Skip to content

Commit 0fd4c27

Browse files
authored
Merge pull request #213073 from alexwolfmsft/passwordless-service-bus-queues
Passwordless service bus queues
2 parents ecfba92 + 3c7ea20 commit 0fd4c27

14 files changed

+1122
-616
lines changed

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

Lines changed: 455 additions & 308 deletions
Large diffs are not rendered by default.

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

Lines changed: 415 additions & 280 deletions
Large diffs are not rendered by default.

articles/storage/common/migrate-azure-credentials.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ The following steps explain how to migrate an existing application to use passwo
6767

6868
For local development, make sure you're authenticated with the same Azure AD account you assigned the role to on your Blob Storage account. You can authenticate via the Azure CLI, Visual Studio, Azure PowerShell, or other tools such as IntelliJ.
6969

70-
[!INCLUDE [default-azure-credential-sign-in](../../../includes/default-azure-credential-sign-in.md)]
70+
[!INCLUDE [default-azure-credential-sign-in](../../../includes/passwordless/default-azure-credential-sign-in.md)]
7171

7272
Next you will need to update your code to use passwordless connections.
7373

@@ -106,7 +106,7 @@ Once your application is configured to use passwordless connections and runs loc
106106

107107
#### Create the managed identity using the Azure portal
108108

109-
The following steps demonstrate how to create a system-assigned managed identity for various web hosting services. The managed identity can securely connect to other Azure Services using the app configurations you setup previously.
109+
The following steps demonstrate how to create a system-assigned managed identity for various web hosting services. The managed identity can securely connect to other Azure Services using the app configurations you set up previously.
110110

111111
### [Service Connector](#tab/service-connector)
112112

@@ -240,7 +240,7 @@ az spring app identity assign \
240240

241241
### [Azure Container Apps](#tab/container-apps-identity)
242242

243-
You can assign a managed identity to an Azure Container Apps instance with the [az containerapp identity assign](/cli/azure/containerapp/identity) command.
243+
You can assign a managed identity to an Azure Container Apps instance with the [az container app identity assign](/cli/azure/containerapp/identity) command.
244244

