Skip to content

Commit 9e5572c

Browse files
authored
Merge pull request #226095 from spelluru/tutorialfix0202-2
missing instructions to get connection string
2 parents c3aa06b + 930f539 commit 9e5572c

File tree

3 files changed

+59
-37
lines changed

3 files changed

+59
-37
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
title: include file
3+
description: include file
4+
services: service-bus-messaging
5+
author: spelluru
6+
ms.service: service-bus-messaging
7+
ms.topic: include
8+
ms.date: 02/02/2022
9+
ms.author: spelluru
10+
ms.custom: include file
11+
---
12+
13+
## Get connection string to the namespace (Azure portal)
14+
Creating a new namespace automatically generates an initial Shared Access Signature (SAS) policy with primary and secondary keys, and primary and secondary connection strings that each grant full control over all aspects of the namespace. See [Service Bus authentication and authorization](../service-bus-authentication-and-authorization.md) for information about how to create rules with more constrained rights for regular senders and receivers.
15+
16+
A client can use the connection string to connect to the Service Bus namespace. To copy the primary connection string for your namespace, follow these steps:
17+
18+
1. On the **Service Bus Namespace** page, select **Shared access policies** on the left menu.
19+
3. On the **Shared access policies** page, select **RootManageSharedAccessKey**.
20+
4. In the **Policy: RootManageSharedAccessKey** window, select the copy button next to **Primary Connection String**, to copy the connection string to your clipboard for later use. Paste this value into Notepad or some other temporary location.
21+
22+
:::image type="content" source="./media/service-bus-create-namespace-portal/connection-string.png" lightbox="./media/service-bus-create-namespace-portal/connection-string.png" alt-text="Screenshot shows an S A S policy called RootManageSharedAccessKey, which includes keys and connection strings.":::
23+
24+
You can use this page to copy primary key, secondary key, primary connection string, and secondary connection string.

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

Lines changed: 30 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

@@ -95,6 +88,8 @@ The first step is to create a *namespace*, and obtain a [Shared Access Signature
9588

9689
[!INCLUDE [service-bus-create-namespace-portal](./includes/service-bus-create-namespace-portal.md)]
9790

91+
[!INCLUDE [get-namespace-connection-string](./includes/get-namespace-connection-string.md)]
92+
9893
## Create a web role
9994

10095
In this section, you build the front end of your application. First, you
@@ -105,12 +100,12 @@ queue and displays status information about the queue.
105100
### Create the project
106101

107102
1. Using administrator privileges, start Visual
108-
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,
109104
discussed later in this article, requires that Visual Studio be
110105
started with administrator privileges.
111106

112-
In Visual Studio, on the **File** menu, click **New**, and then
113-
click **Project**.
107+
In Visual Studio, on the **File** menu, select **New**, and then
108+
select **Project**.
114109
2. On the **Templates** page, follow these steps:
115110
1. Select **C#** for programming language.
116111
1. Select **Cloud** for the project type.
@@ -124,24 +119,24 @@ queue and displays status information about the queue.
124119
1. On the **Roles** page, double-click **ASP.NET Web Role**, and select **OK**.
125120

126121
:::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":::
127-
4. Hover over **WebRole1** under **Azure Cloud Service solution**, click
128-
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".)
129124

130125
:::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.":::
131126
5. In the **Create a new ASP.NET Web Application** dialog box, select **MVC**, and then select **Create**.
132127

133128
:::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.":::
134-
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
135130
**Manage NuGet Packages**.
136-
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.
137132

138133
:::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.":::
139134

140135
Note that the required client assemblies are now referenced and some new code files have been added.
141136
10. Follow the same steps to add the `Azure.Identity` NuGet package to the project.
142-
10. In **Solution Explorer**, expand **FronendWebRole**, right-click **Models** and click **Add**,
143-
then click **Class**. In the **Name** box, type the name
144-
**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**.
145140

146141
### Write the code for your web role
147142
In this section, you create the various pages that your application displays.
@@ -222,7 +217,7 @@ In this section, you create the various pages that your application displays.
222217
}
223218
}
224219
```
225-
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.
226221
5. Now, create the view for the `Submit()` method you
227222
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**.
228223
6. In the **Add New Scaffolded Item** dialog box, select **Add**.
@@ -244,7 +239,7 @@ In this section, you create the various pages that your application displays.
244239
the queue. In **Solution Explorer**, double-click the
245240
**Views\Home\Submit.cshtml** file to open it in the Visual Studio
246241
editor. Add the following line after `<h2>Submit</h2>`. For now,
247-
the `ViewBag.MessageCount` is empty. You will populate it later.
242+
the `ViewBag.MessageCount` is empty. You'll populate it later.
248243

249244
```html
250245
<p>Current number of orders in queue waiting to be processed: @ViewBag.MessageCount</p>
@@ -262,8 +257,8 @@ Global.aspx.cs. Finally, update the submission code you
262257
created earlier in HomeController.cs to actually submit items to a
263258
Service Bus queue.
264259

