Skip to content

Commit 8ac235b

Browse files
Merge pull request #14 from microsoft/dev
fix: Handled logging and updated authentication set up
2 parents 55a554a + 474127f commit 8ac235b

File tree

5 files changed

+26
-14
lines changed

5 files changed

+26
-14
lines changed

docs/ConfigureAppAuthentication.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ We will add Microsoft Entra ID as an authentication provider to API and Web Appl
1313

1414
1. Add Authentication Provider in Web Application
1515

16-
- Go to deployed Container App and select `ca-<randomname>-web` and click **Add Identity Provider** button in Authentication.
16+
- Go to deployed Container App and select `ca-cps-<randomname>-web` and click **Add Identity Provider** button in Authentication.
1717
![add_auth_provider_web_1](./Images/add_auth_provider_web_1.png)
1818

1919
- Select **Microsoft** and set **Client secret expiration**, then click **Add** button.
2020
![add_auth_provider_web_2](./Images/add_auth_provider_web_2.png)
2121

2222
2. Add Authentication Provider in API Service
2323

24-
- Go to deployed Container App and select `ca-<randomname>-api` and click **Add Identity Provider** button in Authentication.
24+
- Go to deployed Container App and select `ca-cps-<randomname>-api` and click **Add Identity Provider** button in Authentication.
2525
![add_auth_provider_api_1](./Images/add_auth_provider_api_1.png)
2626

2727
- Select **Microsoft** and set **Client secret expiration**.
@@ -34,7 +34,7 @@ We will add Microsoft Entra ID as an authentication provider to API and Web Appl
3434

3535
1. Set Redirect URI in Single Page Application Platform
3636

37-
- Go to deployed Container App `ca-<randomname>-web` and select **Authentication** menu, then select created Application Registration.
37+
- Go to deployed Container App `ca-cps-<randomname>-web` and select **Authentication** menu, then select created Application Registration.
3838
![configure_app_registration_web_1](./Images/configure_app_registration_web_1.png)
3939

4040
- Select **Authentication**, then select **+ Add a platform** menu.
@@ -43,15 +43,15 @@ We will add Microsoft Entra ID as an authentication provider to API and Web Appl
4343
- Select **Single-page application**.
4444
![configure_app_registration_web_3](./Images/configure_app_registration_web_3.png)
4545

46-
- Add Container App `ca-<randomname>-web`'s URL.
46+
- Add Container App `ca-cps-<randomname>-web`'s URL.
4747
![configure_app_registration_web_4](./Images/configure_app_registration_web_4.png)
4848

4949
- You may get this URL from here in your Container App.
5050
![configure_app_registration_web_5](./Images/configure_app_registration_web_5.png)
5151

5252
2. Add Permission and Grant Permission
5353

54-
- Add Permission for API application. Select **+ Add a permission** button, then search API application with name `ca-<your environment name>-<unique string>-api`.
54+
- Add Permission for API application. Select **+ Add a permission** button, then search API application with name `ca-cps-<randomname>-api`.
5555
![configure_app_registration_web_6](./Images/configure_app_registration_web_6.png)
5656
![configure_app_registration_web_7](./Images/configure_app_registration_web_7.png)
5757

@@ -74,7 +74,7 @@ We will add Microsoft Entra ID as an authentication provider to API and Web Appl
7474

7575
1. Grab Scope Name for Impersonation
7676

77-
- Go to deployed Container App `ca-<randomname>-api` and select **Authentication** menu, then select created Application Registration.
77+
- Go to deployed Container App `ca-cps-<randomname>-api` and select **Authentication** menu, then select created Application Registration.
7878
![configure_app_registration_api_1](./Images/configure_app_registration_api_1.png)
7979

8080
- Select **Expose an API** in the left menu. Copy the Scope name, then paste it in some temporary place.
@@ -83,11 +83,11 @@ We will add Microsoft Entra ID as an authentication provider to API and Web Appl
8383

