Azure.Identity.AuthenticationFailedException:

Gnetchejo, Patrick Juvet 75 Reputation points
2023-06-13T15:05:16.4566667+00:00

I tried to follow this Tutorial:” Coding with the Azure Digital Twins SDK” from Microsoft website. I used visual studio code

Unfortunately I get the following error  : “Unhandled exception. Azure.Identity.AuthenticationFailedException: Azure CLI authentication failed due to an unknown error. See the troubleshooting guide for more information. https://aka.ms/azsdk/net/identity/azclicredential/troubleshoot 'az' n'est pas reconnu en tant que commande interne”

When I run the part concerning  “Upload a model”.

 

Please can you help me to solve this issue ?

 

Thank you

Azure IoT
Azure IoT
A category of Azure services for internet of things devices.
379 questions
Azure Digital Twins
Azure Digital Twins
An Azure platform that is used to create digital representations of real-world things, places, business processes, and people.
219 questions
Microsoft Authenticator
Microsoft Authenticator
A Microsoft app for iOS and Android devices that enables authentication with two-factor verification, phone sign-in, and code generation.
5,496 questions
0 comments No comments
{count} votes

Accepted answer
  1. LeelaRajeshSayana-MSFT 13,456 Reputation points
    2023-06-13T23:21:44.11+00:00

    Hi @Gnetchejo, Patrick Juvet Greetings! Welcome to Microsoft Q&A forum. Thank you for posting the question here.

    The sample code from the tutorial Coding with the Azure Digital Twins SDK uses DefaultAzureCredential (part of the Azure.Identity library) to authenticate users with the Azure Digital Twins instance. With DefaultAzureCredential, the sample will search for credentials in your local environment, like an Azure sign-in in a local Azure CLI or in Visual Studio or Visual Studio Code.

    The error message implies that the authentication failed. Did you sign in into the Visual Studio code using the same Azure credentials that you want to use to access your Azure Digital Twins instance? If you do not want to sing in into Visual Studio Code, you can install Azure CLI on your machine and authenticate locally using the az login command from the Command prompt. After you authenticate using this command, you should be able to execute the code without any issues.

    Kindly note that there is known issue with Azure.Identity library that causes the DefaultAzureCredential method to throw the following error Azure.Identity.AuthenticationFailedException: SharedTokenCacheCredential authentication failed. If you face this issue, you can resolve it by adding an optional parameter as follows new DefaultAzureCredential(new DefaultAzureCredentialOptions { ExcludeSharedTokenCacheCredential = true }) when instantiating the DefaultAzureCredential

    Hope this helps. Please let us know if you need further assistance or have any follow up questions.


    If the response helped, please do click Accept Answer and Yes. Doing so would help other community members with similar issue identify the solution. I highly appreciate your contribution to the community.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful