CredentialUnavailableError when using DefaultAzureCredential

Saurav Likhar 5 Reputation points Microsoft Employee
2023-08-09T16:11:31.4566667+00:00

Hi,

I am using DefaultAzureCredential to get the credentials for EventhubProducerClient. In DefaultAzureCredential, I am giving the options DefaultAzureCredentialResourceIdOptions which is intialized with the resource id of managed identity.

There are many request at the same time which are trying to create the EventHubProducerClient and send the data to event hub. In some requests I am getting the error -

{"errors":[{"name":"CredentialUnavailableError"},{"name":"CredentialUnavailableError"},{"name":"CredentialUnavailableError"},{"name":"CredentialUnavailableError"},{"name":"CredentialUnavailableError"},{"name":"CredentialUnavailableError"}],"name":"AggregateAuthenticationError"}

Is there any limit on managed identity to fetch the token for credentials?

Microsoft Identity Manager
Microsoft Identity Manager
A family of Microsoft products that manage a user's digital identity using identity synchronization, certificate management, and user provisioning.
691 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
21,585 questions
{count} vote

2 answers

Sort by: Most helpful
  1. Marilee Turscak-MSFT 36,846 Reputation points Microsoft Employee
    2023-08-11T00:11:40.33+00:00

    Hi @Saurav Likhar ,

    The CredentialUnavailableError error typically means one of the following: the environment variables in your application are not correctly updated, your service principal does not have the correct secret permission, or in some cases Visual Studio may have lost its Azure Service Authentication connection.

    Please confirm the following:

    1. Ensure that the environment variables are updated:

    AZURE_CLIENT_ID - service principal's app id

    AZURE_TENANT_ID - id of the principal's Azure Active Directory tenant

    AZURE_CLIENT_SECRET - one of the service principal's client secrets

    1. Ensure that the application is added to the Key Vault Access policies and that the resource has "Key Vault Secrets User" permissions.
    2. In Visual Studio, go to Tools > Options. Expand "Azure Service Authentication" > "Account Selection." If you see a "Reenter your credentials" link, click it and sign in again. If not, try a regular sign-out + sign-in via your Visual Studio profile in the top right.

    Additional resources:

    CredentialUnavailableException: DefaultAzureCredential failed to retrieve a token from the included credentials

    Azure error: DefaultAzureCredential authentication failed

    Setting Azure EnvironmentCredential()

    If these steps don't work, I would recommend checking in the internal Stack Overflow channel since I see that you are an internal FTE.

    If the information helped you, please Accept the answer. This will help us and improve discoverability for others in the community who may be researching similar issues.


  2. Rohit Pitre 0 Reputation points
    2024-09-10T06:15:44.76+00:00

    @Saurav Likhar (sauravlikhar) I am facing the same issue but for Azure Computer Vision client, could you please update if you were able to find a solution for your problem ?

    0 comments No comments

Your answer

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