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.

[BUG] DefaultAzureCredential VisualStudioCredential unable to retrieve an access token.

See original GitHub issue

Library name and version

Azure.Identity.DefaultAzureCredential

Describe the bug

I am attempting to authenticate to Azure using the DefaultAzureCredential in my program. However, after I create the DefaultAzureCredential attempt to use it, I receive an error stating that the VisualStudioCredential.GetToken was unable to retrieve an access token.

var options = new DefaultAzureCredentialOptions()
{
    ExcludeAzureCliCredential = true,
    ExcludeAzurePowerShellCredential = true,
    ExcludeEnvironmentCredential = true,
    ExcludeInteractiveBrowserCredential = true,
    ExcludeManagedIdentityCredential = true,
    ExcludeSharedTokenCacheCredential = true,
    ExcludeVisualStudioCodeCredential = true,
    ExcludeVisualStudioCredential = false
};

var cred = new DefaultAzureCredential(options);

When I attempt to actually use the token, I receive this exception:

Azure-Identity: VisualStudioCredential.GetToken was unable to retrieve an access token. Scopes: [ user_impersonation ] 
ParentRequestId: <id> Exception: Azure.Identity.CredentialUnavailableException (0x80131500): 
Process "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\Extensions\fc0rxpqz.bks\TokenService\Microsoft.Asal.TokenService.exe" 
has failed with unexpected error: TS003: Error, TS007: resource parameter must be a URI or a GUID.

Expected behavior

Successfully authenticate and interact with Azure resources.

Actual behavior

Receive an exception stating ‘VisualStudioCredential.GetToken was unable to retrieve an access token’.

Reproduction Steps

  1. Open VS 2022
  2. Create new console project
  3. Create new DefaultAzureCredential
  4. Attempt to interact with Azure resources

Environment

Windows 11 .NET 6 Visual Studio 2022

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jsquirecommented, Jun 29, 2022

Thank you for your feedback. Tagging and routing to the team member best able to assist.

0reactions
msftbot[bot]commented, Nov 11, 2022

Hi, we’re sending this friendly reminder because we haven’t heard back from you in 7 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don’t hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

DefaultAzureCredential failed to retrieve a token
If you try to retrieve a value from Azure Key Vault, you may run into this error: “DefaultAzureCredential failed to retrieve a token...
Read more >
Steps to resolve “DefaultAzureCredential failed to retrieve a ...
Multiple attempts failed to obtain a token from the managed identity endpoint. ... error: TS003: Error, TS004: Unable to get access token.
Read more >
Azure.Identity.CredentialUnavailableException: ...
Identity.CredentialUnavailableException: DefaultAzureCredential failed to retrieve a token from the included credentials EnvironmentCredential ...
Read more >
Azure Identity 201 - DefaultAzureCredential Options
We wanted to make it brain-dead simple for you to authenticate your apps with Azure. Auth can be very hard to get right....
Read more >
DefaultAzureCredential failed to retrieve a token from the ...
Resolution to "[CredentialUnavailableException: DefaultAzureCredential failed to retrieve a token from the included credentials." in Visual ...
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