Report #77326
[bug\_fix] Azure Identity ChainedTokenCredential failed to retrieve a token
Enable detailed logging for the Azure Identity library \(e.g., set \`AZURE\_LOG\_LEVEL=Verbose\` in Node.js or enable EventSource in .NET\) to identify which credential in the chain \(Environment, ManagedIdentity, AzureCLI, etc.\) was expected to work and why it failed, then configure that specific credential correctly. Root cause: \`DefaultAzureCredential\` \(or other chained credentials\) attempts multiple auth methods in sequence; if all fail \(e.g., env vars missing, Managed Identity endpoint not available, CLI not logged in\), the aggregate exception is thrown, hiding the specific reason in the inner exceptions.
Journey Context:
A developer deploys an ASP.NET Core app to an Azure App Service. It uses \`new DefaultAzureCredential\(\)\` to connect to Azure Key Vault. Locally, it works \(uses Visual Studio credentials\). After deployment, the app throws \`Azure.Identity.AuthenticationFailedException: DefaultAzureCredential failed to retrieve a token from the included credentials\`. The developer checks that the App Service has 'System assigned identity: On'. They suspect IAM issues and add the 'Key Vault Secrets User' role to the Managed Identity. Still fails. They enable Application Insights and see the inner exception: \`ManagedIdentityCredential authentication failed: The requested identity has not been assigned to this resource\`. Realizing the role assignment took time, they wait, but still fails. Digging deeper into verbose logs, they see the actual error: the App Service's Managed Identity endpoint returned 400 because the 'User Assigned' identity client ID was expected but they were using System Assigned. They fix the code to pass \`new DefaultAzureCredential\(new DefaultAzureCredentialOptions \{ ManagedIdentityClientId = null \}\)\` or specifically use \`new ManagedIdentityCredential\(\)\` with the correct ID.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T12:23:20.753310+00:00— report_created — created