Skip to content

Commit

Permalink
Update ManagedIdentityCredential to use UAMI for containerapps
Browse files Browse the repository at this point in the history
  • Loading branch information
1yefuwang1 committed Sep 18, 2024
1 parent 5682b67 commit fa57654
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/backend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ async def setup_clients():
AZURE_ENABLE_UNAUTHENTICATED_ACCESS = os.getenv("AZURE_ENABLE_UNAUTHENTICATED_ACCESS", "").lower() == "true"
AZURE_SERVER_APP_ID = os.getenv("AZURE_SERVER_APP_ID")
AZURE_SERVER_APP_SECRET = os.getenv("AZURE_SERVER_APP_SECRET")
AZURE_CLIENT_ID = os.getenv("AZURE_CLIENT_ID")
AZURE_CLIENT_APP_ID = os.getenv("AZURE_CLIENT_APP_ID")
AZURE_AUTH_TENANT_ID = os.getenv("AZURE_AUTH_TENANT_ID", AZURE_TENANT_ID)

Expand Down Expand Up @@ -449,7 +450,11 @@ async def setup_clients():
azure_credential: Union[AzureDeveloperCliCredential, ManagedIdentityCredential]
if RUNNING_ON_AZURE:
current_app.logger.info("Setting up Azure credential using ManagedIdentityCredential")
azure_credential = ManagedIdentityCredential()
azure_credential = (
ManagedIdentityCredential()
if AZURE_CLIENT_ID is None
else ManagedIdentityCredential(client_id=AZURE_CLIENT_ID)
)
elif AZURE_TENANT_ID:
current_app.logger.info(
"Setting up Azure credential using AzureDeveloperCliCredential with tenant_id %s", AZURE_TENANT_ID
Expand Down

0 comments on commit fa57654

Please sign in to comment.