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 8d3edb0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/backend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,16 @@ 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()
if AZURE_CLIENT_ID := os.getenv("AZURE_CLIENT_ID"):
# ManagedIdentityCredential should use AZURE_CLIENT_ID if set in env, but its not working for some reason,
# so we explicitly pass it in as the client ID here. This is necessary for user-assigned managed identities.
current_app.logger.info(
"Setting up Azure credential using ManagedIdentityCredential with client_id %s", AZURE_CLIENT_ID
)
azure_credential = ManagedIdentityCredential(client_id=AZURE_CLIENT_ID)
else:
current_app.logger.info("Setting up Azure credential using ManagedIdentityCredential")
azure_credential = ManagedIdentityCredential()
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 8d3edb0

Please sign in to comment.