Skip to content

Commit 930f539

Browse files
committed
acrolynx
1 parent 4361009 commit 930f539

File tree

1 file changed

+28
-35
lines changed

1 file changed

+28
-35
lines changed

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

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ms.custom: devx-track-csharp
1111

1212
Developing for Microsoft Azure is easy using Visual Studio and the free Azure SDK for .NET. This tutorial walks you through the steps to create an application that uses multiple Azure resources running in your local environment.
1313

14-
You will learn the following:
14+
You'll learn the following:
1515

1616
* How to enable your computer for Azure development with a
1717
single download and install.
@@ -22,7 +22,7 @@ You will learn the following:
2222

2323
[!INCLUDE [create-account-note](../../includes/create-account-note.md)]
2424

25-
In this tutorial, you'll build and run the multi-tier application in an Azure cloud service. The front end is an ASP.NET MVC web role and the back end is a worker-role that uses a Service Bus queue. You can create the same multi-tier application with the front end as a web project, that is deployed to an Azure website instead of a cloud service. You can also try out the [.NET on-premises/cloud hybrid application](../azure-relay/service-bus-dotnet-hybrid-app-using-service-bus-relay.md) tutorial.
25+
In this tutorial, you'll build and run the multi-tier application in an Azure cloud service. The front end is an ASP.NET MVC web role and the back end is a worker-role that uses a Service Bus queue. You can create the same multi-tier application with the front end as a web project that is deployed to an Azure website instead of a cloud service. You can also try out the [.NET on-premises/cloud hybrid application](../azure-relay/service-bus-dotnet-hybrid-app-using-service-bus-relay.md) tutorial.
2626

2727
The following screenshot shows the completed application.
2828

@@ -36,7 +36,7 @@ the communication between the tiers.
3636

3737
Using Service Bus messaging between the web and middle tiers decouples the
3838
two components. In contrast to direct messaging (that is, TCP or HTTP),
39-
the web tier does not connect to the middle tier directly; instead it
39+
the web tier doesn't connect to the middle tier directly; instead it
4040
pushes units of work, as messages, into Service Bus, which reliably
4141
retains them until the middle tier is ready to consume and process them.
4242

@@ -49,19 +49,12 @@ configured with filter rules that restrict the set of messages passed to
4949
the subscription queue to those that match the filter. The following example uses
5050
Service Bus queues.
5151

52-
:::image type="content" source="./media/service-bus-dotnet-multi-tier-app-using-service-bus-queues/getting-started-multi-tier-100.png" alt-text="Diagram showing the communication between the Web Role, the Service Bus, and the Worker Role.":::
52+
:::image type="content" source="./media/service-bus-dotnet-multi-tier-app-using-service-bus-queues/getting-started-multi-tier-100.png" alt-text="Diagram showing the communication between the Web Role, Service Bus, and the Worker Role.":::
5353

5454
This communication mechanism has several advantages over direct
5555
messaging:
5656

57-
* **Temporal decoupling.** With the asynchronous messaging pattern,
58-
producers and consumers need not be online at the same time. Service
59-
Bus reliably stores messages until the consuming party is ready to
60-
receive them. This enables the components of the distributed
61-
application to be disconnected, either voluntarily, for example, for
62-
maintenance, or due to a component crash, without impacting the
63-
system as a whole. Furthermore, the consuming application might only
64-
need to come online during certain times of the day.
57+
* **Temporal decoupling.** When you use the asynchronous messaging pattern, producers and consumers don't need to be online at the same time. Service Bus reliably stores messages until the consuming party is ready to receive them. This enables the components of the distributed application to be disconnected, either voluntarily, for example, for maintenance, or due to a component crash, without impacting the system as a whole. Furthermore, the consuming application might only need to come online during certain times of the day.
6558
* **Load leveling.** In many applications, system load varies over
6659
time, while the processing time required for each unit of work is
6760
typically constant. Intermediating message producers and consumers
@@ -73,7 +66,7 @@ messaging:
7366
added to read from the queue. Each message is processed by only one
7467
of the worker processes. Furthermore, this pull-based load balancing
7568
enables optimal use of the worker machines even if the
76-
worker machines differ in terms of processing power, as they will
69+
worker machines differ in terms of processing power, as they'll
7770
pull messages at their own maximum rate. This pattern is often
7871
termed the *competing consumer* pattern.
7972

@@ -107,12 +100,12 @@ queue and displays status information about the queue.
107100
### Create the project
108101

109102
1. Using administrator privileges, start Visual
110-
Studio: right-click the **Visual Studio** program icon, and then click **Run as administrator**. The Azure Compute Emulator,
103+
Studio: right-click the **Visual Studio** program icon, and then select **Run as administrator**. The Azure Compute Emulator,
111104
discussed later in this article, requires that Visual Studio be
112105
started with administrator privileges.
113106

