Issue
I am attempting to run a .NET 6.0 project locally on my Ubuntu machine using rider. The project using the DefaultAzureCredential class but when I trying running it gives the following error
"DefaultAzureCredential failed to retrieve a token from the included credentials. See the troubleshooting guide for more information. https://aka.ms/azsdk/net/identity/defaultazurecredential/troubleshoot\n- EnvironmentCredential authentication unavailable. Environment variables are not fully configured. See the troubleshooting guide for more information. https://aka.ms/azsdk/net/identity/environmentcredential/troubleshoot\n- ManagedIdentityCredential authentication unavailable. Multiple attempts failed to obtain a token from the managed identity endpoint.\n- Operating system Linux 5.19.0-26-generic #27-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 23 20:44:15 UTC 2022 isn't supported.\n- Stored credentials not found. Need to authenticate user in VSCode Azure Account. See the troubleshooting guide for more information. https://aka.ms/azsdk/net/identity/vscodecredential/troubleshoot\n- Please run 'az login' to set up account\n- PowerShell is not installed."
I tried installing the Azure Cli and using az login which logs me in successfully but that does not resolve the error. I also tried installing the Azure Toolkit in rider and signing in through that with a 'device code'. Again that works successfully but when running the application I still getting the same issue.
This same project work fine using rider or visual studio in Windows, so it seems to be something about this class being unable to consume credentials on my Linux machine that is not a problem when using a Windows.
Solution
By default AzureCliCredential should read the credentials from $HOME/.azure
so it should be able to read it. Maybe values of $HOME
or $AZURE_CONFIG_DIR
differ (do you run app as a root maybe? Or in some container?)
I'd suggest setting includeInteractiveCredentials
to true
in constructor:
new DefaultAzureCredential(true)
This way, if credentials are not found, it should open a browser to allow authentication
Answered By - karolgro Answer Checked By - Terry (WPSolving Volunteer)