Skip to content

Commit 4def4ed

Browse files
authored
Merge pull request #284925 from ktoliver/pubsub
[AQ] edit pass: Azure Web PubSub how-to articles (work item 291696)
2 parents bdda95a + e19e83d commit 4def4ed

26 files changed

+623
-592
lines changed
Lines changed: 85 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,163 +1,166 @@
11
---
2-
title: Authorize request to Web PubSub resources with Microsoft Entra ID from applications
3-
description: This article provides information about authorizing request to Web PubSub resources with Microsoft Entra ID from applications
2+
title: Authorize an application request by using Microsoft Entra ID
3+
description: Learn how to authorize an application request to Web PubSub resources by using Microsoft Entra ID.
44
author: terencefan
5-
65
ms.author: tefa
7-
ms.date: 11/08/2021
6+
ms.date: 08/16/2024
87
ms.service: azure-web-pubsub
98
ms.topic: conceptual
109
---
1110

12-
# Authorize request to Web PubSub resources with Microsoft Entra ID from Azure applications
11+
# Authorize an application request by using Microsoft Entra ID
1312

14-
Azure Web PubSub Service supports Microsoft Entra ID for authorizing requests from [applications](../active-directory/develop/app-objects-and-service-principals.md).
13+
Azure Web PubSub supports Microsoft Entra ID for authorizing requests from [applications](../active-directory/develop/app-objects-and-service-principals.md).
1514

16-
This article shows how to configure your Web PubSub resource and codes to authorize the request to a Web PubSub resource from an Azure application.
15+
This article shows you how to configure your Web PubSub resource and code to authorize a request to a Web PubSub resource from an Azure application.
1716

1817
## Register an application
1918

2019
The first step is to register an Azure application.
2120

