Skip to content

Commit 336a067

Browse files
committed
Service Bus - Authenticate from app - review & refresh
1 parent 89656ea commit 336a067

File tree

5 files changed

+28
-28
lines changed

5 files changed

+28
-28
lines changed

articles/service-bus-messaging/authenticate-application.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
title: Authenticate an application to access Azure Service Bus entities
33
description: This article provides information about authenticating an application with Azure Active Directory to access Azure Service Bus entities (queues, topics, etc.)
44
ms.topic: conceptual
5-
ms.date: 01/06/2022
5+
ms.date: 02/24/2023
66
ms.custom: subject-rbac-steps
77
---
88

99
# Authenticate and authorize an application with Azure Active Directory to access Azure Service Bus entities
10-
Azure Service Bus supports using Azure Active Directory (Azure AD) to authorize requests to Service Bus entities (queues, topics, subscriptions, or filters). With Azure AD, you can use Azure role-based access control (Azure RBAC) to grant permissions to a security principal, which may be a user, group, or application service principal. To learn more about roles and role assignments, see [Understanding the different roles](../role-based-access-control/overview.md).
10+
Azure Service Bus supports using Azure Active Directory (Azure AD) to authorize requests to Service Bus entities (queues, topics, subscriptions, or filters). With Azure AD, you can use Azure role-based access control (Azure RBAC) to grant permissions to a security principal, which may be a user, group, or application service principal. A key advantage of using Azure AD with Azure Service Bus is that you don't need to store your credentials in the code anymore. Instead, you can request an OAuth 2.0 access token from the Microsoft Identity platform. If the authentication succeeds, Azure AD returns an access token to the application, and the application can then use the access token to authorize request to Service Bus resources.
1111

1212
> [!IMPORTANT]
1313
> You can disable local or SAS key authentication for a Service Bus namespace and allow only Azure Active Directory authentication. For step-by-step instructions, see [Disable local authentication](disable-local-authentication.md).
@@ -18,26 +18,26 @@ When a security principal (a user, group, or application) attempts to access a S
1818
1. First, the security principal’s identity is authenticated, and an OAuth 2.0 token is returned. The resource name to request a token is `https://servicebus.azure.net`.
1919
1. Next, the token is passed as part of a request to the Service Bus service to authorize access to the specified resource.
2020

21-
The authentication step requires that an application request contains an OAuth 2.0 access token at runtime. If an application is running within an Azure entity such as an Azure VM, a virtual machine scale set, or an Azure Function app, it can use a managed identity to access the resources. To learn how to authenticate requests made by a managed identity to Service Bus service, see [Authenticate access to Azure Service Bus resources with Azure Active Directory and managed identities for Azure Resources](service-bus-managed-service-identity.md).
21+
The authentication step requires that an application request contains an OAuth 2.0 access token at runtime. If an application is running within an Azure entity such as an Azure VM, a Virtual Machine Scale Set, or an Azure Function app, it can use a managed identity to access the resources. To learn how to authenticate requests made by a managed identity to the Service Bus service, see [Authenticate access to Azure Service Bus resources with Azure Active Directory and managed identities for Azure Resources](service-bus-managed-service-identity.md).
2222

