You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can authorize access to the service bus namespace using the following steps:
46
45
47
-
Select the **Sign in** button in the top right of Visual Studio.
48
-
49
-
:::image type="content" source="..//storage/blobs/media/storage-quickstart-blobs-dotnet/sign-in-visual-studio-small.png" alt-text="Screenshot showing the button to sign in to Azure using Visual Studio.":::
46
+
1. Select the **Sign in** button in the top right of Visual Studio.
50
47
51
-
Sign-in using the Azure AD account you assigned a role to previously.
48
+
:::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.":::
49
+
2. Sign-in using the Azure AD account you assigned a role to previously.
52
50
53
-
:::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.":::
51
+
:::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.":::
54
52
55
53
56
54
## Send messages to the queue
@@ -62,12 +60,11 @@ This section shows you how to create a .NET console application to send messages
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**.
68
65
1. Select **C#** for the programming language.
69
66
1. Select **Console** for the type of the application.
70
-
1. Select **Console Application** from the results list.
67
+
1. Select **Console App** from the results list.
71
68
1. Then, select **Next**.
72
69
73
70
:::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":::
@@ -81,10 +78,14 @@ This section shows you how to create a .NET console application to send messages
81
78
### [Passwordless](#tab/passwordless)
82
79
83
80
1. Select **Tools** > **NuGet Package Manager** > **Package Manager Console** from the menu.
84
-
1. Run the following command to install the **Azure.Messaging.ServiceBus**and **Azure.Identity**NuGet packages:
81
+
1. Run the following command to install the **Azure.Messaging.ServiceBus** NuGet package.
85
82
86
83
```powershell
87
84
Install-Package Azure.Messaging.ServiceBus
85
+
```
86
+
1. Run the following command to install the **Azure.Identity** NuGet package.
87
+
88
+
```powershell
88
89
Install-Package Azure.Identity
89
90
```
90
91
@@ -108,9 +109,9 @@ This section shows you how to create a .NET console application to send messages
108
109
### [Passwordless](#tab/passwordless)
109
110
110
111
> [!IMPORTANT]
111
-
> Per the `TODO` comment, update the placeholder values in the code snippets with the values from the Service Bus you created.
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.
112
113
113
-
* Creates a [ServiceBusClient](/dotnet/api/azure.messaging.servicebus.servicebusclient) object using the passwordless `DefaultAzureCredential` object. `DefaultAzureCredential` will automatically discover and use the credentials of your Visual Studio login to authenticate to Azure Service Bus.
114
+
* 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.
114
115
* 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.
115
116
* Creates a [ServiceBusMessageBatch](/dotnet/api/azure.messaging.servicebus.servicebusmessagebatch) object by using the [ServiceBusSender.CreateMessageBatchAsync](/dotnet/api/azure.messaging.servicebus.servicebussender.createmessagebatchasync) method.
116
117
* Add messages to the batch using the [ServiceBusMessageBatch.TryAddMessage](/dotnet/api/azure.messaging.servicebus.servicebusmessagebatch.tryaddmessage).
@@ -290,14 +291,19 @@ In this section, you'll create a .NET console application that receives messages
290
291
### [Passwordless](#tab/passwordless)
291
292
292
293
1. Select **Tools** > **NuGet Package Manager** > **Package Manager Console** from the menu.
293
-
1. Run the following command to install the **Azure.Messaging.ServiceBus** and **Azure.Identity** NuGet packages:
294
+
1. Select **QueueReceiver** for **Default project**.
295
+
296
+
:::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.":::
297
+
1. Run the following command to install the **Azure.Messaging.ServiceBus** NuGet package.
294
298
295
299
```powershell
296
300
Install-Package Azure.Messaging.ServiceBus
297
-
Install-Package Azure.Identity
298
301
```
302
+
1. Run the following command to install the **Azure.Identity** NuGet package.
299
303
300
-
:::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.":::
304
+
```powershell
305
+
Install-Package Azure.Identity
306
+
```
301
307
302
308
### [Connection String](#tab/connection-string)
303
309
@@ -380,6 +386,8 @@ In this section, you'll add code to retrieve messages from the queue.
380
386
* Starts processing messages by invoking the [StartProcessingAsync](/dotnet/api/azure.messaging.servicebus.servicebusprocessor.startprocessingasync) on the `ServiceBusProcessor` object.
381
387
* When user presses a key to end the processing, invokes the [StopProcessingAsync](/dotnet/api/azure.messaging.servicebus.servicebusprocessor.stopprocessingasync) on the `ServiceBusProcessor` object.
382
388
389
+
> [!IMPORTANT]
390
+
> Update placeholder values (`<NAMESPACE-NAME>` and `<QUEUE-NAME>`) in the code snippet with actual values you noted down earlier..
383
391
384
392
```csharp
385
393
// The Service Bus client types are safe to cache and use as a singleton for the lifetime
Copy file name to clipboardExpand all lines: includes/passwordless/service-bus/service-bus-assign-roles.md
+23-11Lines changed: 23 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,30 +17,42 @@ The following example assigns the `Azure Service Bus Data Owner` role to your us
17
17
### Azure built-in roles for Azure Service Bus
18
18
For Azure Service Bus, the management of namespaces and all related resources through the Azure portal and the Azure resource management API is already protected using the Azure RBAC model. Azure provides the below Azure built-in roles for authorizing access to a Service Bus namespace:
19
19
20
-
-[Azure Service Bus Data Owner](../../../articles/role-based-access-control/built-in-roles.md#azure-service-bus-data-owner): Enables data access to Service Bus namespace and its entities (queues, topics, subscriptions, and filters)
20
+
-[Azure Service Bus Data Owner](../../../articles/role-based-access-control/built-in-roles.md#azure-service-bus-data-owner): Enables data access to Service Bus namespace and its entities (queues, topics, subscriptions, and filters). A member of this role can send and receive messages from queues or topics/subscriptions.
21
21
-[Azure Service Bus Data Sender](../../../articles/role-based-access-control/built-in-roles.md#azure-service-bus-data-sender): Use this role to give the send access to Service Bus namespace and its entities.
22
22
-[Azure Service Bus Data Receiver](../../../articles/role-based-access-control/built-in-roles.md#azure-service-bus-data-receiver): Use this role to give the receive access to Service Bus namespace and its entities.
23
23
24
24
If you want to create a custom role, see [Rights required for Service Bus operations](../../../articles/service-bus-messaging/service-bus-sas.md#rights-required-for-service-bus-operations).
25
25
26
+
### Create a user in Azure Active Directory
27
+
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.
29
+
30
+
1. Sign-in to [Azure portal](https://portal.azure.com) in a new tab or new web browser window.
31
+
1. In the search bar at the top, type **Azure Active Directory**, and select **Azure Active Directory** from the results.
32
+
1. On the Azure Active Directory page, select **Users** under **Manage** on the left navigational menu.
33
+
1. On the **Users** page, select **+ New user** on the command bar, and then select **Create new user**.
34
+
1. On the **New user** page, follow these steps:
35
+
1. For **User name**, enter a name for the user. For example: **john.doe**.
36
+
1. For **Name**, specify the full name. For example: **John Doe**.
37
+
1. Select **Create** to create the user in Azure AD.
38
+
39
+
### Add Azure AD user to Azure Service Bus Owner role
40
+
41
+
Add your Azure AD user name or the one you created in the previous step to the **Azure Service Bus Data Owner** role at the Service Bus namespace level. It will allow an app running in the context of this user account to send messages to a queue or a topic, and receive messages from a queue or a topic's subscription.
42
+
26
43
> [!IMPORTANT]
27
44
> In most cases, it will take a minute or two for the role assignment to propagate in Azure. In rare cases, it may take up to eight minutes. If you receive authentication errors when you first run your code, wait a few moments and try again.
28
45
29
-
1. In the Azure portal, locate your service bus namespace using the main search bar or left navigation.
30
-
46
+
1. If you don't have the Service Bus Namespace page open in the Azure portal, locate your Service Bus namespace using the main search bar or left navigation.
31
47
2. On the overview page, select **Access control (IAM)** from the left-hand menu.
32
-
33
48
3. On the **Access control (IAM)** page, select the **Role assignments** tab.
34
-
35
49
4. Select **+ Add** from the top menu and then **Add role assignment** from the resulting drop-down menu.
36
50
37
51
:::image type="content" source="media/service-bus-assign-roles/add-role.png" alt-text="A screenshot showing how to assign a role.":::
38
-
39
52
5. Use the search box to filter the results to the desired role. For this example, search for `Azure Service Bus Data Owner` and select the matching result. Then choose **Next**.
53
+
1. Under **Assign access to**, select **User, group, or service principal**, and then choose **+ Select members**.
40
54
41
-
6. Under **Assign access to**, select **User, group, or service principal**, and then choose **+ Select members**.
42
-
43
-
7. In the dialog, search for your Azure AD username (usually your *user@domain* email address) and then choose **Select** at the bottom of the dialog.
44
-
45
-
8. Select **Review + assign** to go to the final page, and then **Review + assign** again to complete the process.
55
+
56
+
1. In the dialog, search for your Azure AD username (usually your *user@domain* email address) and then choose **Select** at the bottom of the dialog.
57
+
1. Select **Review + assign** to go to the final page, and then **Review + assign** again to complete the process.
0 commit comments