22-
1. On the [Azure portal](https://portal.azure.com/), search for and select **Microsoft Entra ID**
23-
2. Under **Manage** section, select **App registrations**.
24-
3. Click **New registration**.
25-
26-
![Screenshot of registering an application.](./media/howto-authorize-from-application/register-an-application.png)
21+
1. In the [Azure portal](https://portal.azure.com/), search for and then select **Microsoft Entra ID**.
22+
1. On the left menu under **Manage**, select **App registrations**.
23+
1. Select **New registration**.
24+
1. For **Name**, enter a name to use for your application.
25+
1. Select **Register** to confirm the application registration.
2726

28-
4. Enter a display **Name** for your application.
29-
5. Click **Register** to confirm the register.
27+
:::image type="content" source="media/howto-authorize-from-application/register-an-application.png" alt-text="Screenshot that shows registering an application.":::
3028

31-
Once you have your application registered, you can find the **Application (client) ID** and **Directory (tenant) ID** under its Overview page. These GUIDs can be useful in the following steps.
29+
When your application is registered, go to the application overview to view the values for **Application (client) ID** and **Directory (tenant) ID**. You use these values in the following sections.
3230

33-
![Screenshot of an application.](./media/howto-authorize-from-application/application-overview.png)
31+
:::image type="content" source="media/howto-authorize-from-application/application-overview.png" alt-text="Screenshot that shows an application.":::
3432

35-
To learn more about registering an application, see
36-
37-
- [Quickstart: Register an application with the Microsoft identity platform](../active-directory/develop/quickstart-register-app.md).
33+
For more information about registering an application, see the quickstart [Register an application by using the Microsoft identity platform](../active-directory/develop/quickstart-register-app.md).
3834

3935
## Add credentials
4036

4137
You can add both certificates and client secrets (a string) as credentials to your confidential client app registration.
4238

43-
### Client secret
39+
For more information about adding credentials, see [Add credentials](../active-directory/develop/quickstart-register-app.md#add-credentials).
4440

45-
The application requires a client secret to prove its identity when requesting a token. To create a client secret, follow these steps.
41+
### Add a client secret
4642

47-
1. Under **Manage** section, select **Certificates & secrets**
48-
1. On the **Client secrets** tab, click **New client secret**.
49-
![Screenshot of creating a client secret.](./media/howto-authorize-from-application/new-client-secret.png)
50-
1. Enter a **description** for the client secret, and choose a **expire time**.
51-
1. Copy the value of the **client secret** and then paste it to a secure location.
52-
> [!NOTE]
53-
> The secret will display only once.
43+
The application requires a client secret for a client to prove its identity when it requests a token.
5444

55-
### Certificate
45+
To create a client secret:
5646

57-
You can also upload a certification instead of creating a client secret.
47+
1. On the left menu under **Manage**, select **Certificates & secrets**.
48+
1. On the **Client secrets** tab, select **New client secret**.
5849

59-
![Screenshot of uploading a certification.](./media/howto-authorize-from-application/upload-certificate.png)
50+
:::image type="content" source="media/howto-authorize-from-application/new-client-secret.png" alt-text="Screenshot that shows creating a client secret.":::
51+
52+
1. Enter a description for the client secret, and then choose an **Expires** time for the secret.
53+
1. Copy the value of the client secret, and then paste it to a secure location to save for later use.
54+
55+
> [!NOTE]
56+
> The secret is visible only when you create the secret. You can't view the client secret in the portal later.
6057
61-
To learn more about adding credentials, see
58+
### Add a certificate
6259

63-
- [Add credentials](../active-directory/develop/quickstart-register-app.md#add-credentials)
60+
You can upload a certificate instead of creating a client secret.
6461

65-
## Add role assignments on Azure portal
62+
:::image type="content" source="media/howto-authorize-from-application/upload-certificate.png" alt-text="Screenshot that shows uploading a certificate.":::
6663

67-
This sample shows how to assign a `Web PubSub Service Owner` role to a service principal (application) over a Web PubSub resource.
64+
## Add a role assignment in the Azure portal
65+
66+
This section demonstrates how to assign a Web PubSub Service Owner role to a service principal (application) for a Web PubSub resource.
6867

6968
> [!NOTE]
70-
> A role can be assigned to any scope, including management group, subscription, resource group or a single resource. To learn more about scope, see [Understand scope for Azure RBAC](../role-based-access-control/scope-overview.md)
69+
> You can assign a role to any scope, including management group, subscription, resource group, and single resource. For more information about scope, see [Understand scope for Azure role-based access control](../role-based-access-control/scope-overview.md).
7170
72-
1. On the [Azure portal](https://portal.azure.com/), navigate to your Web PubSub resource.
71+
1. In the [Azure portal](https://portal.azure.com/), go to your Web PubSub resource.
7372

74-
1. Click **Access Control (IAM)** to display access control settings for the Azure Web PubSub.
73+
1. On the left menu, select **Access control (IAM)** to display access control settings for the resource.
7574

76-
1. Click the **Role assignments** tab to view the role assignments at this scope.
75+
1. Select the **Role assignments** tab and view the role assignments at this scope.
7776

78-
The following screenshot shows an example of the Access control (IAM) page for a Web PubSub resource.
77+
The following figure shows an example of the **Access control (IAM)** pane for a Web PubSub resource:
7978

80-
![Screenshot of access control.](./media/howto-authorize-from-application/access-control.png)
79+
:::image type="content" source="media/howto-authorize-from-application/access-control.png" alt-text="Screenshot that shows an example of the Access control (IAM) pane.":::
8180

82-
1. Click **Add > Add role assignment**.
81+
1. Select **Add** > **Add role assignment**.
8382

84-
1. On the **Roles** tab, select `Web PubSub Service Owner`.
83+
1. Select the **Roles** tab, and then select **Web PubSub Service Owner**.
8584

86-
1. Click **Next**.
85+
1. Select **Next**.
8786

88-
![Screenshot of adding role assignment.](./media/howto-authorize-from-application/add-role-assignment.png)
87+
:::image type="content" source="media/howto-authorize-from-application/add-role-assignment.png" alt-text="Screenshot that shows adding a role assignment.":::
8988

90-
1. On the **Members** tab, under **Assign access to** section, select **User, group, or service principal**.
89+
1. Select the **Members** tab. Under **Assign access to**, select **User, group, or service principal**.
9190

92-
1. Click **Select Members**
91+
1. Choose **Select members**.
9392

94-
1. Search for and select the application that you would like to assign the role to.
93+
1. Search for and select the application to assign the role to.
9594

96-
1. Click **Select** to confirm the selection.
95+
1. Choose **Select** to confirm the selection.
9796

98-
1. Click **Next**.
97+
1. Select **Next**.
9998

100-
![Screenshot of assigning role to service principals.](./media/howto-authorize-from-application/assign-role-to-service-principals.png)
99+
:::image type="content" source="media/howto-authorize-from-application/assign-role-to-service-principals.png" alt-text="Screenshot that shows assigning a role to service principals.":::
101100

102-
1. Click **Review + assign** to confirm the change.
101+
1. Select **Review + assign** to confirm the change.
103102

104103
> [!IMPORTANT]
105-
> Azure role assignments may take up to 30 minutes to propagate.
106-
> To learn more about how to assign and manage Azure role assignments, see these articles:
104+
> Azure role assignments might take up to 30 minutes to propagate.
105+
106+
To learn more about how to assign and manage Azure role assignments, see these articles:
107107

108-
- [Assign Azure roles using the Azure portal](../role-based-access-control/role-assignments-portal.yml)
109-
- [Assign Azure roles using the REST API](../role-based-access-control/role-assignments-rest.md)
110-
- [Assign Azure roles using Azure PowerShell](../role-based-access-control/role-assignments-powershell.md)
111-
- [Assign Azure roles using Azure CLI](../role-based-access-control/role-assignments-cli.md)
112-
- [Assign Azure roles using Azure Resource Manager templates](../role-based-access-control/role-assignments-template.md)
108+
- [Assign Azure roles by using the Azure portal](../role-based-access-control/role-assignments-portal.yml)
109+
- [Assign Azure roles by using REST API](../role-based-access-control/role-assignments-rest.md)
110+
- [Assign Azure roles by using Azure PowerShell](../role-based-access-control/role-assignments-powershell.md)
111+
- [Assign Azure roles by using the Azure CLI](../role-based-access-control/role-assignments-cli.md)
112+
- [Assign Azure roles by using an Azure Resource Manager template](../role-based-access-control/role-assignments-template.md)
113113

114114
## Use Postman to get the Microsoft Entra token
115115

116-
1. Launch Postman
116+
1. Open Postman.
117117

118-
2. For the method, select **GET**.
118+
1. For **Method**, select **GET**.
119119

120-
3. For the **URI**, enter `https://login.microsoftonline.com/<TENANT ID>/oauth2/token`. Replace `<TENANT ID>` with the **Directory (tenant) ID** value in the **Overview** tab of the application you created earlier.
120+
1. For **URI**, enter `https://login.microsoftonline.com/<TENANT ID>/oauth2/token`. Replace `<TENANT ID>` with the value for **Directory (tenant) ID** on the **Overview** pane of the application you created.
121121

122-
4. On the **Headers** tab, add **Content-Type** key and `application/x-www-form-urlencoded` for the value.
122+
1. Select the **Headers** tab, and then add the following keys and values:
123123

124-
![Screenshot of the basic info using postman to get the token.](./media/howto-authorize-from-application/get-azure-ad-token-using-postman.png)
124+
1. For **Key**, select **Content-Type**.
125+
1. For **Value**, enter `application/x-www-form-urlencoded`.
125126

126-
5. Switch to the **Body** tab, and add the following keys and values.
127-
1. Select **x-www-form-urlencoded**.
128-
2. Add `grant_type` key, and type `client_credentials` for the value.
129-
3. Add `client_id` key, and paste the value of **Application (client) ID** in the **Overview** tab of the application you created earlier.
130-
4. Add `client_secret` key, and paste the value of client secret you noted down earlier.
131-
5. Add `resource` key, and type `https://webpubsub.azure.com` for the value.
127+
:::image type="content" source="media/howto-authorize-from-application/get-azure-ad-token-using-postman.png" alt-text="Screenshot that shows information on the Basic tab when you use Postman to get the token.":::
132128

133-
![Screenshot of the body parameters when using postman to get the token.](./media/howto-authorize-from-application/get-azure-ad-token-using-postman-body.png)
129+
1. Select the **Body** tab.
130+
1. Select the body type **x-www-form-urlencoded**.
131+
1. Under **Key**, add the following keys and values:
134132

135-
6. Select **Send** to send the request to get the token. You see the token in the `access_token` field.
133+
1. Select **grant_type**, and then select the value **client_credentials**.
134+
1. Select **client_id**, and then paste the value of **Application (client) ID** from the **Overview** pane of the application you created.
135+
1. Select **client_secret**, and then paste the value of the client secret you saved.
136+
1. Select **resource**, and then enter `https://webpubsub.azure.com` for the value.
136137

137-
![Screenshot of the response token when using postman to get the token.](./media/howto-authorize-from-application/get-azure-ad-token-using-postman-response.png)
138+
:::image type="content" source="media/howto-authorize-from-application/get-azure-ad-token-using-postman-body.png" alt-text="Screenshot that shows the Body tab parameters when you use Postman to get the token.":::
138139

139-
7. For oauth2/v2.0/token endpoint, pass the 'scope' instead of 'resource'
140+
For an OAuth2/v2.0/token endpoint, pass the value for `scope` instead of the value for `resource`:
140141

141-
```
142-
client_id: *your client id*
142+
```json
143+
client_id: *your client ID*
143144
client_secret: *your client secret*
144145
grant_type: client_credentials
145146
scope: https://webpubsub.azure.com/.default
146147
```
147148

148-
## Sample codes using Microsoft Entra authorization
149+
1. Select **Send** to send the request to get the token. The value for `access_token` is the access token.
149150

150-
We officially support 4 programming languages:
151+
:::image type="content" source="media/howto-authorize-from-application/get-azure-ad-token-using-postman-response.png" alt-text="Screenshot that shows the response token when you use Postman to get the token.":::
152+
153+
## Code samples that use Microsoft Entra authorization
154+
155+
Get samples that use Microsoft Entra authorization in our four officially supported programming languages:
151156

152157
- [C#](./howto-create-serviceclient-with-net-and-azure-identity.md)
153158
- [Python](./howto-create-serviceclient-with-python-and-azure-identity.md)
154159
- [Java](./howto-create-serviceclient-with-java-and-azure-identity.md)
155160
- [JavaScript](./howto-create-serviceclient-with-javascript-and-azure-identity.md)
156161

157-
## Next steps
158-
159-
See the following related articles:
162+
## Related content
160163

161164
- [Overview of Microsoft Entra ID for Web PubSub](concept-azure-ad-authorization.md)
162-
- [Authorize request to Web PubSub resources with Microsoft Entra ID from managed identities](howto-authorize-from-managed-identity.md)
165+
- [Use Microsoft Entra ID to authorize a request from a managed identity to Web PubSub resources](howto-authorize-from-managed-identity.md)
163166
- [Disable local authentication](./howto-disable-local-auth.md)

0 commit comments

Comments
 (0)