114-
In Visual Studio, on the **File** menu, click **New**, and then
115-
click **Project**.
107+
In Visual Studio, on the **File** menu, select **New**, and then
108+
select **Project**.
116109
2. On the **Templates** page, follow these steps:
117110
1. Select **C#** for programming language.
118111
1. Select **Cloud** for the project type.
@@ -126,24 +119,24 @@ queue and displays status information about the queue.
126119
1. On the **Roles** page, double-click **ASP.NET Web Role**, and select **OK**.
127120

128121
:::image type="content" source="./media/service-bus-dotnet-multi-tier-app-using-service-bus-queues/getting-started-multi-tier-11.png" alt-text="Select Web Role":::
129-
4. Hover over **WebRole1** under **Azure Cloud Service solution**, click
130-
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".)
122+
4. Hover over **WebRole1** under **Azure Cloud Service solution**, select
123+
the pencil icon, and rename the web role to **FrontendWebRole**. Then select **OK**. (Make sure you enter "Frontend" with a lower-case 'e,' not "FrontEnd".)
131124

132125
:::image type="content" source="./media/service-bus-dotnet-multi-tier-app-using-service-bus-queues/getting-started-multi-tier-02.png" alt-text="Screenshot of the New Microsoft Azure Cloud Service dialog box with the solution renamed to FrontendWebRole.":::
133126
5. In the **Create a new ASP.NET Web Application** dialog box, select **MVC**, and then select **Create**.
134127

135128
:::image type="content" source="./media/service-bus-dotnet-multi-tier-app-using-service-bus-queues/getting-started-multi-tier-12.png" alt-text="Screenshot of the New ASP.NET Project dialog box with MVC highlighted and outlined in red and the Change Authentication option outlined in red.":::
136-
8. In **Solution Explorer**, in the **FrontendWebRole** project, right-click **References**, then click
129+
8. In **Solution Explorer**, in the **FrontendWebRole** project, right-click **References**, then select
137130
**Manage NuGet Packages**.
138-
9. Click the **Browse** tab, then search for **Azure.Messaging.ServiceBus**. Select the **Azure.Messaging.ServiceBus** package, select **Install**, and accept the terms of use.
131+
9. Select the **Browse** tab, then search for **Azure.Messaging.ServiceBus**. Select the **Azure.Messaging.ServiceBus** package, select **Install**, and accept the terms of use.
139132

140133
:::image type="content" source="./media/service-bus-dotnet-multi-tier-app-using-service-bus-queues/getting-started-multi-tier-13.png" alt-text="Screenshot of the Manage NuGet Packages dialog box with the Azure.Messaging.ServiceBus highlighted and the Install option outlined in red.":::
141134

142135
Note that the required client assemblies are now referenced and some new code files have been added.
143136
10. Follow the same steps to add the `Azure.Identity` NuGet package to the project.
144-
10. In **Solution Explorer**, expand **FronendWebRole**, right-click **Models** and click **Add**,
145-
then click **Class**. In the **Name** box, type the name
146-
**OnlineOrder.cs**. Then click **Add**.
137+
10. In **Solution Explorer**, expand **FronendWebRole**, right-click **Models** and select **Add**,
138+
then select **Class**. In the **Name** box, type the name
139+
**OnlineOrder.cs**. Then select **Add**.
147140

148141
### Write the code for your web role
149142
In this section, you create the various pages that your application displays.
@@ -224,7 +217,7 @@ In this section, you create the various pages that your application displays.
224217
}
225218
}
226219
```
227-
4. From the **Build** menu, click **Build Solution** to test the accuracy of your work so far.
220+
4. From the **Build** menu, select **Build Solution** to test the accuracy of your work so far.
228221
5. Now, create the view for the `Submit()` method you
229222
created earlier. Right-click within the `Submit()` method (the overload of `Submit()` that takes no parameters) in the **HomeController.cs** file, and then choose **Add View**.
230223
6. In the **Add New Scaffolded Item** dialog box, select **Add**.
@@ -246,7 +239,7 @@ In this section, you create the various pages that your application displays.
246239
the queue. In **Solution Explorer**, double-click the
247240
**Views\Home\Submit.cshtml** file to open it in the Visual Studio
248241
editor. Add the following line after `<h2>Submit</h2>`. For now,
249-
the `ViewBag.MessageCount` is empty. You will populate it later.
242+
the `ViewBag.MessageCount` is empty. You'll populate it later.
250243

251244
```html
252245
<p>Current number of orders in queue waiting to be processed: @ViewBag.MessageCount</p>
@@ -264,8 +257,8 @@ Global.aspx.cs. Finally, update the submission code you
264257
created earlier in HomeController.cs to actually submit items to a
265258
Service Bus queue.
266259

267-
1. In **Solution Explorer**, right-click **FrontendWebRole** (right-click the project, not the role). Click **Add**, and then click **Class**.
268-
2. Name the class **QueueConnector.cs**. Click **Add** to create the class.
260+
1. In **Solution Explorer**, right-click **FrontendWebRole** (right-click the project, not the role). Select **Add**, and then select **Class**.
261+
2. Name the class **QueueConnector.cs**. Select **Add** to create the class.
269262
3. Now, add code that encapsulates the connection information and initializes the connection to a Service Bus queue. Replace the entire contents of QueueConnector.cs with the following code, and enter values for `your Service Bus namespace` (your namespace name) and `yourKey`, which is the **primary key** you previously obtained from the Azure portal.
270263

