Skip to content

Commit 09ee76b

Browse files
feat: Updated Readme and fixed AZ template issue
1 parent ef8c977 commit 09ee76b

6 files changed

Lines changed: 101 additions & 257 deletions

File tree

docs/AppAuthentication.md

Lines changed: 0 additions & 53 deletions
This file was deleted.

docs/ConfigureAppAuthentication.md

Lines changed: 99 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,109 @@
1-
# Azure App Registrations Setup
1+
# Set up Authentication in Azure Container App
22

33
This document provides step-by-step instructions to configure Azure App Registrations for a front-end and back-end application.
44

55
## Prerequisites
6+
67
- Access to **Azure Active Directory (Azure AD)**
78
- Necessary permissions to create and manage **App Registrations**
89

9-
## Step 1: Create Back-End App Registration
10-
1. Go to the [Azure Portal](https://portal.azure.com/).
11-
1. Navigate to **App registrations**.
12-
1. Click **New registration**.
13-
1. Provide a **Name** for the back-end app (e.g., `cps-backend-<env_name>-app`).
14-
1. Choose **Supported account types**.
15-
1. Click **Register**.
16-
17-
### Step 1.1: Expose an API for the Back-End App
18-
1. In the back-end app registration, go to **Expose an API**.
19-
1. Click **Add a scope**.
20-
1. Click **Save and Continue**.
21-
1. Set the **Scope name** to `user_impersonation`.
22-
1. Set the **Admin consent display name** to `user_impersonation`.
23-
1. Provide a description and enable **Admin consent**.
24-
1. Click **Add Scope**.
25-
1. Copy the **Scope value**.
26-
1. Go to the **Overview** section and copy the **Client ID** of the back-end app.
27-
28-
### Step 1.2: Generate Client Secret
29-
1. In the back-end app registration, go to **Certificates & secrets**.
30-
1. Click **New Client Secret**.
31-
1. Enter a **Description**.
32-
1. Select the **Expiration time** for the secret.
33-
1. Click **Add**.
34-
1. Copy the **Secret value**.
35-
36-
## Step 2: Copy Front-End App URL from Azure Container Apps
37-
1. Navigate to the **Resource Group** where your Azure resources are deployed.
38-
1. Select the deployed front-end application named **ca-cps-<env_name>-web**.
39-
1. Copy the **Front-End Application URL** displayed under the **Overview** section.
40-
41-
## Step 3: Create Front-End App Registration
42-
1. Navigate to **App registrations**.
43-
1. Click **New registration**.
44-
1. Provide a **Name** for the front-end app (e.g., `cps-frontend-<env_name>-app`).
45-
1. Choose **Supported account types** as per your requirement.
46-
1. In the **Redirect URI** section, select **Single-page application** and paste the copied **Front-End Application URL** from Step 2 in the textbox next to it.
47-
1. Click **Register**.
48-
49-
### Step 3.1: Expose an API for the Front-End App
50-
1. In the front-end app registration, go to **Expose an API**.
51-
1. Click **Add a scope**.
52-
1. Click **Save and Continue**.
53-
1. Set the **Scope name** to `user_impersonation`.
54-
1. Set the **Admin consent display name** to `user_impersonation`.
55-
1. Provide a description and enable **Admin consent**.
56-
1. Click **Add Scope**.
57-
1. Copy the **Scope value**.
58-
1. Go to the **Overview** section and copy the **Client ID** of the app.
59-
60-
### Step 3.2: Configure API Permissions in the Front-End App
61-
1. In the front-end app registration, go to **API permissions**.
62-
1. Click **Add a permission**.
63-
1. Select **My APIs**.
64-
1. Select the back-end app registration created in Step 1.
65-
1. If you don’t find it under **My APIs**, search under **APIs My organization uses**.
66-
1. Choose the `user_impersonation` permission.
67-
1. Click **Add permissions**.
68-
1. Click **Grant admin consent**.
69-
70-
## Step 4: Configure Authentication Settings in the Front-End Container App (Web)
71-
1. Navigate to the **Resource Group** where your Azure resources are deployed.
72-
1. Select the deployed front-end application named **ca-cps-<env_name>-web**.
73-
1. Click **Containers** under **Application** from the left-side menu.
74-
1. Click **Environment variables**.
75-
1. For the key **APP_MSAL_AUTH_CLIENT_ID**, add the front-end app **Client ID** copied from Step 3.1.
76-
1. For the key **APP_MSAL_AUTH_SCOPE**, add the scope copied from Step 3.1.
77-
1. For the key **APP_MSAL_TOKEN_SCOPE**, add the scope copied from Step 1.1.
78-
1. Click **Save as a new revision**.
79-
80-
## Step 5: Configure Identity Provider in the Back-End Container App (API)
81-
1. Navigate to the **Resource Group** where your Azure resources are deployed.
82-
1. Select the deployed back-end application named **ca-cps-<env_name>-api**.
83-
1. Under **Settings**, go to **Authentication**.
84-
1. Click **Add Identity Provider**.
85-
1. Select the **Identity Provider** as **Microsoft**.
86-
1. Select **Provide the details of an existing app registration**.
87-
1. Enter the **Back-End API App Client ID** copied from Step 1.1 into the **Application (client) ID** field.
88-
1. Enter the **Client Secret** generated in Step 1.2 into the **Client secret (recommended)** field.
89-
1. Under **Allowed token audiences**, add the value **api://<Back-End App Client ID>**.
90-
1. Under **Client application requirement**, select **Allow requests from specific client applications**.
91-
1. Click the **Edit** icon under the **Allowed client applications** section.
92-
1. Add the **Client ID of the Back-End App** copied from Step 1.1.
93-
1. Add the **Client ID of the Front-End App** copied from Step 3.1.
94-
1. Click **OK**.
95-
1. Under the **Unauthenticated requests** section, select **HTTP 401 Unauthorized: recommended for APIs**.
96-
1. Click **Add**.
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
15+
16+
- Go to deployed Container App and select `ca-<your environment>-<randomname>-web` and click **Add Identity Provider** button in Authentication.
17+
![add_auth_provider_web_1](./Images/add_auth_provider_web_1.png)
18+
19+
- Select **Microsoft** and set **Client secret expiration**, then click **Add** button.
20+
![add_auth_provider_web_2](./Images/add_auth_provider_web_2.png)
21+
22+
2. Add Authentication Provider in API Service
23+
24+
- Go to deployed Container App and select `ca-<your environment>-<randomname>-api` and click **Add Identity Provider** button in Authentication.
25+
![add_auth_provider_api_1](./Images/add_auth_provider_api_1.png)
26+
27+
- Select **Microsoft** and set **Client secret expiration**.
28+
![add_auth_provider_api_2](./Images/add_auth_provider_api_2.png)
29+
30+
- Set **Unauthenticated requests**, then click **Add** button.
31+
![add_auth_provider_api_3](./Images/add_auth_provider_api_3.png)
32+
33+
## Step 2: Configure Application Registration - Web Application
34+
35+
1. Set Redirect URI in Single Page Application Platform
36+
37+
- Go to deployed Container App `ca-<your environment>-<randomname>-web` and select **Authentication** menu, then select created Application Registration.
38+
![configure_app_registration_web_1](./Images/configure_app_registration_web_1.png)
39+
40+
- Select **Authentication**, then select **+ Add a platform** menu.
41+
![configure_app_registration_web_2](./Images/configure_app_registration_web_2.png)
42+
43+
- Select **Single-page application**.
44+
![configure_app_registration_web_3](./Images/configure_app_registration_web_3.png)
45+
46+
- Add Container App `ca-<your environment>-<randomname>-web`'s URL.
47+
![configure_app_registration_web_4](./Images/configure_app_registration_web_4.png)
48+
49+
- You may get this URL from here in your Container App.
50+
![configure_app_registration_web_5](./Images/configure_app_registration_web_5.png)
51+
52+
2. Add Permission and Grant Permission
53+
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+
![configure_app_registration_web_6](./Images/configure_app_registration_web_6.png)
56+
![configure_app_registration_web_7](./Images/configure_app_registration_web_7.png)
57+
58+
- Grant admin consent to permissions.
59+
![configure_app_registration_web_8](./Images/configure_app_registration_web_8.png)
60+
61+
3. Grab Scope Name for Impersonation
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+
![configure_app_registration_web_9](./Images/configure_app_registration_web_9.png)
66+
67+
4. Grab Client Id for Web App
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+
![configure_app_registration_web_10](./Images/configure_app_registration_web_10.png)
72+
73+
## Step 3: Configure Application Registration - API Application
74+
75+
1. Grab Scope Name for Impersonation
76+
77+
- Go to deployed Container App `ca-<your environment>-<randomname>-api` and select **Authentication** menu, then select created Application Registration.
78+
![configure_app_registration_api_1](./Images/configure_app_registration_api_1.png)
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+
![configure_app_registration_api_2](./Images/configure_app_registration_api_2.png)
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+
![add_client_id_to_api_1](./Images/add_client_id_to_api_1.png)
88+
89+
2. Select **Allow requests from specific client applications**, then click the **pencil** icon to add the Client Id.
90+
![add_client_id_to_api_2](./Images/add_client_id_to_api_2.png)
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+
![add_client_id_to_web_3](./Images/add_client_id_to_web_3.png)
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+
![update_env_app_1](./Images/update_env_app_1.png)
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.
97106

98107
## Conclusion
108+
99109
You have successfully configured the front-end and back-end Azure App Registrations with proper API permissions and security settings.

docs/ConfigureAppAuthentication_withImage.md

Lines changed: 0 additions & 109 deletions
This file was deleted.

docs/DeploymentGuide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ This will rebuild the source code, package it into a container, and push it to t
247247
```
248248
249249
3. **Add Authentication Provider**
250-
- Follow steps in [App Authentication](./ConfigureAppAuthentication_withImage.md) to configure authenitcation in app service. Note that Authentication changes can take up to 10 minutes.
250+
- Follow steps in [App Authentication](./ConfigureAppAuthentication.md) to configure authenitcation in app service. Note that Authentication changes can take up to 10 minutes.
251251
252252
4. **Deleting Resources After a Failed Deployment**
253253

infra/deploy_ai_foundry.bicep

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Creates Azure dependent resources for Azure AI studio
22
param solutionName string
33
param solutionLocation string
4-
@secure()
54
param keyVaultName string
65
param cuLocation string
76
param deploymentType string
@@ -10,11 +9,8 @@ param gptModelVersion string
109
param gptDeploymentCapacity int
1110
// param embeddingModel string
1211
// param embeddingDeploymentCapacity int
13-
@secure()
1412
param managedIdentityObjectId string
15-
@secure()
1613
param applicationInsightsId string
17-
@secure()
1814
param containerRegistryId string
1915

2016
// Load the abbrevations file required to name the azure resources.

0 commit comments

Comments
 (0)