question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Why would DefaultAzureCredential not find Visual Studio when I have 3 versions installed?

See original GitHub issue

Library 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.

image

  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:closed
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
shueybubblescommented, Aug 9, 2022

In my case it was the missing Azure Development workload

0reactions
christothescommented, Aug 5, 2022

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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found