8484
## Step 4: Add Web Application's Client Id to Allowed Client Applications List in API Application Registration
8585

86-
1. Go to the deployed Container App `ca-<randomname>-api`, select **Authentication**, and then click **Edit**.
87-
![add_client_id_to_web_1](./Images/add_client_id_to_web_1.png)
86+
1. Go to the deployed Container App `ca-cps-<randomname>-api`, select **Authentication**, and then click **Edit**.
87+
![add_client_id_to_api_1](./Images/add_client_id_to_api_1.png)
8888

8989
2. Select **Allow requests from specific client applications**, then click the **pencil** icon to add the Client Id.
90-
![add_client_id_to_web_2](./Images/add_client_id_to_web_2.png)
90+
![add_client_id_to_api_2](./Images/add_client_id_to_api_2.png)
9191

9292
3. Add the **Client Id** obtained from [Step 2: Configure Application Registration - Web Application](#step-2-configure-application-registration---web-application), then save.
9393
![add_client_id_to_web_3](./Images/add_client_id_to_web_3.png)
@@ -101,7 +101,7 @@ Now, we will edit and deploy the Web Application Container with updated Environm
101101
1. Select **Containers** menu under **Application**. Then click **Environment variables** tab.
102102
![update_env_app_1_1](./Images/update_env_app_1_1.png)
103103
2. Update 3 values which were taken in previous steps for **APP_MSAL_AUTH_CLIENT_ID**, **APP_MSAL_AUTH_SCOPE**, **APP_MSAL_TOKEN_SCOPE**.
104-
Click on **Save as a new revision**
104+
Click on **Save as a new revision**.
105105
The updated revision will be activated soon.
106106

107107
## Conclusion

docs/DeploymentGuide.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ You can run this solution in VS Code Dev Containers, which will open the project
7777
If you're not using one of the above options for opening the project, then you'll need to:
7878

7979
1. Make sure the following tools are installed:
80-
80+
- [PowerShell](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell?view=powershell-7.5) <small>(v7.0+)</small> - available for Windows, macOS, and Linux.
8181
- [Azure Developer CLI (azd)](https://aka.ms/install-azd)
8282
- [Python 3.9+](https://www.python.org/downloads/)
8383
- [Docker Desktop](https://www.docker.com/products/docker-desktop/)
@@ -172,8 +172,12 @@ If you need to rebuild the source code and push the updated container to the dep
172172
```powershell
173173
$env:USE_LOCAL_BUILD = $true
174174
```
175+
2. Run the `az login` command
176+
```bash
177+
az login
178+
```
175179
176-
2. Run the `azd up` command again to rebuild and push the updated container:
180+
3. Run the `azd up` command again to rebuild and push the updated container:
177181
```bash
178182
azd up
179183
```
167 KB
Loading
154 KB
Loading

src/ContentProcessorAPI/app/appsettings.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ class AppConfiguration(ModelBaseSettings):
2929
app_cps_processes: str
3030
app_message_queue_extract: str
3131
app_cps_max_filesize_mb: int
32+
app_logging_enable: bool
33+
app_logging_level: str
3234

33-
34-
logging.basicConfig(level=logging.DEBUG)
3535
# Read .env file
3636
# Get Current Path + .env file
3737
env_file_path = os.path.join(os.path.dirname(__file__), ".env")
@@ -44,6 +44,14 @@ class AppConfiguration(ModelBaseSettings):
4444

4545
app_config = AppConfiguration()
4646

47+
if app_config.app_logging_enable:
48+
# Read Configuration for Logging Level as a Text then retrive the logging level
49+
logging_level = getattr(
50+
logging, app_config.app_logging_level
51+
)
52+
logging.basicConfig(level=logging_level)
53+
else:
54+
logging.disable(logging.CRITICAL)
4755

4856
# Dependency Function
4957
def get_app_config() -> AppConfiguration:

0 commit comments

Comments
 (0)