Share via

DefaultAzureCredential() return failed to retrieve a token from the included credentials.

Shobana 0 Reputation points
2024-11-04T15:58:54.26+00:00

I am using Virtual Engineers workplace and using Visual studio IDE. When i try to call an azure service, it is failed to retrieve a token from this included credentials.

Azure App Service
Azure App Service

Azure App Service is a service used to create and deploy scalable, mission-critical web apps.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Ryan Hill 30,336 Reputation points Microsoft Employee Moderator
    2024-11-05T13:31:51.0633333+00:00

    Hi @Shobana

    Take a look at the Authenticate .NET apps to Azure using developer accounts - .NET | Microsoft Learn guide. Make sure you are signed into the IDE with an account that has necessary RBAC roles to the Azure subscription and that the IDE is configured to use that account for Azure services.

    Another issue could be that you're using a work account from one tenant and accessing Azure resources in another tenant. For cases like that, you'll have to set the tenant specifically; for example, credential = new DefaultAzureCredential(new DefaultAzureCredentialOptions { TenantId = "YOUR-TENANT-ID" });. When using managed connection strings, you can apply this value by appending __teantId to the connection name in your app configuration.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.