271264
```csharp
@@ -362,25 +355,25 @@ Service Bus queue.
362355
:::image type="content" source="./media/service-bus-dotnet-multi-tier-app-using-service-bus-queues/getting-started-multi-tier-app2.png" alt-text="Screenshot of the application's Submit page with the message count incremented to 1.":::
363356

364357
## Create the worker role
365-
You will now create the worker role that processes the order
358+
You'll now create the worker role that processes the order
366359
submissions. This example uses the **Worker Role with Service Bus Queue** Visual Studio project template. You already obtained the required credentials from the portal.
367360

368361
1. Make sure you have connected Visual Studio to your Azure account.
369362
2. In Visual Studio, in **Solution Explorer** right-click the
370363
**Roles** folder under the **MultiTierApp** project.
371-
3. Click **Add**, and then click **New Worker Role Project**. The **Add New Role Project** dialog box appears.
364+
3. Select **Add**, and then select **New Worker Role Project**. The **Add New Role Project** dialog box appears.
372365

373366
:::image type="content" source="./media/service-bus-dotnet-multi-tier-app-using-service-bus-queues/SBNewWorkerRole.png" alt-text="Screenshot of the Solution Explorer pane with the New Worker Role Project option and Add option highlighted.":::
374367
1. In the **Add New Role Project** dialog box, select **Worker Role**. Don't select **Worker Role with Service Bus Queue** as it generates code that uses the legacy Service Bus SDK.
375368

376369
:::image type="content" source="./media/service-bus-dotnet-multi-tier-app-using-service-bus-queues/SBWorkerRole1.png" alt-text="Screenshot of the Ad New Role Project dialog box with the Worker Role with Service Bus Queue option highlighted and outlined in red.":::
377-
5. In the **Name** box, name the project **OrderProcessingRole**. Then click **Add**.
370+
5. In the **Name** box, name the project **OrderProcessingRole**. Then select **Add**.
378371
1. In **Solution Explorer**, right-click **OrderProcessingRole** project, and select **Manage NuGet Packages**.
379372
9. Select the **Browse** tab, then search for **Azure.Messaging.ServiceBus**. Select the **Azure.Messaging.ServiceBus** package, select **Install**, and accept the terms of use.
380373

381374
:::image type="content" source="./media/service-bus-dotnet-multi-tier-app-using-service-bus-queues/getting-started-multi-tier-13.png" alt-text="Screenshot of the Manage NuGet Packages dialog box with the Azure.Messaging.ServiceBus highlighted and the Install option outlined in red.":::
382375
1. Follow the same steps to add the `Azure.Identity` NuGet package to the project.
383-
1. 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** class (right-click the class icon, not the role). Click **Add**, then click **Existing Item**.
376+
1. 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** class (right-click the class icon, not the role). Select **Add**, then select **Existing Item**.
384377
1. Browse to the subfolder for **FrontendWebRole\Models**, and then double-click **OnlineOrder.cs** to add it to this project.
385378
1. Add the following `using` statement to the **WorkerRole.cs** file in the **OrderProcessingRole** project.
386379

@@ -457,16 +450,16 @@ submissions. This example uses the **Worker Role with Service Bus Queue** Visual
457450
}
458451
}
459452
```
460-
14. You have completed the application. You can test the full
453+
14. You've completed the application. You can test the full
461454
application by right-clicking the MultiTierApp project in Solution Explorer,
462-
selecting **Set as Startup Project**, and then pressing F5. Note that the
463-
message count does not increment, because the worker role processes items
455+
selecting **Set as Startup Project**, and then pressing F5. The
456+
message count doesn't increment, because the worker role processes items
464457
from the queue and marks them as complete. You can see the trace output of
465458
your worker role by viewing the Azure Compute Emulator UI. You
466459
can do this by right-clicking the emulator icon in the notification
467460
area of your taskbar and selecting **Show Compute Emulator UI**.
468461

469-
:::image type="content" source="./media/service-bus-dotnet-multi-tier-app-using-service-bus-queues/getting-started-multi-tier-38.png" alt-text="Screenshot of what appears when you click the emulator icon. Show Compute Emulator UI is in the list of options.":::
462+
:::image type="content" source="./media/service-bus-dotnet-multi-tier-app-using-service-bus-queues/getting-started-multi-tier-38.png" alt-text="Screenshot of what appears when you select the emulator icon. Show Compute Emulator UI is in the list of options.":::
470463

471464
:::image type="content" source="./media/service-bus-dotnet-multi-tier-app-using-service-bus-queues/getting-started-multi-tier-39.png" alt-text="Screenshot of the Microsoft Azure Compute Emulator (Express) dialog box.":::
472465

0 commit comments

Comments
 (0)