3

I am using ChainedTokenCredential and trying to get managed identity token in local debug environment using Visual Studio 2019. In windows terminal I already logged in using Azure CLI az login.

var credential = new ChainedTokenCredential(
                    new ManagedIdentityCredential(),
                                new AzureCliCredential());

var token = await credential .GetTokenAsync(new TokenRequestContext(new[] { _configuration.GetSection("scope").Value }));

When I am running code in debug I am seeing below error,

The ChainedTokenCredential failed to retrieve a token from the included credentials. ManagedIdentityCredential authentication unavailable. No Managed Identity endpoint found. Please run 'az login' to set up account

Where I need to do az login? Thanks.

user584018
  • 10,186
  • 15
  • 74
  • 160

1 Answers1

2

Execute az logout first and try again az login and I suggest to set default subscription by executing az account set -s "Subscription ID"

Jean-François Fabre
  • 137,073
  • 23
  • 153
  • 219
dev4java
  • 86
  • 1
  • 8
  • 1
    Install Azure Cli (https://learn.microsoft.com/en-us/cli/azure/install-azure-cli) and execute suggested commands in Command Prompt (Windows)/ Terminal (Linux) – dev4java Dec 02 '22 at 16:56