245245
```azurecli
246246
az containerapp identity assign \

includes/default-azure-credential-sign-in.md renamed to includes/passwordless/default-azure-credential-sign-in.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ ms.author: alexwolf
1010
ms.custom: include file
1111
---
1212

13+
Make sure you're authenticated with the same Azure AD account you assigned the role to. You can authenticate via the Azure CLI, Visual Studio, or Azure PowerShell.
14+
1315
### [Azure CLI](#tab/sign-in-azure-cli)
1416

1517
Sign-in to Azure through the Azure CLI using the following command:
@@ -22,11 +24,11 @@ az login
2224

2325
Select the **Sign in** button in the top right of Visual Studio.
2426

25-
:::image type="content" source="../articles/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.":::
27+
:::image type="content" source="../../articles/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.":::
2628

2729
Sign-in using the Azure AD account you assigned a role to previously.
2830

29-
:::image type="content" source="../articles/storage/blobs/media/storage-quickstart-blobs-dotnet/sign-in-visual-studio-account-small.png" alt-text="Screenshot showing the account selection.":::
31+
:::image type="content" source="../../articles/storage/blobs/media/storage-quickstart-blobs-dotnet/sign-in-visual-studio-account-small.png" alt-text="Screenshot showing the account selection.":::
3032

3133
### [Visual Studio Code](#tab/sign-in-visual-studio-code)
3234

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: "include file"
3+
description: "include file"
4+
services: storage
5+
author: alexwolfmsft
6+
ms.service: storage
7+
ms.topic: include
8+
ms.date: 10/21/2022
9+
ms.author: alexwolf
10+
ms.custom: include file
11+
---
12+
13+
`DefaultAzureCredential` is a class provided by the Azure Identity client library for .NET. To learn more about `DefaultAzureCredential`, see the [DefaultAzureCredential overview](/dotnet/azure/sdk/authentication#defaultazurecredential). `DefaultAzureCredential` supports multiple authentication methods and determines which method should be used at runtime. This approach enables your app to use different authentication methods in different environments (local vs. production) without implementing environment-specific code.
14+
15+
For example, your app can authenticate using your Visual Studio sign-in credentials when developing locally, and then use a [managed identity](/azure/active-directory/managed-identities-azure-resources/overview) once it has been deployed to Azure. No code changes are required for this transition.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: "include file"
3+
description: "include file"
4+
services: storage
5+
author: alexwolfmsft
6+
ms.service: storage
7+
ms.topic: include
8+
ms.date: 09/09/2022
9+
ms.author: alexwolf
10+
ms.custom: include file
11+
---
12+
13+
Application requests to most Azure Services must be authorized. Using the `DefaultAzureCredential` class provided by the Azure Identity client library is the recommended approach for implementing passwordless connections to Azure services in your code.
14+
15+
You can also authorize requests to Azure services using passwords, connection strings, or other credentials directly. However, this approach should be used with caution. Developers must be diligent to never expose these secrets in an unsecure location. Anyone who gains access to the password or secret key is able to authenticate. `DefaultAzureCredential` offers improved management and security benefits over the account key to allow passwordless authentication. Both options are demonstrated in the following example.
73 KB
Loading
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
title: "include file"
3+
description: "include file"
4+
services: storage
5+
author: alexwolfmsft
6+
ms.service: storage
7+
ms.topic: include
8+
ms.date: 09/09/2022
9+
ms.author: alexwolf
10+
ms.custom: include file
11+
---
12+
13+
When developing locally, make sure that the user account that connects to Azure Service Bus has the correct permissions. You'll need the `Azure Service Bus Data Owner` role in order to send and receive messages. To assign yourself this role, you'll need the User Access Administrator role, or another role that includes the `Microsoft.Authorization/roleAssignments/write` action. You can assign Azure RBAC roles to a user using the Azure portal, Azure CLI, or Azure PowerShell. Learn more about the available scopes for role assignments on the [scope overview](/azure/role-based-access-control/scope-overview) page.
14+
15+
The following example assigns the `Azure Service Bus Data Owner` role to your user account, which provides full access to Azure Service Bus resources. In a real scenario, follow the [Principle of Least Privilege](/azure/active-directory/develop/secure-least-privileged-access) to give users only the minimum permissions needed for a more secure production environment.
16+
17+
> [!IMPORTANT]
18+
> 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.
19+
20+
### [Azure portal](#tab/roles-azure-portal)
21+
22+
1. In the Azure portal, locate your service bus namespace using the main search bar or left navigation.
23+
24+
2. On the overview page, select **Access control (IAM)** from the left-hand menu.
25+
26+
3. On the **Access control (IAM)** page, select the **Role assignments** tab.
27+
28+
4. Select **+ Add** from the top menu and then **Add role assignment** from the resulting drop-down menu.
29+
30+
:::image type="content" source="media/add-role.png" alt-text="A screenshot showing how to assign a role.":::
31+
32+
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**.
33+
34+
6. Under **Assign access to**, select **User, group, or service principal**, and then choose **+ Select members**.
35+
36+
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.
37+
38+
8. Select **Review + assign** to go to the final page, and then **Review + assign** again to complete the process.
39+
40+
### [Azure CLI](#tab/roles-azure-cli)
41+
42+
To assign a role at the resource level using the Azure CLI, you first must retrieve the resource ID using the `az servicebus namespace show` command. You can filter the output properties using the `--query` parameter.
43+
44+
```azurecli
45+
az servicebus namespace show -g '<your-service-bus-resource-group>' -n '<your-service-bus-name> --query id
46+
```
47+
48+
Copy the output `Id` from the preceding command. You can then assign roles using the [az role](/cli/azure/role) command of the Azure CLI.
49+
50+
```azurecli
51+
az role assignment create --assignee "<user@domain>" \
52+
--role "Azure Service Bus Data Owner" \
53+
--scope "<your-resource-id>"
54+
```
55+
56+
### [PowerShell](#tab/roles-powershell)
57+
58+
To assign a role at the resource level using Azure PowerShell, you first must retrieve the resource ID using the `Get-AzResource` command.
59+
60+
```azurepowershell
61+
Get-AzResource -ResourceGroupName "<your-service-bus-resource-group>" -Name "<your-service-bus-name>"
62+
```
63+
64+
Copy the `Id` value from the preceding command output. You can then assign roles using the [New-AzRoleAssignment](/powershell/module/az.resources/new-azroleassignment) command in PowerShell.
65+
66+
```azurepowershell
67+
New-AzRoleAssignment -SignInName <user@domain> `
68+
-RoleDefinitionName "Azure Service Bus Data Owner" `
69+
-Scope <yourStorageAccountId>
70+
```
71+
72+
---
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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: 04/26/2022
9+
ms.author: spelluru
10+
ms.custom: include file
11+
---
12+
13+
## Create a namespace in the Azure portal
14+
To begin using Service Bus messaging entities in Azure, you must first create a namespace with a name that is unique across Azure. A namespace provides a scoping container for Service Bus resources within your application.
15+
16+
To create a namespace:
17+
18+
1. Sign in to the [Azure portal](https://portal.azure.com)
19+
2. In the left navigation pane of the portal, select **+ Create a resource**, select **Integration**, and then select **Service Bus**.
20+
21+
:::image type="content" source="../../../articles/service-bus-messaging/includes/media/service-bus-create-namespace-portal/create-resource-service-bus-menu.png" alt-text="Image showing selection of Create a resource, Integration, and then Service Bus in the menu.":::
22+
3. In the **Basics** tag of the **Create namespace** page, follow these steps:
23+
1. For **Subscription**, choose an Azure subscription in which to create the namespace.
24+
1. For **Resource group**, choose an existing resource group in which the namespace will live, or create a new one.
25+
1. Enter a **name for the namespace**. The namespace name should adhere to the following naming conventions:
26+
- The name must be unique across Azure. The system immediately checks to see if the name is available.
27+
- The name length is at least 6 and at most 50 characters.
28+
- The name can contain only letters, numbers, and hyphens ("-").
29+
- The name must start with a letter and end with a letter or number.
30+
- The name doesn't end with "-sb" or "-mgmt".
31+
1. For **Location**, choose the region in which your namespace should be hosted.
32+
1. For **Pricing tier**, select the pricing tier (Basic, Standard, or Premium) for the namespace. For this quickstart, select **Standard**.
33+
34+
> [!IMPORTANT]
35+
> If you want to use [Topics and subscriptions](../../../articles/service-bus-messaging/service-bus-queues-topics-subscriptions.md#topics-and-subscriptions), choose either Standard or Premium. Topics/subscriptions aren't supported in the Basic pricing tier.
36+
37+
If you selected the **Premium** pricing tier, specify the number of **messaging units**. The premium tier provides resource isolation at the CPU and memory level so that each workload runs in isolation. This resource container is called a messaging unit. A premium namespace has at least one messaging unit. You can select 1, 2, 4, 8 or 16 messaging units for each Service Bus Premium namespace. For more information, see [Service Bus Premium Messaging](../../../articles/service-bus-messaging/service-bus-premium-messaging.md).
38+
39+
1. Select **Review + create**. The system now creates your namespace and enables it. You might have to wait several minutes as the system provisions resources for your account.
40+
41+
:::image type="content" source="../../../articles/service-bus-messaging/includes/media/service-bus-create-namespace-portal/create-namespace.png" alt-text="Image showing the Create a namespace page.":::
42+
1. On the **Create** page, review settings, and select **Create**.
43+
4. Select **Go to resource** on the deployment page.
44+
45+
:::image type="content" source="../../../articles/service-bus-messaging/includes/media/service-bus-create-namespace-portal/deployment-alert.png" alt-text="Image showing the deployment succeeded page with the Go to resource link.":::
46+
5. You see the home page for your service bus namespace.
47+
48+
:::image type="content" source="../../../articles/service-bus-messaging/includes/media/service-bus-create-namespace-portal/service-bus-namespace-home-page.png" alt-text="Image showing the home page of the Service Bus namespace created." :::
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
title: "include file"
3+
description: "include file"
4+
services: storage
5+
author: alexwolfmsft
6+
ms.service: storage
7+
ms.topic: include
8+
ms.date: 09/09/2022
9+
ms.author: alexwolf
10+
ms.custom: include file
11+
---
12+
13+
## Authenticate the app to Azure
14+
15+
[!INCLUDE [passwordless-overview](../passwordless-overview.md)]
16+
17+
## [Passwordless (Recommended)](#tab/passwordless)
18+
19+
[!INCLUDE [passwordless-default-azure-credential-overview](../dotnet-default-azure-credential-overview.md)]
20+
21+
### Assign roles to your Azure AD user
22+
23+
[!INCLUDE [service-bus-assign-roles](service-bus-assign-roles.md)]
24+
25+
### Sign in and add the Azure Identity package
26+
27+
You can authorize access to the service bus namespace using the following steps:
28+
29+
[!INCLUDE [default-azure-credential-sign-in](../default-azure-credential-sign-in.md)]
30+
31+
[!INCLUDE [visual-studio-add-identity](../visual-studio-add-identity.md)]
32+
33+
## [Connection String](#tab/connection-string)
34+
35+
[!INCLUDE [service-bus-retrieve-connection-string](service-bus-retrieve-connection-string.md)]
36+
37+
---

0 commit comments

Comments
 (0)