DefaultAzureCredential failure could be more explicit, give breadcrumbs to fix.
Currently the failure reads as follows, if no env vars are populated:
azure.core.exceptions.ClientAuthenticationError: No valid token received. EnvironmentCredential: Incomplete environment configuration.. ImdsCredential: IMDS endpoint unavailable
This was not particularly enlightening to me, and made me expect that I had broken something/specified an endpoint wrong/had some network cut. The documentation ended up being perfectly clear (Here was good, Here was even better) so perhaps we could give a breadcrumb to that if nothing else.
My naïve fix would likely include a get_token wrapper at the DefaultAzureCredential level to catch the ClientAuthenticationError and supplement the message with a brief description of the nature of the credential (chaining) and perhaps a breadcrumb to our documentation. If this seems reasonable feel free to simply reassign the issue to me and I'll gladly implement.
To call out very clearly the Before/After for @mayurid: Before: azure.core.exceptions.ClientAuthenticationError: No valid token received. EnvironmentCredential: Incomplete environment configuration.. ImdsCredential: IMDS endpoint unavailable After: azure.core.exceptions.ClientAuthenticationError: Chained credential request has failed, no valid token received. Attempted credentials: EnvironmentCredential: Incomplete environment configuration. ImdsCredential: IMDS endpoint unavailable
Please visit the Azure identity Python SDK docs at https://aka.ms/python-sdk-identity#defaultazurecredential to learn what options defaultAzureCredential supports
Thanks for raising this, I'd also like a better error message there. Your fix sounds reasonable so please, go for it. Do you think the message produced by ChainedTokenCredential (which is what you've seen) is acceptable in general?
I slept on that question, and came back with the following. The existing message contained the useful bits, but might benefit from a slight bit of context.
See PR below, feel free to throw rocks. The one thing I hadn't fully settled on was whether there was precedents for urls (do we have an shortlink or something?) or if the human readable guidance was sufficient.
https://github.com/Azure/azure-sdk-for-python/pull/8109