Skip to content

Commit a0cd5ab

Browse files
committed
update
1 parent 9f3a792 commit a0cd5ab

File tree

3 files changed

+45
-29
lines changed

3 files changed

+45
-29
lines changed

articles/service-bus-messaging/service-bus-dotnet-get-started-with-queues.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ms.custom: contperf-fy22q2, mode-api
1010

1111
# Quickstart: Send and receive messages from an Azure Service Bus queue (.NET)
1212

13-
In this quickstart, you will do the following steps:
13+
In this quickstart, you'll do the following steps:
1414

1515
1. Create a Service Bus namespace, using the Azure portal.
1616
2. Create a Service Bus queue, using the Azure portal.
@@ -108,15 +108,17 @@ This section shows you how to create a .NET console application to send messages
108108
109109
### [Passwordless](#tab/passwordless)
110110
111-
> [!IMPORTANT]
112-
> As per the `TODO` comment in the source code, update the placeholder values (`<NAMESPACE-NAME>` and `<QUEUE-NAME>`) in the code snippet with the values from the Service Bus you created.
113-
114111
* Creates a [ServiceBusClient](/dotnet/api/azure.messaging.servicebus.servicebusclient) object using the `DefaultAzureCredential` object. `DefaultAzureCredential` will automatically discover and use the credentials of your Visual Studio login to authenticate to Azure Service Bus.
115112
* Invokes the [CreateSender](/dotnet/api/azure.messaging.servicebus.servicebusclient.createsender) method on the [ServiceBusClient](/dotnet/api/azure.messaging.servicebus.servicebusclient) object to create a [ServiceBusSender](/dotnet/api/azure.messaging.servicebus.servicebussender) object for the specific Service Bus queue.
116113
* Creates a [ServiceBusMessageBatch](/dotnet/api/azure.messaging.servicebus.servicebusmessagebatch) object by using the [ServiceBusSender.CreateMessageBatchAsync](/dotnet/api/azure.messaging.servicebus.servicebussender.createmessagebatchasync) method.
117114
* Add messages to the batch using the [ServiceBusMessageBatch.TryAddMessage](/dotnet/api/azure.messaging.servicebus.servicebusmessagebatch.tryaddmessage).
118115
* Sends the batch of messages to the Service Bus queue using the [ServiceBusSender.SendMessagesAsync](/dotnet/api/azure.messaging.servicebus.servicebussender.sendmessagesasync) method.
119116
117+
> [!IMPORTANT]
118+
> Update placeholder values (`<NAMESPACE-CONNECTION-STRING>` and `<QUEUE-NAME>`) in the code snippet with names of your Service Bus namespace and queue.
119+
120+
121+
120122
```csharp
121123
using Azure.Messaging.ServiceBus;
122124
using Azure.Identity;
@@ -181,15 +183,16 @@ This section shows you how to create a .NET console application to send messages
181183
182184
### [Connection string](#tab/connection-string)
183185
184-
> [!IMPORTANT]
185-
> Update placeholder values (`<NAMESPACE-CONNECTION-STRING>` and `<QUEUE-NAME>`) in the code snippet with actual values you noted down earlier.
186-
187186
* Creates a [ServiceBusClient](/dotnet/api/azure.messaging.servicebus.servicebusclient) object using the connection string.
188187
* Invokes the [CreateSender](/dotnet/api/azure.messaging.servicebus.servicebusclient.createsender) method on the [ServiceBusClient](/dotnet/api/azure.messaging.servicebus.servicebusclient) object to create a [ServiceBusSender](/dotnet/api/azure.messaging.servicebus.servicebussender) object for the specific Service Bus queue.
189188
* Creates a [ServiceBusMessageBatch](/dotnet/api/azure.messaging.servicebus.servicebusmessagebatch) object by using the [ServiceBusSender.CreateMessageBatchAsync](/dotnet/api/azure.messaging.servicebus.servicebussender.createmessagebatchasync) method.
190189
* Add messages to the batch using the [ServiceBusMessageBatch.TryAddMessage](/dotnet/api/azure.messaging.servicebus.servicebusmessagebatch.tryaddmessage).
191190
* Sends the batch of messages to the Service Bus queue using the [ServiceBusSender.SendMessagesAsync](/dotnet/api/azure.messaging.servicebus.servicebussender.sendmessagesasync) method.
192191
192+
> [!IMPORTANT]
193+
> Update placeholder values (`<NAMESPACE-CONNECTION-STRING>` and `<QUEUE-NAME>`) in the code snippet with names of your Service Bus namespace and queue.
194+
195+
193196
```csharp
194197
using Azure.Messaging.ServiceBus;
195198
@@ -387,7 +390,7 @@ In this section, you'll add code to retrieve messages from the queue.
387390
* When user presses a key to end the processing, invokes the [StopProcessingAsync](/dotnet/api/azure.messaging.servicebus.servicebusprocessor.stopprocessingasync) on the `ServiceBusProcessor` object.
388391
389392
> [!IMPORTANT]
390-
> Update placeholder values (`<NAMESPACE-NAME>` and `<QUEUE-NAME>`) in the code snippet with actual values you noted down earlier..
393+
> Update placeholder values (`<NAMESPACE-NAME>` and `<QUEUE-NAME>`) in the code snippet with names of your Service Bus namespace and queue.
391394
392395
```csharp
393396
// The Service Bus client types are safe to cache and use as a singleton for the lifetime

articles/service-bus-messaging/service-bus-dotnet-how-to-use-topics-subscriptions.md

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,20 @@ If you're new to the service, see [Service Bus overview](service-bus-messaging-o
4545

4646
---
4747

48+
[!INCLUDE [service-bus-create-topic-subscription-portal](./includes/service-bus-create-topic-subscription-portal.md)]
49+
4850
[!INCLUDE [service-bus-passwordless-template-tabbed](../../includes/passwordless/service-bus/service-bus-passwordless-template-tabbed.md)]
4951

50-
[!INCLUDE [service-bus-create-topic-subscription-portal](./includes/service-bus-create-topic-subscription-portal.md)]
52+
## Launch Visual Studio and sign-in to Azure
53+
54+
You can authorize access to the service bus namespace using the following steps:
55+
56+
1. Select the **Sign in** button in the top right of Visual Studio.
57+
58+
:::image type="content" source="./media/service-bus-dotnet-get-started-with-queues/azure-sign-button-visual-studio.png" alt-text="Screenshot showing the button to sign in to Azure using Visual Studio.":::
59+
2. Sign-in using the Azure AD account you assigned a role to previously.
5160

52-
> [!IMPORTANT]
53-
> Note down the connection string to the namespace, the topic name, and the subscription name. You'll use them later in this tutorial.
61+
:::image type="content" source="..//storage/blobs/media/storage-quickstart-blobs-dotnet/sign-in-visual-studio-account-small.png" alt-text="Screenshot showing the account selection.":::
5462

5563
## Send messages to the topic
5664
This section shows you how to create a .NET console application to send messages to a Service Bus topic.
@@ -60,12 +68,11 @@ This section shows you how to create a .NET console application to send messages
6068
6169
### Create a console application
6270

63-
1. Start Visual Studio 2022.
64-
1. Select **Create a new project**.
71+
1. In Visual Studio, select **File** -> **New** -> **Project** menu.
6572
1. On the **Create a new project** dialog box, do the following steps: If you don't see this dialog box, select **File** on the menu, select **New**, and then select **Project**.
6673
1. Select **C#** for the programming language.
6774
1. Select **Console** for the type of the application.
68-
1. Select **Console Application** from the results list.
75+
1. Select **Console App** from the results list.
6976
1. Then, select **Next**.
7077

7178
:::image type="content" source="./media/service-bus-dotnet-get-started-with-queues/new-send-project.png" alt-text="Image showing the Create a new project dialog box with C# and Console selected":::
@@ -77,14 +84,16 @@ This section shows you how to create a .NET console application to send messages
7784
### [Passwordless](#tab/passwordless)
7885

7986
1. Select **Tools** > **NuGet Package Manager** > **Package Manager Console** from the menu.
80-
1. Run the following command to install the **Azure.Messaging.ServiceBus** and **Azure.Identity** NuGet packages:
87+
1. Run the following command to install the **Azure.Messaging.ServiceBus** NuGet package.
8188

8289
```powershell
8390
Install-Package Azure.Messaging.ServiceBus
84-
Install-Package Azure.Identity
8591
```
92+
1. Run the following command to install the **Azure.Identity** NuGet package.
8693
87-
:::image type="content" source="media/service-bus-dotnet-get-started-with-queues/package-manager-console.png" alt-text="Screenshot showing QueueReceiver project selected in the Package Manager Console.":::
94+
```powershell
95+
Install-Package Azure.Identity
96+
```
8897
8998
### [Connection String](#tab/connection-string)
9099
@@ -94,9 +103,6 @@ This section shows you how to create a .NET console application to send messages
94103
```Powershell
95104
Install-Package Azure.Messaging.ServiceBus
96105
```
97-
98-
:::image type="content" source="media/service-bus-dotnet-get-started-with-queues/package-manager-console.png" alt-text="Screenshot showing QueueReceiver project selected in the Package Manager Console.":::
99-
100106
---
101107
102108
@@ -106,11 +112,14 @@ This section shows you how to create a .NET console application to send messages
106112
107113
## [Passwordless](#tab/passwordless)
108114
109-
1. Creates a [ServiceBusClient](/dotnet/api/azure.messaging.servicebus.servicebusclient) object using the connection string to the namespace.
115+
1. Creates a [ServiceBusClient](/dotnet/api/azure.messaging.servicebus.servicebusclient) object using the `DefaultAzureCredential` object. `DefaultAzureCredential` will automatically discover and use the credentials of your Visual Studio login to authenticate to Azure Service Bus.
110116
1. Invokes the [CreateSender](/dotnet/api/azure.messaging.servicebus.servicebusclient.createsender) method on the `ServiceBusClient` object to create a [ServiceBusSender](/dotnet/api/azure.messaging.servicebus.servicebussender) object for the specific Service Bus topic.
111117
1. Creates a [ServiceBusMessageBatch](/dotnet/api/azure.messaging.servicebus.servicebusmessagebatch) object by using the [ServiceBusSender.CreateMessageBatchAsync](/dotnet/api/azure.messaging.servicebus.servicebussender.createmessagebatchasync).
112118
1. Add messages to the batch using the [ServiceBusMessageBatch.TryAddMessage](/dotnet/api/azure.messaging.servicebus.servicebusmessagebatch.tryaddmessage).
113119
1. Sends the batch of messages to the Service Bus topic using the [ServiceBusSender.SendMessagesAsync](/dotnet/api/azure.messaging.servicebus.servicebussender.sendmessagesasync) method.
120+
121+
> [!IMPORTANT]
122+
> Update placeholder values (`<NAMESPACE-NAME>` and `<TOPIC-NAME>`) in the code snippet with names of your Service Bus namespace and topic.
114123
115124
```csharp
116125
using System.Threading.Tasks;
@@ -242,7 +251,7 @@ This section shows you how to create a .NET console application to send messages
242251
1. On the **Overview** page, in the bottom-middle pane, switch to the **Topics** tab, and select the Service Bus topic. In the following example, it's `mytopic`.
243252
244253
:::image type="content" source="./media/service-bus-dotnet-how-to-use-topics-subscriptions/select-topic.png" alt-text="Select topic":::
245-
1. On the **Service Bus Topic** page, In the **Messages** chart in the bottom **Metrics** section, you can see that there are three incoming messages for the topic. If you don't see the value, wait for a few minutes and refresh the page to see the updated chart.
254+
1. On the **Service Bus Topic** page, In the **Messages** chart in the bottom **Metrics** section, you can see that there are three incoming messages for the topic. If you don't see the value, wait for a few minutes, and refresh the page to see the updated chart.
246255
247256
:::image type="content" source="./media/service-bus-dotnet-how-to-use-topics-subscriptions/sent-messages-essentials.png" alt-text="Messages sent to the topic" lightbox="./media/service-bus-dotnet-how-to-use-topics-subscriptions/sent-messages-essentials.png":::
248257
4. Select the subscription in the bottom pane. In the following example, it's **S1**. On the **Service Bus Subscription** page, you see the **Active message count** as **3**. The subscription has received the three messages that you sent to the topic, but no receiver has picked them yet.
@@ -269,14 +278,17 @@ In this section, you'll create a .NET console application that receives messages
269278
### [Passwordless](#tab/passwordless)
270279
271280
1. Select **Tools** > **NuGet Package Manager** > **Package Manager Console** from the menu.
272-
1. Run the following command to install the **Azure.Messaging.ServiceBus** and **Azure.Identity** NuGet packages:
281+
1. Select **SubscriptionReceiver** for **Default project** drop-down list.
282+
1. Run the following command to install the **Azure.Messaging.ServiceBus** NuGet package.
273283
274284
```powershell
275285
Install-Package Azure.Messaging.ServiceBus
276-
Install-Package Azure.Identity
277286
```
287+
1. Run the following command to install the **Azure.Identity** NuGet package.
278288
279-
:::image type="content" source="media/service-bus-dotnet-get-started-with-queues/package-manager-console.png" alt-text="Screenshot showing QueueReceiver project selected in the Package Manager Console.":::
289+
```powershell
290+
Install-Package Azure.Identity
291+
```
280292
281293
### [Connection String](#tab/connection-string)
282294
@@ -287,8 +299,6 @@ In this section, you'll create a .NET console application that receives messages
287299
Install-Package Azure.Messaging.ServiceBus
288300
```
289301
290-
:::image type="content" source="media/service-bus-dotnet-get-started-with-queues/package-manager-console.png" alt-text="Screenshot showing QueueReceiver project selected in the Package Manager Console.":::
291-
292302
---
293303
294304
### Add code to receive messages from the subscription
@@ -366,12 +376,15 @@ In this section, you'll add code to retrieve messages from the subscription.
366376
367377
## [Passwordless](#tab/passwordless)
368378
369-
* Creates a [ServiceBusClient](/dotnet/api/azure.messaging.servicebus.servicebusclient) object using the passwordless `DefaultAzureCredential` object.
379+
* Creates a [ServiceBusClient](/dotnet/api/azure.messaging.servicebus.servicebusclient) object using the `DefaultAzureCredential` object. `DefaultAzureCredential` will automatically discover and use the credentials of your Visual Studio login to authenticate to Azure Service Bus.
370380
* Invokes the [CreateProcessor](/dotnet/api/azure.messaging.servicebus.servicebusclient.createprocessor) method on the `ServiceBusClient` object to create a [ServiceBusProcessor](/dotnet/api/azure.messaging.servicebus.servicebusprocessor) object for the specified Service Bus topic.
371381
* Specifies handlers for the [ProcessMessageAsync](/dotnet/api/azure.messaging.servicebus.servicebusprocessor.processmessageasync) and [ProcessErrorAsync](/dotnet/api/azure.messaging.servicebus.servicebusprocessor.processerrorasync) events of the `ServiceBusProcessor` object.
372382
* Starts processing messages by invoking the [StartProcessingAsync](/dotnet/api/azure.messaging.servicebus.servicebusprocessor.startprocessingasync) on the `ServiceBusProcessor` object.
373383
* When user presses a key to end the processing, invokes the [StopProcessingAsync](/dotnet/api/azure.messaging.servicebus.servicebusprocessor.stopprocessingasync) on the `ServiceBusProcessor` object.
374384
385+
> [!IMPORTANT]
386+
> Update placeholder values (`<NAMESPACE-NAME>`, `<TOPIC-NAME>`, `<SUBSCRIPTION-NAME>`) in the code snippet with names of your Service Bus namespace, topic, and subscription.
387+
375388
For more information, see code comments.
376389
377390
```csharp

includes/passwordless/service-bus/service-bus-assign-roles.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ If you want to create a custom role, see [Rights required for Service Bus operat
2525

2626
### Create a user in Azure Active Directory
2727

28-
If you are already have an Azure Active Directory (Azure AD) user account, skip this step. If not (for example, if you logged in using a Microsoft account like: `[email protected]`), create a user in Azure AD.
28+
If you already have an Azure Active Directory (Azure AD) user account, skip this step. If not (for example, if you logged in using a Microsoft account like: `[email protected]`), create a user in Azure AD.
2929

3030
1. Sign-in to [Azure portal](https://portal.azure.com) in a new tab or new web browser window.
3131
1. In the search bar at the top, type **Azure Active Directory**, and select **Azure Active Directory** from the results.

0 commit comments

Comments
 (0)