PageRenderTime 31ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

/articles/cloud-services-dotnet-multi-tier-app-using-service-bus-queues.md

https://github.com/Auguronomics/azure-content
Markdown | 662 lines | 474 code | 188 blank | 0 comment | 0 complexity | b45f1cbe963d196e872f62b600084ded MD5 | raw file
  1. <properties linkid="dev-net-e2e-multi-tier" urlDisplayName="Multi-Tier Application" pageTitle=".NET Multi-Tier Application - Windows Azure Tutorial" metaKeywords="Azure Service Bus queue tutorial, Azure queue tutorial, Azure worker role tutorial, Azure .NET queue tutorial, Azure C# queue tutorial, Azure C# worker role tutorial" description="A tutorial that helps you develop a multi-tier app in Windows Azure that uses Service Bus queues to communicate between tiers. Samples in .NET." metaCanonical="" services="cloud-services,service-bus" documentationCenter=".NET" title=".NET Multi-Tier Application Using Service Bus Queues" authors="" solutions="" writer="sethm" manager="dwrede" editor="mattshel" />
  2. # .NET Multi-Tier Application Using Service Bus Queues
  3. Developing for Windows Azure is easy using Visual Studio 2012 and the
  4. free Windows Azure SDK for .NET. If you do not already have Visual
  5. Studio 2012, the SDK will automatically install Visual Studio Express 2012 for Web, so you can start developing for Windows Azure entirely for
  6. free. This guide assumes you have no prior experience using Windows
  7. Azure. On completing this guide, you will have an application that uses
  8. multiple Windows Azure resources running in your local environment and
  9. demonstrating how a multi-tier application works.
  10. You will learn:
  11. - How to enable your computer for Windows Azure development with a
  12. single download and install.
  13. - How to use Visual Studio to develop for Windows Azure.
  14. - How to create a multi-tier application in Windows Azure using web
  15. and worker roles.
  16. - How to communicate between tiers using Service Bus Queues.
  17. In this tutorial you'll build and run the multi-tier application in a Windows Azure Cloud Service. The front end will be an ASP.NET MVC web role and the back end will be a worker-role. You could create the same multi-tier application with the front end as a web project that would be deployed to a Windows Azure Web Site instead of a cloud service. For instructions about what to do differently a Windows Azure Web Site front end, see the [Next steps](#nextsteps) section.
  18. A screenshot of the completed application is shown below:
  19. ![][0]
  20. **Note** Windows Azure also provides storage queue functionality. For more information about Windows Azure storage queues and Service Bus queues, see [Windows Azure Queues and Windows Azure Service Bus Queues - Compared and Contrasted][sbqueuecomparison].
  21. [WACOM.INCLUDE [create-account-note](../includes/create-account-note.md)]
  22. <h2><span class="short-header">Inter-role communication</span>Scenario overview: inter-role communication</h2>
  23. To submit an order for processing, the front end UI component, running
  24. in the web role, needs to interact with the middle tier logic running in
  25. the worker role. This example uses Service Bus brokered messaging for
  26. the communication between the tiers.
  27. Using brokered messaging between the web and middle tiers decouples the
  28. two components. In contrast to direct messaging (that is, TCP or HTTP),
  29. the web tier does not connect to the middle tier directly; instead it
  30. pushes units of work, as messages, into the Service Bus, which reliably
  31. retains them until the middle tier is ready to consume and process them.
  32. The Service Bus provides two entities to support brokered messaging:
  33. queues and topics. With queues, each message sent to the queue is
  34. consumed by a single receiver. Topics support the publish/subscribe
  35. pattern in which each published message is made available to each
  36. subscription registered with the topic. Each subscription logically
  37. maintains its own queue of messages. Subscriptions can also be
  38. configured with filter rules that restrict the set of messages passed to
  39. the subscription queue to those that match the filter. This example uses
  40. Service Bus queues.
  41. ![][1]
  42. This communication mechanism has several advantages over direct
  43. messaging, namely:
  44. - **Temporal decoupling.** With the asynchronous messaging pattern,
  45. producers and consumers need not be online at the same time. Service
  46. Bus reliably stores messages until the consuming party is ready to
  47. receive them. This allows the components of the distributed
  48. application to be disconnected, either voluntarily, for example, for
  49. maintenance, or due to a component crash, without impacting the
  50. system as a whole. Furthermore, the consuming application may only
  51. need to come online during certain times of the day.
  52. - **Load leveling**. In many applications, system load varies over
  53. time whereas the processing time required for each unit of work is
  54. typically constant. Intermediating message producers and consumers
  55. with a queue means that the consuming application (the worker) only
  56. needs to be provisioned to accommodate average load rather than peak
  57. load. The depth of the queue will grow and contract as the incoming
  58. load varies. This directly saves money in terms of the amount of
  59. infrastructure required to service the application load.
  60. - **Load balancing.** As load increases, more worker processes can be
  61. added to read from the queue. Each message is processed by only one
  62. of the worker processes. Furthermore, this pull-based load balancing
  63. allows for optimum utilization of the worker machines even if the
  64. worker machines differ in terms of processing power as they will
  65. pull messages at their own maximum rate. This pattern is often
  66. termed the competing consumer pattern.
  67. ![][2]
  68. The following sections discuss the code that implements this
  69. architecture.
  70. <h2><span class="short-header">Set up environment</span>Set up the development environment</h2>
  71. Before you can begin developing your Windows Azure application, you need
  72. to get the tools and set-up your development environment.
  73. 1. To install the Windows Azure SDK for .NET, click the button below:
  74. [Get Tools and SDK][]
  75. 2. Click **install the SDK**.
  76. 3. Choose the link for the version of Visual Studio you are using. The steps in this tutorial use Visual Studio 2012:
  77. ![][32]
  78. 4. When prompted to run or save the installation file, click
  79. **Run**:
  80. ![][3]
  81. 5. In the Web Platform Installer, click **Install** and proceed with the installation:
  82. ![][33]
  83. 6. Once the installation is complete, you will have everything
  84. necessary to start developing. The SDK includes tools that let you
  85. easily develop Windows Azure applications in Visual Studio. If you
  86. do not have Visual Studio installed, it also installs the free
  87. Visual Studio Express for Web.
  88. <h2><span class="short-header">Set up the namespace</span>Set up the Service Bus namespace</h2>
  89. The next step is to create a service namespace, and to obtain a shared
  90. secret key. A service namespace provides an application boundary for
  91. each application exposed through Service Bus. A shared secret key is
  92. automatically generated by the system when a service namespace is
  93. created. The combination of service namespace and shared secret key
  94. provides a credential for Service Bus to authenticate access to an
  95. application.
  96. 1. Log into the [Windows Azure Management Portal][].
  97. 2. In the left navigation pane of the Management Portal, click
  98. **Service Bus**.
  99. 3. In the lower pane of the Management Portal, click **Create**.
  100. ![][6]
  101. 4. In the **Add a new namespace** dialog, enter a namespace name.
  102. The system immediately checks to see if the name is available.
  103. ![][7]
  104. 5. After making sure the namespace name is available, choose the
  105. country or region in which your namespace should be hosted (make
  106. sure you use the same country/region in which you are deploying your
  107. compute resources).
  108. IMPORTANT: Pick the **same region** that you intend to choose for
  109. deploying your application. This will give you the best performance.
  110. 6. Click the check mark. The system now creates your service
  111. namespace and enables it. You might have to wait several minutes as
  112. the system provisions resources for your account.
  113. ![][27]
  114. 7. In the main window, click the name of your service namespace.
  115. ![][30]
  116. 8. Click **Connection Information**.
  117. ![][31]
  118. 9. In the **Access connection information** pane, find the **Default Issuer** and **Default Key** entries.
  119. 10. Make a note of the key, or copy it to the clipboard.
  120. <h2><span class="short-header">Create a web role</span>Create a web role</h2>
  121. In this section, you will build the front end of your application. You
  122. will first create the various pages that your application displays.
  123. After that, you will add the code for submitting items to a Service Bus
  124. Queue and displaying status information about the queue.
  125. ### Create the project
  126. 1. Using administrator privileges, start either Microsoft Visual Studio
  127. 2012 or Microsoft Visual Studio Express for Web. To start Visual
  128. Studio with administrator privileges, right-click **Microsoft Visual
  129. Studio 2012 (or Microsoft Visual Studio Express for Web)** and
  130. then click **Run as administrator**. The Windows Azure compute emulator,
  131. discussed later in this guide, requires that Visual Studio be
  132. launched with administrator privileges.
  133. In Visual Studio, on the **File** menu, click **New**, and then
  134. click **Project**.
  135. ![][8]
  136. 2. From **Installed Templates**, under **Visual C#**, click Cloud and
  137. then click **Windows Azure Project**. Name the project
  138. **MultiTierApp**. Then click **OK**.
  139. ![][9]
  140. 3. From **.NET Framework 4** roles, double-click **ASP.NET MVC 4 Web
  141. Role**.
  142. ![][10]
  143. 4. Hover over **MvcWebRole1** under **Windows Azure Cloud Service solution**, click
  144. the pencil icon, and rename the web role to **FrontendWebRole**. Then Click **OK**. (Make sure you enter "Frontend" with a lower-case "e", not "FrontEnd".)
  145. ![][11]
  146. 5. From the **Select a template** list, click **Internet Application**,
  147. then click **OK**.
  148. ![][12]
  149. 6. In **Solution Explorer**, right-click **References**, then click
  150. **Manage NuGet Packages...** or **Add Library Package Reference**.
  151. 7. Select **Online** on the left-hand side of the dialog. Search for
  152. "**WindowsAzure**" and select the **Windows Azure Service
  153. Bus** item. Then complete the installation and close this dialog.
  154. ![][13]
  155. 8. Note that the required client assemblies are now referenced and some
  156. new code files have been added.
  157. 9. In **Solution Explorer**, right click **Models** and click **Add**,
  158. then click **Class**. In the Name box, type the name
  159. **OnlineOrder.cs**. Then click **Add**.
  160. ### Write the code for your web role
  161. In this section, you will create the various pages that your application
  162. displays.
  163. 1. In the **OnlineOrder.cs** file in Visual Studio, replace the
  164. existing namespace definition with the following code:
  165. namespace FrontendWebRole.Models
  166. {
  167. public class OnlineOrder
  168. {
  169. public string Customer { get; set; }
  170. public string Product { get; set; }
  171. }
  172. }
  173. 2. In **Solution Explorer**, double-click
  174. **Controllers\HomeController.cs**. Add the following **using**
  175. statements at the top of the file to include the namespaces for the
  176. model you just created, as well as Service Bus:
  177. using FrontendWebRole.Models;
  178. using Microsoft.ServiceBus.Messaging;
  179. using Microsoft.ServiceBus;
  180. 3. Also in the **HomeController.cs** file in Visual Studio, replace the
  181. existing namespace definition with the following code. This code
  182. contains methods for handling the submission of items to the queue:
  183. namespace FrontendWebRole.Controllers
  184. {
  185. public class HomeController : Controller
  186. {
  187. public ActionResult Index()
  188. {
  189. // Simply redirect to Submit, since Submit will serve as the
  190. // front page of this application
  191. return RedirectToAction("Submit");
  192. }
  193. public ActionResult About()
  194. {
  195. return View();
  196. }
  197. // GET: /Home/Submit
  198. // Controller method for a view you will create for the submission
  199. // form
  200. public ActionResult Submit()
  201. {
  202. // Will put code for displaying queue message count here.
  203. return View();
  204. }
  205. // POST: /Home/Submit
  206. // Controler method for handling submissions from the submission
  207. // form
  208. [HttpPost]
  209. // Attribute to help prevent cross-site scripting attacks and
  210. // cross-site request forgery
  211. [ValidateAntiForgeryToken]
  212. public ActionResult Submit(OnlineOrder order)
  213. {
  214. if (ModelState.IsValid)
  215. {
  216. // Will put code for submitting to queue here.
  217. return RedirectToAction("Submit");
  218. }
  219. else
  220. {
  221. return View(order);
  222. }
  223. }
  224. }
  225. }
  226. 4. From the **Build** menu, click **Build Solution**.
  227. 5. Now, you will create the view for the **Submit()** method you
  228. created above. Right-click within the Submit() method, and choose
  229. **Add View**
  230. ![][14]
  231. 6. A dialog appears for creating the view. Click the checkbox for
  232. **Create a strongly-typed view**. In addition, select the
  233. **OnlineOrder** class in the **Model class** dropdown, and choose
  234. **Create** under the **Scaffold template** dropdown.
  235. ![][15]
  236. 7. Click **Add**.
  237. 8. Now, you will change the displayed name of your application. In the
  238. **Solution Explorer**, double-click the
  239. **Views\Shared\\_Layout.cshtml** file to open it in the Visual
  240. Studio editor.
  241. 9. Replace all occurrences of **My ASP.NET MVC Application** with
  242. **LITWARE'S Awesome Products**.
  243. 10. Replace **"your logo here"** with **LITWARE'S Awesome Products**:
  244. ![][16]
  245. 11. Remove the **Home**, **About**, and **Contact** links. Delete the highlighted code:
  246. ![][28]
  247. 12. Finally, modify the submission page to include some information about
  248. the queue. In the **Solution Explorer**, double-click the
  249. **Views\Home\Submit.cshtml** file to open it in the Visual Studio
  250. editor. Add the following line after **&lt;h2>Submit&lt;/h2>**. For now,
  251. the **ViewBag.MessageCount** is empty. You will populate it later.
  252. <p>Current Number of Orders in Queue Waiting to be Processed: @ViewBag.MessageCount</p>
  253. 13. You now have implemented your UI. You can press **F5** to run your
  254. application and confirm that it looks as expected.
  255. ![][17]
  256. ### Write the code for submitting items to a Service Bus queue
  257. Now, you will add code for submitting items to a queue. You will first
  258. create a class that contains your Service Bus Queue connection
  259. information. Then, you will initialize your connection from
  260. **Global.aspx.cs**. Finally, you will update the submission code you
  261. created earlier in **HomeController.cs** to actually submit items to a
  262. Service Bus Queue.
  263. 1. In Solution Explorer, right-click **FrontendWebRole** (right-click the project, not the role). Click **Add**, and then click **Class**.
  264. 2. Name the class **QueueConnector.cs**. Click **Add** to create the class.
  265. 3. You will now paste in code that encapsulates your connection
  266. information and contains methods for initializing the connection to
  267. a Service Bus Queue. In QueueConnector.cs, paste in the following code, and enter in
  268. values for **Namespace**, **IssuerName**, and **IssuerKey**. You can
  269. find these values in the [Management Portal][Windows Azure Management Portal].
  270. using System;
  271. using System.Collections.Generic;
  272. using System.Linq;
  273. using System.Web;
  274. using Microsoft.ServiceBus.Messaging;
  275. using Microsoft.ServiceBus;
  276. namespace FrontendWebRole
  277. {
  278. public static class QueueConnector
  279. {
  280. // Thread-safe. Recommended that you cache rather than recreating it
  281. // on every request.
  282. public static QueueClient OrdersQueueClient;
  283. // Obtain these values from the Management Portal
  284. public const string Namespace = "your service bus namespace";
  285. public const string IssuerName = "issuer name";
  286. public const string IssuerKey = "issuer key";
  287. // The name of your queue
  288. public const string QueueName = "OrdersQueue";
  289. public static NamespaceManager CreateNamespaceManager()
  290. {
  291. // Create the namespace manager which gives you access to
  292. // management operations
  293. var uri = ServiceBusEnvironment.CreateServiceUri(
  294. "sb", Namespace, String.Empty);
  295. var tP = TokenProvider.CreateSharedSecretTokenProvider(
  296. IssuerName, IssuerKey);
  297. return new NamespaceManager(uri, tP);
  298. }
  299. public static void Initialize()
  300. {
  301. // Using Http to be friendly with outbound firewalls
  302. ServiceBusEnvironment.SystemConnectivity.Mode =
  303. ConnectivityMode.Http;
  304. // Create the namespace manager which gives you access to
  305. // management operations
  306. var namespaceManager = CreateNamespaceManager();
  307. // Create the queue if it does not exist already
  308. if (!namespaceManager.QueueExists(QueueName))
  309. {
  310. namespaceManager.CreateQueue(QueueName);
  311. }
  312. // Get a client to the queue
  313. var messagingFactory = MessagingFactory.Create(
  314. namespaceManager.Address,
  315. namespaceManager.Settings.TokenProvider);
  316. OrdersQueueClient = messagingFactory.CreateQueueClient(
  317. "OrdersQueue");
  318. }
  319. }
  320. }
  321. 4. Now, you will ensure your **Initialize** method gets called. In the
  322. **Solution Explorer**, double-click **Global.asax\Global.asax.cs**.
  323. 5. Add the following line to the bottom of the **Application_Start**
  324. method:
  325. FrontendWebRole.QueueConnector.Initialize();
  326. 6. Finally, you will update your web code you created earlier, to
  327. submit items to the queue. In the **Solution Explorer**,
  328. double-click **Controllers\HomeController.cs** that you created
  329. earlier.
  330. 7. Update the **Submit()** method as follows to get the message count
  331. for the queue:
  332. public ActionResult Submit()
  333. {
  334. // Get a NamespaceManager which allows you to perform management and
  335. // diagnostic operations on your Service Bus Queues.
  336. var namespaceManager = QueueConnector.CreateNamespaceManager();
  337. // Get the queue, and obtain the message count.
  338. var queue = namespaceManager.GetQueue(QueueConnector.QueueName);
  339. ViewBag.MessageCount = queue.MessageCount;
  340. return View();
  341. }
  342. 8. Update the **Submit(OnlineOrder order)** method as follows to submit
  343. order information to the queue:
  344. public ActionResult Submit(OnlineOrder order)
  345. {
  346. if (ModelState.IsValid)
  347. {
  348. // Create a message from the order
  349. var message = new BrokeredMessage(order);
  350. // Submit the order
  351. QueueConnector.OrdersQueueClient.Send(message);
  352. return RedirectToAction("Submit");
  353. }
  354. else
  355. {
  356. return View(order);
  357. }
  358. }
  359. 9. You can now run your application again. Each time you submit an
  360. order, the message count increases.
  361. ![][18]
  362. <h2><span class="short-header">Configuration manager</span>Cloud configuration manager</h2>
  363. Windows Azure supports a set of managed APIs that provides a consistent way to create new instances of Windows Azure service clients (such as the Service Bus) across Microsoft cloud services. These APIs enable you to instantiate these clients (for example, **CloudBlobClient**, **QueueClient**, **TopicClient**) regardless of where the application is hosted -- on-premises, in a Microsoft cloud service, in web sites, or in a persistent VM Role. You can also use these APIs to retrieve the configuration information necessary for instantiating these clients, and to change the configuration without having to redeploy the calling application. The APIs are located in the [Microsoft.WindowsAzure.Configuration.CloudConfigurationManager][] class. There are also APIs on the client side.
  364. ### Connection string
  365. To instantiate a client (for example, a Service Bus **QueueClient**), you can represent the configuration information as a connection string. On the client side, there is a **CreateFromConnectionString()** method that instantiates that client type by using that connection string. For example, given the following configuration section:
  366. <ConfigurationSettings>
  367. ...
  368. <Setting name="Microsoft.ServiceBus.ConnectionString" value="Endpoint=sb://[yourServiceNamespace].servicebus.windows.net/;SharedSecretIssuer=[issuerName];SharedSecretValue=[yourDefaultKey]" />
  369. </ConfigurationSettings>
  370. The following code retrieves the connection string, creates a queue, and initializes the connection to the queue:
  371. QueueClient Client;
  372. string connectionString =
  373. CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");
  374. var namespaceManager =
  375. NamespaceManager.CreateFromConnectionString(connectionString);
  376. if (!namespaceManager.QueueExists(QueueName))
  377. {
  378. namespaceManager.CreateQueue(QueueName);
  379. }
  380. // Initialize the connection to Service Bus Queue
  381. Client = QueueClient.CreateFromConnectionString(connectionString, QueueName);
  382. The code in the following section uses these configuration management APIs.
  383. <h2><span class="short-header">Create worker role</span>Create the worker role</h2>
  384. You will now create the worker role that processes the order
  385. submissions. This example uses the **Worker Role with Service Bus Queue** Visual Studio project template. First, you will use Server Explorer in Visual Studio to obtain the required credentials.
  386. 1. From the menu bar in Visual Studio, choose **View**, and then click **Server Explorer**. A **Service Bus** node appears under **Windows Azure** within the Server Explorer hierarchy, as in the following figure.
  387. ![][21]
  388. 2. In Server Explorer, expand **Windows Azure**, then right-click **Service Bus**, then click **Add New Connection**.
  389. 3. In the **Add Connection** dialog, type the name of the service namespace, the issuer name, and the issuer key. Then click **OK** to connect.
  390. ![][22]
  391. 4. In Visual Studio, in **Solution Explorer** right-click the
  392. **Roles** folder under the **MultiTierApp** project.
  393. 5. Click **Add**, and then click **New Worker Role Project**. The **Add New Role Project** dialog appears.
  394. ![][26]
  395. 6. In the **Add New Role Project dialog**, click **Worker Role with Service Bus Queue**, as in the following figure:
  396. ![][23]
  397. 7. In the **Name** box, name the project **OrderProcessingRole**. Then click **Add**.
  398. 8. In Server Explorer, right-click the name of your service namespace, then click **Properties**. In the Visual Studio **Properties** pane, the first entry contains a connection string that is populated with the service namespace endpoint containing the required authorization credentials. For example, see the following figure. Double-click **ConnectionString**, and then press **Ctrl+C** to copy this string to the clipboard.
  399. ![][24]
  400. 9. In Solution Explorer, right-click the **OrderProcessingRole** you created in step 7 (make sure that you right-click **OrderProcessingRole** under **Roles**, and not the class). Then click **Properties**.
  401. 10. In the **Settings** tab of the **Properties** dialog, click inside the **Value** box for **Microsoft.ServiceBus.ConnectionString**, and then paste the endpoint value you copied in step 8.
  402. ![][25]
  403. 11. Create an **OnlineOrder** class to represent the orders as you process them from the queue. You can reuse a class you have already created. In Solution Explorer, right-click the **OrderProcessingRole** project (right-click the project, not the role). Click **Add**, then click **Existing Item**.
  404. 12. Browse to the subfolder for **FrontendWebRole\Models**, and double-click **OnlineOrder.cs** to add it to this project.
  405. 13. Replace the value of the **QueueName** variable in **WorkerRole.cs** from `"ProcessingQueue"` to `"OrdersQueue"` as in the following code:
  406. // The name of your queue
  407. const string QueueName = "OrdersQueue";
  408. 14. Add the following using statement at the top of the WorkerRole.cs file:
  409. using FrontendWebRole.Models;
  410. 15. In the `Run()` function, inside the `OnMessage` call, add the following code inside the `try` clause:
  411. Trace.WriteLine("Processing", receivedMessage.SequenceNumber.ToString());
  412. // View the message as an OnlineOrder
  413. OnlineOrder order = receivedMessage.GetBody<OnlineOrder>();
  414. Trace.WriteLine(order.Customer + ": " + order.Product, "ProcessingMessage");
  415. receivedMessage.Complete();
  416. 16. You have completed the application. You can test the full
  417. application as you did earlier, by pressing F5. Note that the message count does not increment, because the worker role processes items from the queue and marks them as complete. You can see the trace output of your
  418. worker role by viewing the Windows Azure Compute Emulator UI. You
  419. can do this by right-clicking the emulator icon in the notification
  420. area of your taskbar and selecting **Show Compute Emulator UI**.
  421. ![][19]
  422. ![][20]
  423. <h2><a name="nextsteps"></a><span class="short-header">Next steps</span>Next steps</h2>
  424. To learn more about Service Bus, see the following resources:
  425. * [Windows Azure Service Bus][sbmsdn]
  426. * [Service Bus How To's][sbwacom]
  427. * [How to Use Service Bus Queues][sbwacomqhowto]
  428. To learn more about multi-tier scenarios, or to learn how to deploy an application to a cloud service, see:
  429. * [.NET Multi-Tier Application Using Storage Tables, Queues, and Blobs][mutitierstorage]
  430. You might want to implement the front-end of a multi-tier application in a Windows Azure Web Site instead of a Windows Azure Cloud Service. To learn more about the difference between web sites and cloud services, see [Windows Azure Execution Models][executionmodels].
  431. To implement the application you create in this tutorial as a standard web project instead of as a cloud service web role, follow the steps in this tutorial with the following differences:
  432. 1. When you create the project, choose the **ASP.NET MVC 4 Web Application** project template in the **Web** category instead of the **Cloud Service** template in the **Cloud** category. Then follow the same directions for creating the MVC application, until you get to the **Cloud configuration manager** section.
  433. 2. When you create the worker role, create it in a new, separate solution, similar to the original instructions for the web role. Now however, you're creating just the worker role in the cloud service project. Then follow the same directions for creating the worker role.
  434. 3. You can test the front-end and back-end separately, or you can run both simultaneously in separate Visual Studio instances.
  435. To learn how to deploy the front end to a Windows Azure Web Site, see [Deploying an ASP.NET Web Application to a Windows Azure Web Site](http://www.windowsazure.com/en-us/develop/net/tutorials/get-started/). To learn how to deploy the back end to a Windows Azure Cloud Service, see [.NET Multi-Tier Application Using Storage Tables, Queues, and Blobs][mutitierstorage].
  436. [0]: ./media/cloud-services-dotnet-multi-tier-app-using-service-bus-queues/getting-started-multi-tier-01.png
  437. [1]: ./media/cloud-services-dotnet-multi-tier-app-using-service-bus-queues/getting-started-multi-tier-100.png
  438. [sbqueuecomparison]: http://msdn.microsoft.com/en-us/library/windowsazure/hh767287.aspx
  439. [2]: ./media/cloud-services-dotnet-multi-tier-app-using-service-bus-queues/getting-started-multi-tier-101.png
  440. [Get Tools and SDK]: http://go.microsoft.com/fwlink/?LinkId=271920
  441. [3]: ./media/cloud-services-dotnet-multi-tier-app-using-service-bus-queues/getting-started-3.png
  442. [Windows Azure Management Portal]: http://manage.windowsazure.com
  443. [6]: ./media/cloud-services-dotnet-multi-tier-app-using-service-bus-queues/sb-queues-03.png
  444. [7]: ./media/cloud-services-dotnet-multi-tier-app-using-service-bus-queues/sb-queues-04.png
  445. [8]: ./media/cloud-services-dotnet-multi-tier-app-using-service-bus-queues/getting-started-multi-tier-09.png
  446. [9]: ./media/cloud-services-dotnet-multi-tier-app-using-service-bus-queues/getting-started-multi-tier-10.jpg
  447. [10]: ./media/cloud-services-dotnet-multi-tier-app-using-service-bus-queues/getting-started-multi-tier-11.png
  448. [11]: ./media/cloud-services-dotnet-multi-tier-app-using-service-bus-queues/getting-started-multi-tier-02.png
  449. [12]: ./media/cloud-services-dotnet-multi-tier-app-using-service-bus-queues/getting-started-multi-tier-12.png
  450. [13]: ./media/cloud-services-dotnet-multi-tier-app-using-service-bus-queues/getting-started-multi-tier-13.png
  451. [14]: ./media/cloud-services-dotnet-multi-tier-app-using-service-bus-queues/getting-started-multi-tier-33.png
  452. [15]: ./media/cloud-services-dotnet-multi-tier-app-using-service-bus-queues/getting-started-multi-tier-34.png
  453. [16]: ./media/cloud-services-dotnet-multi-tier-app-using-service-bus-queues/getting-started-multi-tier-35.png
  454. [17]: ./media/cloud-services-dotnet-multi-tier-app-using-service-bus-queues/getting-started-multi-tier-36.png
  455. [18]: ./media/cloud-services-dotnet-multi-tier-app-using-service-bus-queues/getting-started-multi-tier-37.png
  456. [19]: ./media/cloud-services-dotnet-multi-tier-app-using-service-bus-queues/getting-started-multi-tier-38.png
  457. [20]: ./media/cloud-services-dotnet-multi-tier-app-using-service-bus-queues/getting-started-multi-tier-39.png
  458. [21]: ./media/cloud-services-dotnet-multi-tier-app-using-service-bus-queues/SBExplorer.png
  459. [22]: ./media/cloud-services-dotnet-multi-tier-app-using-service-bus-queues/SBExplorerAddConnect.png
  460. [23]: ./media/cloud-services-dotnet-multi-tier-app-using-service-bus-queues/SBWorkerRole1.png
  461. [24]: ./media/cloud-services-dotnet-multi-tier-app-using-service-bus-queues/SBExplorerProperties.png
  462. [25]: ./media/cloud-services-dotnet-multi-tier-app-using-service-bus-queues/SBWorkerRoleProperties.png
  463. [26]: ./media/cloud-services-dotnet-multi-tier-app-using-service-bus-queues/SBNewWorkerRole.png
  464. [27]: ./media/cloud-services-dotnet-multi-tier-app-using-service-bus-queues/getting-started-multi-tier-27.png
  465. [28]: ./media/cloud-services-dotnet-multi-tier-app-using-service-bus-queues/getting-started-multi-tier-40.png
  466. [30]: ./media/cloud-services-dotnet-multi-tier-app-using-service-bus-queues/sb-queues-09.png
  467. [31]: ./media/cloud-services-dotnet-multi-tier-app-using-service-bus-queues/sb-queues-06.png
  468. [32]: ./media/cloud-services-dotnet-multi-tier-app-using-service-bus-queues/getting-started-41.png
  469. [33]: ./media/cloud-services-dotnet-multi-tier-app-using-service-bus-queues/getting-started-4-2-WebPI.png
  470. [sbmsdn]: http://msdn.microsoft.com/en-us/library/windowsazure/ee732537.aspx
  471. [sbwacom]: /en-us/manage/services/service-bus/
  472. [sbwacomqhowto]: /en-us/develop/net/how-to-guides/service-bus-queues/
  473. [mutitierstorage]: /en-us/develop/net/tutorials/multi-tier-web-site/1-overview/
  474. [executionmodels]: http://www.windowsazure.com/en-us/develop/net/fundamentals/compute/