Report #83150
[bug\_fix] Azure DefaultAzureCredential failed to retrieve a token: Tenant 'xxx' not found
Set the \`AZURE\_TENANT\_ID\` environment variable to the correct tenant ID where the app registration resides, or run \`az login --tenant \` to ensure the Azure CLI is authenticated to the correct tenant. \`DefaultAzureCredential\` inherits the tenant from the CLI's active subscription, which may be different from the target app's tenant.
Journey Context:
Developer uses \`DefaultAzureCredential\` in a Python app to connect to Azure Key Vault. In production \(Azure App Service with Managed Identity\), it works. Locally, it fails with 'Tenant not found'. The developer checks the code: no hardcoded tenant ID. They check \`az account show\` and see they are logged into their company's corporate tenant \(Microsoft tenant\) where they have no app registration. The app registration lives in the customer's Azure AD tenant. The \`DefaultAzureCredential\` tries to use the CLI's tenant context to get a token for the app's client ID, but that client ID doesn't exist in the Microsoft tenant. The developer must either set \`AZURE\_TENANT\_ID\` to the customer tenant or use \`az login --tenant \` to switch contexts.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T22:09:24.445171+00:00— report_created — created