Why would DefaultAzureCredential not find Visual Studio when I have 3 versions installed?
See original GitHub issueLibrary name and version
Azure.Identity 1.5.0
Query/Question
We have tests that rely on DefaultAzureCredential to access Azure Key Vault. On one of my on-premises VMs the tests can’t get a credential, even though I am running the test in Visual Studio 2022. VS is logged in to Azure. How do I figure out why it’s not seeing VS? VS 2022 doesn’t have an “Azure Service Authentication” setting in Tools/Options.
Message:
Test method Microsoft.SqlServer.Test.SMO.GeneralFunctionality.DatabaseSmoTests.Database_transaction_counts threw exception:
Azure.Identity.CredentialUnavailableException: 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
- EnvironmentCredential authentication unavailable. Environment variables are not fully configured. See the troubleshooting guide for more information. https://aka.ms/azsdk/net/identity/environmentcredential/troubleshoot
- ManagedIdentityCredential authentication unavailable. Multiple attempts failed to obtain a token from the managed identity endpoint.
- No installed instance of Visual Studio was found
- 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
- Azure CLI not installed
- PowerShell is not installed. ---> System.AggregateException: Multiple exceptions were encountered while attempting to authenticate. ---> Azure.Identity.CredentialUnavailableException: EnvironmentCredential authentication unavailable. Environment variables are not fully configured. See the troubleshooting guide for more information. https://aka.ms/azsdk/net/identity/environmentcredential/troubleshoot
Stack Trace:
...
---> (Inner Exception #2) Azure.Identity.CredentialUnavailableException: No installed instance of Visual Studio was found
at Azure.Identity.VisualStudioCredential.<GetTokenImplAsync>d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Azure.Identity.CredentialDiagnosticScope.FailWrapAndThrow(Exception ex, String additionalMessage)
at Azure.Identity.VisualStudioCredential.<GetTokenImplAsync>d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Runtime.CompilerServices.ValueTaskAwaiter`1.GetResult()
at Azure.Core.Pipeline.TaskExtensions.EnsureCompleted[T](ValueTask`1 task)
at Azure.Identity.VisualStudioCredential.GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken)
at Azure.Identity.DefaultAzureCredential.<GetTokenFromSourcesAsync>d__15.MoveNext()<---
Environment
Windows 10 with VS 2022 17.2 and VS 2019 16.11.13 VS has my Azure account synced across all devices.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
DefaultAzureCredential in Visual Studio dev fails to find a ...
1 Answer 1 ... In Visual Studio, you set the account in the options/Azure Service Authentication/Account Selection ok. If you debug locally and ......
Read more >Azure Identity client library for .NET
It's a known issue that VisualStudioCodeCredential doesn't work with Azure Account extension versions newer than 0.9.11. A long-term fix to this ...
Read more >unable to access azure secret once i publish
I have an aspnetcore web app and am using Azure Vault Secrets to store an MSSQL connection string. I have set up the...
Read more >ManagedIdentityCredential authentication unavailable, no ...
I have signin to Visual Studio and I have admin access to resources. DefaultAzureCredential failed to retrieve a token from the included ......
Read more >Azure Identity Plugin for Visual Studio Code Authentication
To do so, open Visual Studio Code, ensure that the extension is installed, and sign in from Command Palette using the "Azure: Sign...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In my case it was the missing Azure Development workload
Hi @shueybubbles - Could it be related to which user account is being used? The VS credential relies on this file to find the token provider:
Users\<user>\AppData\Local\.IdentityService\AzureServiceAuth\tokenprovider.json
Does the user profile that is running the code have this file?