[BUG] DefaultAzureCredential VisualStudioCredential unable to retrieve an access token.
See original GitHub issueLibrary 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
- Open VS 2022
- Create new console project
- Create new
DefaultAzureCredential
- Attempt to interact with Azure resources
Environment
Windows 11 .NET 6 Visual Studio 2022
Issue Analytics
- State:
- Created a year ago
- Comments:9 (4 by maintainers)
Top 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 >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
Thank you for your feedback. Tagging and routing to the team member best able to assist.
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!