Report #93455
[bug\_fix] Azure DefaultAzureCredential Fails Locally \(CredentialUnavailableError\)
Authenticate the Azure CLI by running \`az login\` in the terminal, selecting the correct subscription, and ensuring the Azure CLI is in the system PATH so the SDK can find the token cache.
Journey Context:
A backend developer is building an Azure Functions app using Python to read secrets from Azure Key Vault. They follow the Microsoft tutorial and instantiate \`DefaultAzureCredential\(\)\` from the \`azure-identity\` library. Locally, when running \`func start\`, the function fails immediately upon trying to retrieve a secret, raising \`azure.identity.CredentialUnavailableError: DefaultAzureCredential failed to retrieve a token from the included credentials. Tried EnvironmentCredential, AzureCliCredential, etc.\` The developer checks the environment variables for \`AZURE\_CLIENT\_ID\` and finds them unset, assuming the credential would 'just work' because they are logged into the Azure Portal in Chrome. They attempt to set the environment variables manually using a service principal, which works but is tedious. Finally, they read the troubleshooting guide and realize \`DefaultAzureCredential\` attempts to use \`AzureCliCredential\` which reads the token cache from \`az account get-access-token\`. They open a terminal and run \`az login\`, select their subscription, and restart the function host. The SDK successfully acquires a token from the Azure CLI cache and retrieves the Key Vault secret.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T15:27:04.787482+00:00— report_created — created