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
Copy file name to clipboardExpand all lines: articles/service-bus-messaging/service-bus-managed-service-identity.md
+10-14Lines changed: 10 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,14 +12,10 @@ ms.date: 02/11/2025
12
12
13
13
Managed identities for Azure resources provide Azure services with an automatically managed identity in Microsoft Entra ID. You can use this identity to authenticate to Azure Service Bus without storing credentials in your code.
14
14
15
-
This article shows you how to:
15
+
This article walks you through enabling a managed identity, assigning the appropriate Service Bus role, and connecting to Service Bus from your application code.
16
16
17
-
> [!div class="checklist"]
18
-
> - Enable a managed identity for your Azure compute resource
19
-
> - Assign Service Bus roles to the managed identity
20
-
> - Connect to Service Bus from your application using the managed identity
21
-
22
-
If you're not familiar with managed identities, see [Managed identities for Azure resources](../active-directory/managed-identities-azure-resources/overview.md).
17
+
> [!NOTE]
18
+
> If you're not familiar with managed identities, see [Managed identities for Azure resources](../active-directory/managed-identities-azure-resources/overview.md).
23
19
24
20
## Prerequisites
25
21
@@ -33,7 +29,7 @@ To use managed identities with Azure Service Bus, you need:
33
29
34
30
> [!IMPORTANT]
35
31
> You can disable local or SAS key authentication for a Service Bus namespace and allow only Microsoft Entra authentication. For step-by-step instructions, see [Disable local authentication](disable-local-authentication.md).
36
-
32
+
37
33
## Assign a Service Bus role to the managed identity
38
34
39
35
Microsoft Entra authorizes access to secured resources through [Azure role-based access control (RBAC)](../role-based-access-control/overview.md). Azure Service Bus provides Azure built-in roles that encompass common sets of permissions used to access Service Bus entities. You can also define custom roles.
@@ -58,7 +54,7 @@ To assign a role to a managed identity in the Azure portal:
58
54
1. Select the managed identity for your Azure resource.
59
55
1. Select **Review + assign**.
60
56
61
-
For more information, see [Assign Azure roles using the Azure portal](/azure/role-based-access-control/role-assignments-portal).
57
+
For more information, see [Assign Azure roles using the Azure portal](../role-based-access-control/role-assignments-portal.md).
62
58
63
59
### Choose the resource scope
64
60
@@ -88,9 +84,9 @@ az role assignment create \
88
84
For more information about how built-in roles are defined, see [Understand role definitions](../role-based-access-control/role-definitions.md#control-and-data-actions). For information about creating Azure custom roles, see [Azure custom roles](../role-based-access-control/custom-roles.md).
89
85
90
86
> [!NOTE]
91
-
> If the source service or app doesn't restart after the access to a Service Bus entity is disabled by removing the source's managed identity from the Service Bus RBAC role, the source app might continue to send/receive messages to/from the Service Bus entity until the token expires (default token validity is 24 hours). This behavior is by design.
87
+
> If the source service or app doesn't restart after you remove its managed identity from the Service Bus RBAC role, the source app might continue to send or receive messages to or from the Service Bus entity until the token expires (default token validity is 24 hours). This behavior is by design.
92
88
>
93
-
> Therefore, after you remove the source's managed identity from the RBAC role, restart the source app or service to immediately expire the token and prevent it from sending messages to or receiving messages from the Service Bus entity.
89
+
> After you remove the source's managed identity from the RBAC role, restart the source app or service to immediately expire the token and prevent it from sending or receiving messages from the Service Bus entity.
94
90
95
91
## Connect to Service Bus using managed identity in Azure SDKs
96
92
@@ -104,19 +100,19 @@ var client = new ServiceBusClient("contoso.servicebus.windows.net", new DefaultA
104
100
105
101
You send and receive messages as usual using [ServiceBusSender](/dotnet/api/azure.messaging.servicebus.servicebussender) and [ServiceBusReceiver](/dotnet/api/azure.messaging.servicebus.servicebusreceiver) or [ServiceBusProcessor](/dotnet/api/azure.messaging.servicebus.servicebusprocessor).
106
102
107
-
For complete step-by-step instructions to send and receive messages using a managed identity, see the following quickstarts. These quickstarts have the code to use a service principal to send and receive messages, but the code is the same for using a managed identity.
103
+
For step-by-step instructions to send and receive messages using a managed identity, see the following quickstarts. These quickstarts have the code to use a service principal to send and receive messages, but the code is the same for using a managed identity.
> The managed identity works only inside the Azure environment, on App services, Azure VMs, and scale sets. For .NET applications, the Microsoft.Azure.Services.AppAuthentication library, which is used by the Service Bus NuGet package, provides an abstraction over this protocol and supports a local development experience. This library also allows you to test your code locally on your development machine, using your user account from Visual Studio, Azure CLI 2.0, or Active Directory Integrated Authentication. For more on local development options with this library, see [Service-to-service authentication to Azure Key Vault using .NET](/dotnet/api/overview/azure/service-to-service-authentication).
111
+
> Managed identities work only inside the Azure environment, on App Service, Azure VMs, and scale sets. For .NET applications, the Microsoft.Azure.Services.AppAuthentication library, which the Service Bus NuGet package uses, provides an abstraction over this protocol and supports a local development experience. This library also lets you test your code locally on your development machine, using your user account from Visual Studio, Azure CLI, or Microsoft Entra Integrated Authentication. For more on local development options with this library, see [Service-to-service authentication to Azure Key Vault using .NET](/dotnet/api/overview/azure/service-to-service-authentication).
116
112
117
113
118
114
## Next steps
119
115
120
116
-[Sample: .NET web application using managed identity with Service Bus](https://github.com/Azure-Samples/app-service-msi-servicebus-dotnet/tree/master)
121
117
-[What are managed identities for Azure resources?](../active-directory/managed-identities-azure-resources/overview.md)
122
-
-[Disable local authentication for Service Bus](disable-local-authentication.md)
118
+
-[Disable local authentication for Service Bus](disable-local-authentication.md)
0 commit comments