|
3 | 3 | This document provides step-by-step instructions to configure Azure App Registrations for a front-end and back-end application. |
4 | 4 |
|
5 | 5 | ## Prerequisites |
| 6 | + |
6 | 7 | - Access to **Azure Active Directory (Azure AD)** |
7 | 8 | - Necessary permissions to create and manage **App Registrations** |
8 | 9 |
|
9 | | -## Step 1: Add Authentication Provider |
10 | | -We will add Microsoft Entra ID as an authentication provider to API and Web Application. |
| 10 | +## Step 1: Add Authentication Provider |
| 11 | + |
| 12 | +We will add Microsoft Entra ID as an authentication provider to API and Web Application. |
| 13 | + |
| 14 | +1. Add Authentication Provider in Web Application |
11 | 15 |
|
12 | | -1. Add Authentication Provider in Web Application |
13 | | - |
14 | | - - Go to deployed Container App and select ca-< your environment >-< randomname >-web and click **Add Identity Provider** button in Authentication |
15 | | - |
| 16 | + - Go to deployed Container App and select `ca-<your environment>-<randomname>-web` and click **Add Identity Provider** button in Authentication. |
| 17 | +  |
16 | 18 |
|
17 | | - - Select **Microsoft** and set **Client secret expiration** then Click **Add** button |
18 | | - |
| 19 | + - Select **Microsoft** and set **Client secret expiration**, then click **Add** button. |
| 20 | +  |
19 | 21 |
|
20 | | -2. Add Authentication Provider in API Service |
21 | | - |
22 | | - - Go to deployed Container App and select **ca-< your environment >-< randomname >-api** and click **Add Identity Provider** button in Authentication |
23 | | - |
| 22 | +2. Add Authentication Provider in API Service |
24 | 23 |
|
25 | | - - Select **Microsoft** and set **Client secret expiration** |
26 | | - |
| 24 | + - Go to deployed Container App and select `ca-<your environment>-<randomname>-api` and click **Add Identity Provider** button in Authentication. |
| 25 | +  |
27 | 26 |
|
28 | | - - Set **Unauthenticated requests** then Click **Add** button |
29 | | - |
| 27 | + - Select **Microsoft** and set **Client secret expiration**. |
| 28 | +  |
| 29 | + |
| 30 | + - Set **Unauthenticated requests**, then click **Add** button. |
| 31 | +  |
30 | 32 |
|
31 | 33 | ## Step 2: Configure Application Registration - Web Application |
| 34 | + |
32 | 35 | 1. Set Redirect URI in Single Page Application Platform |
33 | | - - Go to deployed Container App **ca-< your environment >-< randomname >-web** and select **Authentication** menu then select created Application Registration |
34 | | - |
35 | | - |
36 | | - - Select **Authentication** then Select **+ Add a platform** menu |
37 | | - |
38 | | - |
39 | | - - Select **Single-page application** |
40 | | - |
41 | | - |
42 | | - - Add Container App **ca-< your environment >-< randomname >-web**'s URL |
43 | | - |
44 | | - - You may get this URL from here in your Container App |
45 | | - |
46 | | - |
47 | | -2. Add Permission and Grant Permission |
48 | | - - Add Permission for API application. Select **+ Add a permission** button then search API application with name **ca-< your environment name >-<unique string>-api** |
49 | | - |
50 | | - |
51 | | - - Grant admin consent to permissions |
52 | | - |
53 | | - |
54 | | - |
55 | | -3. Grap Scope Name for Impersonation |
56 | | - - Select **Expose an API** in left menu. Copy the Scope name then paste in some temporary place. |
57 | | - The copied text will be used for Web Application Environment variable - **APP_MSAL_AUTH_SCOPE**. |
58 | | - |
59 | | - |
60 | | -4. Grap Client Id for Web App |
61 | | - - Select **Overview** in left menu. Copy the Client Id then paste in some temporary place. |
62 | | - The copied text will be used for Web Application Environment variable - **APP_MSAL_AUTH_CLIENT_ID** |
63 | | - |
64 | | - |
65 | | -## Step 3: Configure Application Registration - API Application |
66 | | -1. Grap Scope Name for Impersonation |
67 | | - - Go to deployed Container App **ca-< your environment >-< randomname >-api** and select **Authentication** menu then select created Application Registration |
68 | | - |
69 | | - |
70 | | - - Select **Expose an API** in left menu.Copy the Scope name then paste in some temporary place. |
71 | | - The copied text will be used for Web Application Environment variable - **APP_MSAL_TOKEN_SCOPE**. |
72 | | - |
73 | | - |
74 | | -2. Grap Client Id for API |
75 | | - - Select **Overview** in left menu. Copy the Client Id then paste in some temporary place. |
76 | | - The copied text will be used for **allowed client applications** list |
77 | | - |
78 | | - |
79 | | -## Step 4: Add API Client Id to Allowed Client Applications list in Web Application's Registration |
80 | | -1. Go to deployed Container App **ca-< your environment >-< randomname >-web** and select **Authentication** menu then select **Edit** |
81 | | - |
82 | | -2. Select **Allow requests from specific client applications** then click **pencil** icon to add client Id |
83 | | - |
84 | | -1. Add **Client Id** from [API App registration from previous step] then Save(#step-3-configure-application-registration---api-application). |
85 | | - |
86 | 36 |
|
| 37 | + - Go to deployed Container App `ca-<your environment>-<randomname>-web` and select **Authentication** menu, then select created Application Registration. |
| 38 | +  |
87 | 39 |
|
88 | | -## Step 5: Update Environment Variable in Container App for Web Application |
89 | | -In previous 2 steps for [Configure Application Registration - Web Application](#step-2-configure-application-registration---web-application) and [Configure Application Registration - API Application](#step-3-configure-application-registration---api-application), we could grap Client Id for Web App's Application Registration and Scopes for Web and API's Application Registration. |
| 40 | + - Select **Authentication**, then select **+ Add a platform** menu. |
| 41 | +  |
| 42 | + |
| 43 | + - Select **Single-page application**. |
| 44 | +  |
| 45 | + |
| 46 | + - Add Container App `ca-<your environment>-<randomname>-web`'s URL. |
| 47 | +  |
| 48 | + |
| 49 | + - You may get this URL from here in your Container App. |
| 50 | +  |
| 51 | + |
| 52 | +2. Add Permission and Grant Permission |
90 | 53 |
|
91 | | -Now, We will Edit and deploy Web Application Container with updated Environment variables. |
| 54 | + - Add Permission for API application. Select **+ Add a permission** button, then search API application with name `ca-<your environment name>-<unique string>-api`. |
| 55 | +  |
| 56 | +  |
92 | 57 |
|
93 | | -1. Select **Containers** menu under **Application** then **click Edit and Deploy** menu. |
94 | | - |
| 58 | + - Grant admin consent to permissions. |
| 59 | +  |
95 | 60 |
|
96 | | -2. Select Container image and Click **Edit**. under **Environment variables** sections, update 3 values which were taken in previous steps for **APP_MSAL_AUTH_CLIENT_ID**, **APP_MSAL_AUTH_SCOPE**, **APP_MSAL_TOKEN_SCOPE**. |
97 | | -Now updated Revision will be activated soon. |
| 61 | +3. Grab Scope Name for Impersonation |
98 | 62 |
|
| 63 | + - Select **Expose an API** in the left menu. Copy the Scope name, then paste it in some temporary place. |
| 64 | + The copied text will be used for Web Application Environment variable - **APP_MSAL_AUTH_SCOPE**. |
| 65 | +  |
99 | 66 |
|
| 67 | +4. Grab Client Id for Web App |
100 | 68 |
|
| 69 | + - Select **Overview** in the left menu. Copy the Client Id, then paste it in some temporary place. |
| 70 | + The copied text will be used for Web Application Environment variable - **APP_MSAL_AUTH_CLIENT_ID**. |
| 71 | +  |
101 | 72 |
|
| 73 | +## Step 3: Configure Application Registration - API Application |
102 | 74 |
|
| 75 | +1. Grab Scope Name for Impersonation |
103 | 76 |
|
| 77 | + - Go to deployed Container App `ca-<your environment>-<randomname>-api` and select **Authentication** menu, then select created Application Registration. |
| 78 | +  |
104 | 79 |
|
| 80 | + - Select **Expose an API** in the left menu. Copy the Scope name, then paste it in some temporary place. |
| 81 | + The copied text will be used for Web Application Environment variable - **APP_MSAL_TOKEN_SCOPE**. |
| 82 | +  |
105 | 83 |
|
| 84 | +## Step 4: Add Web Application's Client Id to Allowed Client Applications List in API Application Registration |
| 85 | + |
| 86 | +1. Go to the deployed Container App `ca-<your environment>-<randomname>-api`, select **Authentication**, and then click **Edit**. |
| 87 | +  |
| 88 | + |
| 89 | +2. Select **Allow requests from specific client applications**, then click the **pencil** icon to add the Client Id. |
| 90 | +  |
| 91 | + |
| 92 | +3. Add the **Client Id** obtained from [Step 2: Configure Application Registration - Web Application](#step-2-configure-application-registration---web-application), then save. |
| 93 | +  |
| 94 | + |
| 95 | +## Step 5: Update Environment Variable in Container App for Web Application |
| 96 | + |
| 97 | +In previous steps for [Configure Application Registration - Web Application](#step-2-configure-application-registration---web-application) and [Configure Application Registration - API Application](#step-3-configure-application-registration---api-application), we grabbed Client Id for Web App's Application Registration and Scopes for Web and API's Application Registration. |
| 98 | + |
| 99 | +Now, we will edit and deploy the Web Application Container with updated Environment variables. |
| 100 | + |
| 101 | +1. Select **Containers** menu under **Application**, then click **Edit and Deploy** menu. |
| 102 | +  |
| 103 | + |
| 104 | +2. Select Container image and click **Edit**. Under **Environment variables** section, update 3 values which were taken in previous steps for **APP_MSAL_AUTH_CLIENT_ID**, **APP_MSAL_AUTH_SCOPE**, **APP_MSAL_TOKEN_SCOPE**. |
| 105 | + The updated revision will be activated soon. |
106 | 106 |
|
107 | 107 | ## Conclusion |
| 108 | + |
108 | 109 | You have successfully configured the front-end and back-end Azure App Registrations with proper API permissions and security settings. |
0 commit comments