265-
1. In **Solution Explorer**, right-click **FrontendWebRole** (right-click the project, not the role). Click **Add**, and then click **Class**.
266-
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.
267262
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.
268263

269264
```csharp
@@ -360,25 +355,25 @@ Service Bus queue.
360355
:::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.":::
361356

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

366361
1. Make sure you have connected Visual Studio to your Azure account.
367362
2. In Visual Studio, in **Solution Explorer** right-click the
368363
**Roles** folder under the **MultiTierApp** project.
369-
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.
370365

371366
:::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.":::
372367
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.
373368

374369
:::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.":::
375-
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**.
376371
1. In **Solution Explorer**, right-click **OrderProcessingRole** project, and select **Manage NuGet Packages**.
377372
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.
378373

379374
:::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.":::
380375
1. Follow the same steps to add the `Azure.Identity` NuGet package to the project.
381-
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**.
382377
1. Browse to the subfolder for **FrontendWebRole\Models**, and then double-click **OnlineOrder.cs** to add it to this project.
383378
1. Add the following `using` statement to the **WorkerRole.cs** file in the **OrderProcessingRole** project.
384379

@@ -455,16 +450,16 @@ submissions. This example uses the **Worker Role with Service Bus Queue** Visual
455450
}
456451
}
457452
```
458-
14. You have completed the application. You can test the full
453+
14. You've completed the application. You can test the full
459454
application by right-clicking the MultiTierApp project in Solution Explorer,
460-
selecting **Set as Startup Project**, and then pressing F5. Note that the
461-
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
462457
from the queue and marks them as complete. You can see the trace output of
463458
your worker role by viewing the Azure Compute Emulator UI. You
464459
can do this by right-clicking the emulator icon in the notification
465460
area of your taskbar and selecting **Show Compute Emulator UI**.
466461

467-
:::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.":::
468463

469464
:::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.":::
470465

articles/service-bus-messaging/service-bus-tutorial-topics-subscriptions-portal.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,16 @@ Each [subscription to a topic](service-bus-messaging-overview.md#topics) can rec
3838

3939
[!INCLUDE [service-bus-create-namespace-portal](./includes/service-bus-create-namespace-portal.md)]
4040

41+
42+
[!INCLUDE [get-namespace-connection-string](./includes/get-namespace-connection-string.md)]
43+
4144
[!INCLUDE [service-bus-create-topics-three-subscriptions-portal](./includes/service-bus-create-topics-three-subscriptions-portal.md)]
4245

4346

4447

4548
## Create filter rules on subscriptions
4649

47-
After the namespace and topic/subscriptions are provisioned, and you have the necessary credentials, you're ready to create filter rules on the subscriptions, then send and receive messages. You can examine the code in [this GitHub sample folder](https://github.com/Azure/azure-service-bus/tree/master/samples/Java/azure-servicebus/TopicFilters).
50+
After the namespace and topic/subscriptions are provisioned, and you have the connection string to the namespace, you're ready to create filter rules on the subscriptions, then send and receive messages. You can examine the code in [this GitHub sample folder](https://github.com/Azure/azure-service-bus/tree/master/samples/Java/azure-servicebus/TopicFilters).
4851

4952
## Send and receive messages
5053

@@ -58,7 +61,7 @@ To run the code, follow these steps:
5861

5962
2. Navigate to the sample folder `azure-service-bus\samples\DotNet\Azure.Messaging.ServiceBus\BasicSendReceiveTutorialWithFilters`.
6063

61-
3. Obtain the connection string you copied to Notepad in the Obtain the management credentials section of this tutorial. You also need the name of the topic you created in the previous section.
64+
3. Obtain the connection string you copied to Notepad earlier in this tutorial. You also need the name of the topic you created in the previous section.
6265

6366
4. At the command prompt, type the following command:
6467

0 commit comments

Comments
 (0)