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] VisualStudioCredential fails with AADSTS65002

See original GitHub issue

Library name and version

Azure.Identity 1.4.0 or later

Describe the bug

Looks like #8945 came back again for Azure.Identity 1.4.0 or later. The DefaultAzureCredential stopped falling back to other credentials after it failed with the ManagedIdentityCredential.

Here is the exception message

Unhandled 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. The requested identity has not been assigned to this resource.
Status: 400 (Bad Request)

Content:
{"error":"invalid_request","error_description":"Identity not found"}

Note that this happens on a VM from the DevTest lab. The fact that it’s an Azure VM may have confused the library. When I downgraded Azure.Identity to 1.3.0 or earlier, everything worked like a charm.

Expected behavior

DefaultAzureCredential falls back to other credentials after failing with ManagedIdentityCredential

Actual behavior

DefaultAzureCredential doesn’t fall back to other credentials after failing with ManagedIdentityCredential

Reproduction Steps

Use DefaultAzureCredential on an Azure VM from the DevTest lab.

Environment

Windows 11, VS 17.4.0 Preview, .NET 6 app

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
zhenlancommented, Oct 25, 2022

Updated Visual Studio to Version 17.5.0 Preview 1.0 [33024.329.main]. The DefaultAzureCredential worked again with Azure.Identity v1.7.0.

1reaction
zhenlancommented, Sep 9, 2022

I was using Visual Studio, so I would expect VisualStudioCredential or SharedTokenCacheCredential. I don’t know what is actually used when it was working with the older version of the package.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] DefaultAzureCredential VisualStudioCredential ...
I am attempting to authenticate to Azure using the DefaultAzureCredential in my program. However, after I create the DefaultAzureCredential ...
Read more >
c# - Visual Studio 2019 TokenService.exe has failed with ...
Was finally able to get the Visual Studio credential working -- HOWEVER, it requires supplying the tenant ID. The modified code is: Microsoft....
Read more >
What's the best way to report a bug?
I believe I have found a bug in the Azure Portal UI but how do I report this without incurring the cost of...
Read more >
Visual Studio Publish To Azure With Microsoft Identity Platform ...
Error when deploying my Visual Studio project zip file to azure "The command failed with an unexpected error. Here is the traceback:" ...
Read more >
Receive an error when resolving a bug created by your ...
The reason for this is that the new build system uses a service account to create the bug, which is a group in...
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