Skip to content

Commit aca86ec

Browse files
committed
added quickstart page for entra id integration
1 parent 2d090f1 commit aca86ec

File tree

4 files changed

+212
-0
lines changed

4 files changed

+212
-0
lines changed
Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
---
2+
title: Set up and exchange access tokens for Microsoft Entra ID users
3+
titleSuffix: An Azure Communication Services quickstart
4+
description: Building client application providing access tokens for Microsoft Entra ID users
5+
author: aigerimb
6+
manager: soricos
7+
services: azure-communication-services
8+
ms.author: aigerimb
9+
ms.date: 05/06/2025
10+
ms.topic: quickstart
11+
ms.service: azure-communication-services
12+
ms.subservice: acs-entra-id-authentication
13+
ms.reviewer: dominikme, dariac, sanchezjuan
14+
zone_pivot_groups: acs-js-csharp-java-python
15+
ms.custom: mode-other, devx-track-extended-java, devx-track-js, devx-track-python, has-azure-ad-ps-ref
16+
---
17+
# Quickstart: Set up and exchange access tokens for Microsoft Entra ID users
18+
19+
[!INCLUDE [Public Preview Disclaimer](../../includes/public-preview-include.md)]
20+
21+
This quickstart demonstrates how to use the Communication Services Common SDK along with Azure Identity SDK in a console application to authenticate a Microsoft Entra ID user, obtain an Entra ID user token, and automatically exchange it for an Azure Communication Services access token for Microsoft Entra ID user. The resulting Azure Communication Services access token allows you to integrate calling and chat features using the Communication Services Calling and Chat SDKs.
22+
23+
## Prerequisites
24+
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
25+
- An active Azure Communication Services resource and connection string. For more information, see [Create an Azure Communication Services resource](./create-communication-resource.md).
26+
- A Microsoft Entra ID instance. For more information, see [Microsoft Entra ID overview](./entra/fundamentals/whatis).
27+
28+
## Introduction
29+
30+
Your application can support users from either the same tenant or different tenants. In this quickstart, you'll explore a multitenant scenario involving users, developers, and administrators from the fictional companies Contoso and Fabrikam. In this example, Contoso is providing a software as a service (SaaS) solution for Fabrikam.
31+
32+
The following sections walk you through the steps required for administrators, developers, and users. The included diagrams illustrate the multitenant scenario. If you're working in a single-tenant environment, complete all steps for both Contoso and Fabrikam within the same tenant.
33+
34+
## Administrator actions
35+
36+
The Administrator role has extended permissions in Microsoft Entra ID. Members of this role can set up and manage resources. In the following diagram, you can see all actions that have to be executed by Administrators.
37+
38+
![Administrator actions to enable Azure Communication Services support for Microsoft Entra ID users.](./media/entra-id/entra-id-admin-overview.svg)
39+
40+
1. The Contoso Administrator create a service principal for Communication Services Clients application in Contoso Microsoft Entra ID tenant. This step is required to allow the Contoso application to access Communication Services Clients application API permissions.
41+
1. The Contoso Administrator creates or selects an existing *application* in Microsoft Entra ID. The property *Supported account types* defines whether users from various tenants can authenticate to the application. The property *Redirect URI* redirects a successful authentication request to the Contoso *client application*.
42+
1. The Contoso Administrator adds required API permissions from Communication Services Clients application. For the all list of the permissions, see [Access tokens with Microsoft Entra ID](./identity-model.md#access-tokens-with-microsoft-entra-id).
43+
1. The Contoso Administrator allows public client flow for the application.
44+
1. The Contoso Administrator creates or selects existing communication services. The Contoso Administrator grants Fabrikam Entra ID users access to Contoso Azure Communication Services resource. Azure Communication Services Common SDK will be used for Microsoft Entra ID user authentication and in the background seamlessly exchange Microsoft Entra user tokens for Communication Services access token of Microsoft Entra ID user. For more information, see [Create and manage Communication Services resources](./create-communication-resource.md).
45+
1. The Fabrikam Administrator grants required Communication Services Clients application API permissions to the Contoso application. This step is required if only Fabrikam Administrator can grant access to the application with the required permissions.
46+
47+
<a name='step-1-create-a-service-principal-for-acs-clients-application'></a>
48+
49+
### Step 1: Create a service principal for Azure Communication Services Clients application
50+
To enable the Contoso application to access Communication Services Clients application API permissions, the Contoso Administrator must create a service principal for Azure Communication Services Clients application in the Contoso Microsoft Entra ID tenant.
51+
The Contoso Administrator can create a service principal in Contoso tenant by one of the following methods:
52+
53+
- Use the [Microsoft Graph REST API](./graph/api/serviceprincipal-post-serviceprincipals?view=graph-rest-1.0&tabs=http#request) to run the following request:
54+
55+
```http
56+
POST https://graph.microsoft.com/v1.0/servicePrincipals
57+
Content-Type: application/json
58+
59+
{
60+
"appId": "2a04943b-b6a7-4f65-8786-2bb6131b59f6"
61+
}
62+
```
63+
64+
This request can also be executed in [Graph Explorer](./graph/graph-explorer/graph-explorer-overview). Make sure to include your full tenant domain in the URL `https://developer.microsoft.com/graph/graph-explorer?tenant={tenant domain}`, sign in,and provide consent for `Application.ReadWrite.All` permission.
65+
66+
- Use the [Azure CLI](./cli/azure/ad/sp?view=azure-cli-latest#az-ad-sp-create) to run the following command:
67+
68+
```azurecli-interactive
69+
az ad sp create --id 2a04943b-b6a7-4f65-8786-2bb6131b59f6
70+
```
71+
72+
<a name='step-2-create-an-entra-application-registration-or-select-an-entra-application'></a>
73+
74+
### Step 2: Create a Microsoft Entra application registration or select a Microsoft Entra application
75+
76+
Users must be authenticated against Microsoft Entra applications with Azure Communication Services Clients application API permissions. If you don't have an existing application that you want to use for this quickstart, you can create a new application registration.
77+
78+
The following application settings influence the experience:
79+
- The *Supported account types* property defines whether the application is single tenant ("Accounts in this organizational directory only") or multitenant ("Accounts in any organizational directory"). For this scenario, you can use multitenant.
80+
- *Redirect URI* defines the URI where the authentication request is redirected after authentication. For this scenario, you can use **Public client/native (mobile & desktop)** and enter **`http://localhost`** as the URI.
81+
82+
For more detailed information, see [Register an application with the Microsoft identity platform](/entra/identity-platform/quickstart-register-app#register-an-application).
83+
84+
85+
### Step 3: Allow public client flows
86+
87+
On the **Authentication** pane of your application, you can see a configured platform for *Public client/native(mobile & desktop)* with a redirect URI pointing to *http://localhost*. At the bottom of the pane, you'll see an *Allow public client flows* toggle control, which for this quickstart should be set to **Yes**.
88+
89+
### Step 4: Add Communication Services Clients permissions in the application
90+
91+
The application must declare Communication Services Clients to have access to Azure Communication Services capabilities. Microsoft Entra ID user would be requesting a Microsoft Entra user token with these permissions.
92+
93+
1. Navigate to your Microsoft Entra app in the Azure portal and select **API permissions**
94+
1. Select **Add Permissions**
95+
1. In the **Add Permissions** menu, select **APIs my organization uses**
96+
1. Search for and select **Azure Communication Services Clients**
97+
1. Select the permissions **VoIP** and **Chat**, then select **Add permissions**
98+
1. Grant admin consent for all delegated permissions.
99+
100+
![Add Communication Services Clients permissions to the Microsoft Entra application created in previous step.](./media/entra-id/entra-id-add-permissions.png)
101+
102+
### Step 5: Create or select a Communication Services resource and grant Entra ID users access it
103+
104+
The Azure Communication Services resource is used to authenticate all requests from Microsoft Entra ID users and to grant them access to the resource.
105+
106+
If you want to create a new Communication Services resource, see [Create and manage Communication Services resources](./create-communication-resource.md).
107+
108+
The Contoso administrator can provide Fabrikam Entra ID users with access to the Contoso Azure Communication Services resource through the Azure portal or by using the [Entra ID Assignment REST API](./rest/api/communication/identity/entra-id-assignment).
109+
110+
In the Azure portal follow these steps:
111+
1. Navigate to your Communication Services resource.
112+
2. In the left pane, select **User access for Entra ID** under the **Settings** group.
113+
3. Click the **Add** button to provide access to an Entra user, group, or entire tenant.
114+
4. In the **Principal type** select the correct value. In this scenario Contoso Admin provides access for a group from Fabrikam tenant and chooses **Group**.
115+
5. In the **Object ID** field, enter the object ID of the group from Fabrikam Microsoft Entra tenant.
116+
6. In the **Tenant ID** field, enter the tenant ID of the Fabrikam Microsoft Entra tenant.
117+
7. In the **Clien ID** field, enter the client ID of the application from [step 2](entra-id-authentication-integration.md#step-2-create-a-microsoft-entra-application-registration-or-select-a-microsoft-entra-application).
118+
8. Click **Save and exit** to apply the changes.
119+
120+
121+
### Step 6: Provide Administrator consent and group access to Azure Communication Services Clients application
122+
123+
Microsoft Entra tenant can be configured, to require Microsoft Entra administrator consent for Azure Communication Services Clients API permissions of the application. In such a case, the Microsoft Entra Administrator must grant permissions to the Contoso application for Azure Communication Services Clients API permissions. The Fabrikam Microsoft Entra Administrator provides consent via a unique URL.
124+
125+
The following roles can provide consent on behalf of a company:
126+
- Global admin
127+
- Application admin
128+
- Cloud application admin
129+
130+
If you want to check roles in Azure portal, see [List Azure role assignments](../../role-based-access-control/role-assignments-list-portal.yml).
131+
132+
To construct an Administrator consent URL, the Fabrikam Microsoft Entra Administrator does the following steps:
133+
134+
1. In the URL *https://login.microsoftonline.com/{Tenant_ID}/adminconsent?client_id={Application_ID}*, the Administrator replaces {Tenant_ID} with the Fabrikam [Tenant ID](../concepts/troubleshooting-info.md#get-a-directory-id), and replaces {Application_ID} with the Contoso [Application ID](../concepts/troubleshooting-info.md#get-an-application-id).
135+
1. The Administrator logs in and grants permissions on behalf of the organization.
136+
137+
The service principal of the Contoso application in the Fabrikam tenant is created if consent is granted. The Fabrikam Administrator can review the consent in Microsoft Entra ID by doing the following steps:
138+
139+
1. Sign in to the Azure portal as an administrator.
140+
1. Go to Microsoft Entra ID.
141+
1. On the **Enterprise applications** pane, set the **Application type** filter to **All applications**.
142+
1. In the field for filtering the applications, enter the name of the Contoso application.
143+
1. Select **Apply**.
144+
1. Select the service principal by using the required name.
145+
1. Go to the **Permissions** pane.
146+
147+
You can see that the status of the Communication Services Clients application API permissions are *Granted for {Directory_name}*.
148+
149+
150+
If you run into the issue "The app is trying to access a service '2a04943b-b6a7-4f65-8786-2bb6131b59f6'(Azure Communication Services Clients) that your organization '{GUID}' lacks a service principal for. You need to create a service principal for your tenant by following the instructions in the [Step 1: Create a service principal for Azure Communication Services Clients application](entra-id-authentication-integration.md#step-1-create-a-service-principal-for-azure-communication-services-clients-application).
151+
152+
153+
The group access to Azure Communication Services Clients application should be only provided if the Contoso Administrator provided a group access to the Contoso Azure Communication Services resource in the previous step. For the user or entire tenant access to the Azure Communication Services resource, the Fabrikam Administrator can skip this step.
154+
155+
Group-based assignment requires Microsoft Entra ID P1 or P2 edition. The Fabrikam Administrator can provide access to the group from Fabrikam tenant by using the [Microsoft Entra admin center](https://entra.microsoft.com).
156+
To provide access to the group, the Fabrikam Administrator does the following steps:
157+
1. Login to [Microsoft Entra admin center](https://entra.microsoft.com) with **Global Administrator** or **Tenant Administrator** roles.
158+
1. Navigate to **Identity > Applications > Enterprise applications** in the left panel menu.
159+
1. In the search box, enter **Azure Communication Services Clients**, and then select the application from the search results.
160+
1. In the left panel menu, select **Users and groups** and then select **Add user/group**.
161+
1. On the **Add Assignment** pane, select **None Selected** under **Users and groups**.
162+
1. Search for and select the group that you want to assign to the application.
163+
1. Click on **Select** and then select **Assign** to assign the group to the application.
164+
165+
![Assign group access to Azure Communication Services Clients application.](./media/entra-id/entra-admin-center-group-application-assignment.png)
166+
167+
## Developer actions
168+
169+
The Contoso developer needs to set up the *client application* to authenticate users. In the client application, the developer creates a credential using Communication Common SDK along with Azure Identity SDK capable of authenticating users against the Microsoft Entra ID application and exchanging the Microsoft Entra user token for Azure Communication Services access token of Microsoft Entra ID user.
170+
171+
The developer's required actions are shown in following diagram:
172+
173+
![Diagram of developer actions to enable Azure Communication Services support for Microsoft Entra ID users.]()
174+
175+
1. The Contoso developer initialize any implementation of `TokenCredential` from Azure Identity SDK which is capable of obtaining a Microsoft Entra user token for the application that was created earlier by the Administrator.
176+
1. The Contoso developer initializes `AzureCommunicationTokenCredential` from Communication Services Common SDK with `TokenCredential` created in the step 1. The `AzureCommunicationTokenCredential` credential exchanges the incoming Microsoft Entra user token for the access token of Teams user seamlessly in the background.
177+
178+
179+
> [!NOTE]
180+
> The following sections describe how to create `AzureCommunicationTokenCredential`.
181+
182+
::: zone pivot="programming-language-javascript"
183+
[!INCLUDE [JavaScript]()]
184+
::: zone-end
185+
186+
187+
## User actions
188+
189+
The user represents the Fabrikam users of the Contoso application. The user experience is shown in the following diagram:
190+
191+
![Diagram of user actions to enable Azure Communication Services support for Microsoft Entra ID users.]()
192+
193+
1. The Fabrikam user uses the Contoso *client application* and is prompted to authenticate.
194+
1. The Contoso *client application* uses the Azure Identity SDK to authenticate the user against the Fabrikam Microsoft Entra tenant for the Contoso application with Communication Services Clients permissions.
195+
1. Authentication is redirected to the *client application*, as defined in the property *Redirect URI* in the Contoso application.
196+
1. The Communication Common SDK seamlessly exchanges the Microsoft Entra user token for Azure Communication Services access token of Microsoft Entra ID user in the background.
197+
198+
Developers can integrate the Communication Services Calling SDK or Chat SDK by providing `AzureCommunicationTokenCredential`.
199+
200+
## Next steps
201+
202+
In this quickstart, you learned how to:
203+
204+
> [!div class="checklist"]
205+
> * Create and configure an application in Microsoft Entra ID.
206+
> * Use Communication Services Common SDK and Azure Identity SDK to integrate Microsoft Entra ID users to Azure Communication Services.
207+
208+
Learn about the following concepts:
209+
210+
- [Support Microsoft Entra ID users in Azure Communication Services](../concepts/identity-model.md#microsoft-entra-id-integrating-with-entra-id)
211+
- [Single-tenant and multitenant authentication for Microsoft Entra Id users](../concepts/entra-id-authentication-overview.md)
Loading
900 KB
Loading

articles/communication-services/quickstarts/identity/media/entra-id/entra-id-admin-overview.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)