23-
The authorization step requires that one or more Azure roles be assigned to the security principal. Azure Service Bus provides Azure roles that encompass sets of permissions for Service Bus resources. The roles that are assigned to a security principal determine the permissions that the principal will have. To learn more about assigning Azure roles to Azure Service Bus, see [Azure built-in roles for Azure Service Bus](#azure-built-in-roles-for-azure-service-bus).
23+
The authorization step requires that one or more Azure roles be assigned to the security principal. Azure Service Bus provides Azure roles that encompass sets of permissions for Service Bus resources. The roles that are assigned to a security principal determine the permissions that the principal will have on Service Bus resources. To learn more about assigning Azure roles to Azure Service Bus, see [Azure built-in roles for Azure Service Bus](#azure-built-in-roles-for-azure-service-bus).
2424

2525
Native applications and web applications that make requests to Service Bus can also authorize with Azure AD. This article shows you how to request an access token and use it to authorize requests for Service Bus resources.
2626

2727

28-
## Assigning Azure roles for access rights
28+
## Built-in roles for Azure Service Bus
29+
2930
Azure Active Directory (Azure AD) authorizes access rights to secured resources through [Azure RBAC](../role-based-access-control/overview.md). Azure Service Bus defines a set of Azure built-in roles that encompass common sets of permissions used to access Service Bus entities and you can also define custom roles for accessing the data.
3031

3132
When an Azure role is assigned to an Azure AD security principal, Azure grants access to those resources for that security principal. Access can be scoped to the level of subscription, the resource group, or the Service Bus namespace. An Azure AD security principal may be a user, a group, an application service principal, or a [managed identity for Azure resources](../active-directory/managed-identities-azure-resources/overview.md).
3233

33-
## Azure built-in roles for Azure Service Bus
34-
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:
34+
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 following built-in roles for authorizing access to a Service Bus namespace:
3535

3636
- [Azure Service Bus Data Owner](../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)
37-
- [Azure Service Bus Data Sender](../role-based-access-control/built-in-roles.md#azure-service-bus-data-sender): Use this role to give send access to Service Bus namespace and its entities.
37+
- [Azure Service Bus Data Sender](../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.
3838
- [Azure Service Bus Data Receiver](../role-based-access-control/built-in-roles.md#azure-service-bus-data-receiver): Use this role to give receiving access to Service Bus namespace and its entities.
3939

40-
## Resource scope
40+
### Resource scope
4141
Before you assign an Azure role to a security principal, determine the scope of access that the security principal should have. Best practices dictate that it's always best to grant only the narrowest possible scope.
4242

4343
The following list describes the levels at which you can scope access to Service Bus resources, starting with the narrowest scope:
@@ -53,11 +53,6 @@ The following list describes the levels at which you can scope access to Service
5353
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).
5454

5555

56-
## Assign Azure roles using the Azure portal
57-
Assign one of the [Service Bus roles](#azure-built-in-roles-for-azure-service-bus) to the application's service principal at the desired scope (Service Bus namespace, resource group, subscription). For detailed steps, see [Assign Azure roles using the Azure portal](../role-based-access-control/role-assignments-portal.md).
58-
59-
Once you define the role and its scope, you can test this behavior with the [samples on GitHub](https://github.com/Azure/azure-service-bus/tree/master/samples/DotNet/Microsoft.ServiceBus.Messaging/RoleBasedAccessControl).
60-
6156
## Authenticate from an application
6257
A key advantage of using Azure AD with Service Bus is that your credentials no longer need to be stored in your code. Instead, you can request an OAuth 2.0 access token from Microsoft identity platform. Azure AD authenticates the security principal (a user, a group, or service principal) running the application. If authentication succeeds, Azure AD returns the access token to the application, and the application can then use the access token to authorize requests to Azure Service Bus.
6358

@@ -68,21 +63,20 @@ For an overview of the OAuth 2.0 code grant flow, see [Authorize access to Azure
6863
### Register your application with an Azure AD tenant
6964
The first step in using Azure AD to authorize Service Bus entities is registering your client application with an Azure AD tenant from the [Azure portal](https://portal.azure.com/). When you register your client application, you supply information about the application to AD. Azure AD then provides a client ID (also called an application ID) that you can use to associate your application with Azure AD runtime. To learn more about the client ID, see [Application and service principal objects in Azure Active Directory](../active-directory/develop/app-objects-and-service-principals.md).
7065

71-
The following images show steps for registering a web application:
72-
73-
![Register an application](./media/authenticate-application/app-registrations-register.png)
66+
Follow steps in the [Quickstart: Register an application with the Microsoft identity platform](../active-directory/develop/quickstart-register-app.md) to register your application with Azure AD.
7467

7568
> [!Note]
7669
> If you register your application as a native application, you can specify any valid URI for the Redirect URI. For native applications, this value does not have to be a real URL. For web applications, the redirect URI must be a valid URI, because it specifies the URL to which tokens are provided.
7770
78-
After you've registered your application, you'll see the **Application (client) ID** under **Settings**:
71+
After you've registered your application, you'll see the **Application (client) ID** and **Directory (tenant) ID** under **Settings**:
72+
73+
> [!IMPORTANT]
74+
> Make note of the **TenantId** and the **ApplicationId**. You will need these values to run the application.
7975
80-
![Application ID of the registered application](./media/authenticate-application/application-id.png)
76+
:::image type="content" source="./media/authenticate-application/application-id.png" alt-text="Screenshot showing the App registration page showing the Application ID and Tenant ID.":::
8177

8278
For more information about registering an application with Azure AD, see [Integrating applications with Azure Active Directory](../active-directory/develop/quickstart-register-app.md).
8379

84-
> [!IMPORTANT]
85-
> Make note of the **TenantId** and the **ApplicationId**. You will need these values to run the application.
8680

8781
### Create a client secret
8882
The application needs a client secret to prove its identity when requesting a token. To add the client secret, follow these steps.
@@ -91,21 +85,27 @@ The application needs a client secret to prove its identity when requesting a to
9185
1. Select **Certificates & secrets** on the left menu.
9286
1. Under **Client secrets**, select **New client secret** to create a new secret.
9387

94-
![New client secret - button](./media/authenticate-application/new-client-secret-button.png)
88+
:::image type="content" source="./media/authenticate-application/new-client-secret-button.png" alt-text="Screenshot showing the Certificates and secrets page with New client secret button selected.":::
9589
1. Provide a description for the secret, and choose the wanted expiration interval, and then select **Add**.
9690

97-
![Add client secret page](./media/authenticate-application/add-client-secret-page.png)
91+
:::image type="content" source="./media/authenticate-application/add-client-secret-page.png" alt-text="Screenshot showing the Add a client secret page.":::
9892
1. Immediately copy the value of the new secret to a secure location. The fill value is displayed to you only once.
9993

100-
![Client secret](./media/authenticate-application/client-secret.png)
94+
:::image type="content" source="./media/authenticate-application/client-secret.png" alt-text="Screenshot showing the Client secrets section with the secret you added.":::
10195

10296
### Permissions for the Service Bus API
103-
If your application is a console application, you must register a native application and add API permissions for **Microsoft.ServiceBus** to the **required permissions** set. Native applications also need a **redirect-uri** in Azure AD, which serves as an identifier; the URI does not need to be a network destination. Use `https://servicebus.microsoft.com` for this example, because the sample code already uses that URI.
97+
If your application is a console application, you must register a native application and add API permissions for **Microsoft.ServiceBus** to the **required permissions** set. Native applications also need a **redirect-uri** in Azure AD, which serves as an identifier; the URI doesn't need to be a network destination. Use `https://servicebus.microsoft.com` for this example, because the sample code already uses that URI.
98+
99+
## Assign Azure roles using the Azure portal
100+
Assign one of the [Service Bus roles](#azure-built-in-roles-for-azure-service-bus) to the application's service principal at the desired scope (Service Bus namespace, resource group, subscription). For detailed steps, see [Assign Azure roles using the Azure portal](../role-based-access-control/role-assignments-portal.md).
101+
102+
Once you define the role and its scope, you can test this behavior with the [sample on GitHub](https://github.com/Azure/azure-service-bus/tree/master/samples/DotNet/Microsoft.ServiceBus.Messaging/RoleBasedAccessControl). This sample uses the old Microsoft.Azure.ServiceBus package. For information about migrating this sample to use the newer Azure.Messaging.ServiceBus package, see the [Guide for migrating to Azure.Messaging.ServiceBus from Microsoft.Azure.ServiceBus](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/servicebus/Azure.Messaging.ServiceBus/MigrationGuide.md).
103+
104104

105105
### Authenticating the Service Bus client
106106
Once you've registered your application and granted it permissions to send/receive data in Azure Service Bus, you can authenticate your client with the client secret credential, which will enable you to make requests against Azure Service Bus.
107107

108-
For a list of scenarios for which acquiring tokens is supported, see the [Scenarios](https://aka.ms/msal-net-scenarios) section of the [Microsoft Authentication Library (MSAL) for .NET](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet) GitHub repository.
108+
For a list of scenarios for which acquiring tokens are supported, see the [Scenarios](https://aka.ms/msal-net-scenarios) section of the [Microsoft Authentication Library (MSAL) for .NET](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet) GitHub repository.
109109

110110
Using the latest [Azure.Messaging.ServiceBus](https://www.nuget.org/packages/Azure.Messaging.ServiceBus) library, you can authenticate the [ServiceBusClient](/dotnet/api/azure.messaging.servicebus.servicebusclient) with a [ClientSecretCredential](/dotnet/api/azure.identity.clientsecretcredential), which is defined in the [Azure.Identity](https://www.nuget.org/packages/Azure.Identity) library.
111111

@@ -114,7 +114,7 @@ TokenCredential credential = new ClientSecretCredential("<tenant_id>", "<client_
114114
var client = new ServiceBusClient("<fully_qualified_namespace>", credential);
115115
```
116116

117-
If you're using the older .NET packages, please refer to the RoleBasedAccessControl samples in the [azure-service-bus samples repository](https://github.com/Azure/azure-service-bus).
117+
If you're using the older .NET packages, see the RoleBasedAccessControl samples in the [azure-service-bus samples repository](https://github.com/Azure/azure-service-bus).
118118

119119
## Next steps
120120
- To learn more about Azure RBAC, see [What is Azure role-based access control (Azure RBAC)](../role-based-access-control/overview.md)?
1.55 KB
Loading
-14 KB
Loading
-10.4 KB
Loading

articles/service-bus-messaging/service-bus-messaging-overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ Subscribers can define which messages they want to receive from a topic. These m
116116

117117
### Duplicate detection
118118

119-
If an error occurs that causes the client to have any doubt about the outcome of a send operation, duplicate detection takes the doubt out of these situations by enabling the sender to resend the same message, and the queue or topic discards any duplicate copies. For more information, see [](duplicate-detection.md).
119+
If an error occurs that causes the client to have any doubt about the outcome of a send operation, duplicate detection takes the doubt out of these situations by enabling the sender to resend the same message, and the queue or topic discards any duplicate copies. For more information, see [Duplicate detection](duplicate-detection.md).
120120

121121
### Security
122122
Service Bus supports security protocols such as [Shared Access Signatures](service-bus-sas.md) (SAS), [Role Based Access Control (RBAC)](service-bus-role-based-access-control.md) (RBAC) and [Managed identities for Azure resources](service-bus-managed-service-identity.md).

0 commit comments

Comments
 (0)