DefaultAzureCredential failed to retrieve a token from the included credentials / ManagedIdentityCredential authentication unavailable
The Azure SDK tried every credential source (env vars, workload identity, managed identity, CLI…) and none worked.
Seen on:
Azure
Meaning
Locally it usually means you’re not logged in to Azure CLI/VS; in Azure it means managed identity isn’t enabled on the resource, or the env vars for a service principal are incomplete. The message lists why each credential failed.
Common causes
- Managed identity not enabled on the App Service/VM/Container App
- Local machine not signed in to Azure CLI/VS Code
- AZURE_CLIENT_ID/TENANT_ID/SECRET partially set
- User-assigned identity without AZURE_CLIENT_ID
⚡ Quick fix
- Enable managed identity and grant it roles
- Locally run az login
- Set AZURE_CLIENT_ID for user-assigned identities; remove half-set env vars
Detailed fix by platform
Azure CLI
- bash
az webapp identity assign -g rg-app -n my-api az role assignment create --assignee <principal-id> --role "Key Vault Secrets User" --scope <vault-id>
Python
- python
from azure.identity import DefaultAzureCredential cred = DefaultAzureCredential(logging_enable=True) # logs each credential attempt
How to diagnose
- Attempts — Per-credential failure lines
- Identity — Enabled on the resource?
- Env — AZURE_* variables
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in Azure
- AuthorizationPermissionMismatch Azure Storage: AuthorizationPermissionMismatch (403) — This request is not authorized to perform this operation using this permission
- App Service Application Error Azure App Service: ":( Application Error" / container didn’t respond to HTTP pings
- SkuNotAvailable Azure: SkuNotAvailable / QuotaExceeded when creating a VM or resource
Other ways to find it
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 7 Oct 2026