Azure / Azure/azure-cli

failed to retrieve a token from the included credential

Open
#31,648 3 comments 0 reactions 1 assignee Claimed by @jiasli View on GitHub
Account act-identity-squad Auto-Assign customer-reported Possible-Solution question SDK Issue Similar-Issue
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

### Describe the bug

I randomly get this error message:

DefaultAzureCredential failed to retrieve a token from the included credentials. Attempted credentials: EnvironmentCredential: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.

When I do the az login command, I can authenticate fine for about 24 hours, then this error starts popping up again until i reauthenticate.

### Related command

credential = DefaultAzureCredential()

### Errors

stderr='DefaultAzureCredential failed to retrieve a token from the included credentials.\nAttempted credentials:\n\tEnvironmentCredential: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.\nVisit https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Faka.ms%2Fazsdk%2Fpython%2Fidentity%2Fenvironmentcredential%2Ftroubleshoot&data=05%7C02%7Cjrothwell%40coresupply.com%7Cd4fb3d9212e840f3415608dda41814ea%7Ccced47230796475dbff35e9b6ad87138%7C1%7C0%7C638847145518905760%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=xyWBYIBKifS8MNh%2B%2BaERvJ5YnRbKcjJqOPPXkn6GSCU%3D&reserved=0 to troubleshoot this issue.\n\tManagedIdentityCredential: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint. invalid_request\n\tSharedTokenCacheCredential: SharedTokenCacheCredential authentication unavailable. No accounts were found in the cache.\n\tAzureCliCredential: Failed to invoke the Azure CLI\n\tAzurePowerShellCredential: PowerShell is not installed\n\tAzureDeveloperCliCredential: Azure Developer CLI could not be found. Please visit https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Faka.ms%2Fazure-dev&data=05%7C02%7Cjrothwell%40coresupply.com%7Cd4fb3d9212e840f3415608dda41814ea%7Ccced47230796475dbff35e9b6ad87138%7C1%7C0%7C638847145518920733%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=IdH%2BwBhP7MhHPUfwlQ6dBCnih4bc0yzaJnnRhVNZkjw%3D&reserved=0 for installation instructions and then,once installed, authenticate to your Azure account using \'azd auth login\'.\nTo mitigate this issue, please refer to the troubleshooting guidelines here at https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Faka.ms%2Fazsdk%2Fpython%2Fidentity%2Fdefaultazurecredential%2Ftroubleshoot.%2FnDefaultAzureCredential&data=05%7C02%7Cjrothwell%40coresupply.com%7Cd4fb3d9212e840f3415608dda41814ea%7Ccced47230796475dbff35e9b6ad87138%7C1%7C0%7C638847145518930145%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=JccXhrgCiL4QDtKhklNPjIdnYlYxpLH%2BKLeMJWvdkcU%3D&reserved=0 failed to retrieve a token from the included credentials.\nAttempted credentials:\n\tEnvironmentCredential: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.\nVisit https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Faka.ms%2Fazsdk%2Fpython%2Fidentity%2Fenvironmentcredential%2Ftroubleshoot&data=05%7C02%7Cjrothwell%40coresupply.com%7Cd4fb3d9212e840f3415608dda41814ea%7Ccced47230796475dbff35e9b6ad87138%7C1%7C0%7C638847145518939672%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=ae20nUe%2BNZlHvxNgC8hKib7ZI9rFgTzd9MMVXSyjoXI%3D&reserved=0 to troubleshoot this issue.\n\tManagedIdentityCredential: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint. invalid_request\n\tSharedTokenCacheCredential: SharedTokenCacheCredential authentication unavailable. No accounts were found in the cache.\n\tAzureCliCredential: Please run \'az login\' to set up an account\n\tAzurePowerShellCredential: PowerShell is not installed\n\tAzureDeveloperCliCredential: Azure Developer CLI could not be found. Please visit https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Faka.ms%2Fazure-dev&data=05%7C02%7Cjrothwell%40coresupply.com%7Cd4fb3d9212e840f3415608dda41814ea%7Ccced47230796475dbff35e9b6ad87138%7C1%7C0%7C638847145518949473%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=I3iXgq3LHMhRy%2Feh4S3hcgZiWvc8Sfld14WXhyGkdvw%3D&reserved=0 for installation instructions and then,once installed, authenticate to your Azure account using \'azd auth login\'.\nTo mitigate this issue, please refer to the troubleshooting guidelines here at https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Faka.ms%2Fazsdk%2Fpython%2Fidentity%2Fdefaultazurecredential%2Ftroubleshoot.%2FnDefaultAzureCredential&data=05%7C02%7Cjrothwell%40coresupply.com%7Cd4fb3d9212e840f3415608dda41814ea%7Ccced47230796475dbff35e9b6ad87138%7C1%7C0%7C638847145518958620%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=sm8suO3o5bRq1NzPsU7whu5aSXw3LPSdAIwTHVxqp44%3D&reserved=0 failed to retrieve a token from the included credentials.\nAttempted credentials:\n\tEnvironmentCredential: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.\nVisit https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Faka.ms%2Fazsdk%2Fpython%2Fidentity%2Fenvironmentcredential%2Ftroubleshoot&data=05%7C02%7Cjrothwell%40coresupply.com%7Cd4fb3d9212e840f3415608dda41814ea%7Ccced47230796475dbff35e9b6ad87138%7C1%7C0%7C638847145518967944%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=EYcUbng2GS%2FCGiJotwLCqSKVL03nzoXJ%2B%2Fq8exVFK8Y%3D&reserved=0 to troubleshoot this issue.\n\tManagedIdentityCredential: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint. invalid_request\n\tSharedTokenCacheCredential: SharedTokenCacheCredential authentication unavailable. No accounts were found in the cache.\n\tAzureCliCredential: Please run \'az login\' to set up an account\n\tAzurePowerShellCredential: PowerShell is not installed\n\tAzureDeveloperCliCredential: Azure Developer CLI could not be found. Please visit https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Faka.ms%2Fazure-dev&data=05%7C02%7Cjrothwell%40coresupply.com%7Cd4fb3d9212e840f3415608dda41814ea%7Ccced47230796475dbff35e9b6ad87138%7C1%7C0%7C638847145518977778%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=kwqFmZauNxE6Xyin9jAKrsxuMjlT1mgXPSFmxSKntHM%3D&reserved=0 for installation instructions and then,once installed, authenticate to your Azure account using \'azd auth login\'.\nTo mitigate this issue, please refer to the troubleshooting guidelines here at https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Faka.ms%2Fazsdk%2Fpython%2Fidentity%2Fdefaultazurecredential%2Ftroubleshoot.%2FnDefaultAzureCredential&data=05%7C02%7Cjrothwell%40coresupply.com%7Cd4fb3d9212e840f3415608dda41814ea%7Ccced47230796475dbff35e9b6ad87138%7C1%7C0%7C638847145518987028%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=PFtoO%2Bo0dzcoTV4Hh%2Fw3wo%2FtPrhTthB178YaNWJYLeg%3D&reserved=0 failed to retrieve a token from the included credentials.\nAttempted credentials:\n\tEnvironmentCredential: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.\nVisit

### Issue script & Debug output

N/A expected behavior comes after azure cli is authenticated.

### Expected behavior

Authentication to azure blob storage to upload files via python.

### Environment Summary

azure-cli 2.74.0

core 2.74.0
telemetry 1.1.0

Dependencies:
msal 1.32.3
azure-mgmt-resource 23.3.0

Python location 'C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe'
Config directory 'C:\Users\tpegge\.azure'
Extensions directory 'C:\Users\tpegge\.azure\cliextensions'

Python (Windows) 3.12.10 (tags/v3.12.10:0cc8128, Apr 8 2025, 12:21:36) [MSC v.1943 64 bit (AMD64)]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

### Additional context

This is executed via a python script.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.