.net-coreazure-sdk-.netazure-sdkazure-identitydefaultazurecredential

DefaultAzureCredential not working on an Azure Arc enabled Windows Server


I have an arc enabled Windows Server 2022.

Im using DefaultAzureCredential and trying to use the Azure assigned managed identity to Authenticate to Azure key vault (and also azure storage at some stage)

I've populated the environment variable AZURE_CLIENT_ID + AZURE_TENANT_ID with the Id of this managed identity (object id of the managed identity shown to me in Entra ID) and you can see the other related environment variables:

enter image description here

But on starting the windows service I just get:

enter image description here

AuthenticationFailedException. User assigned managed identity is not supported by the detected managed identity environment

SO confused - I thought this was supported in Arc enabled servers? If this is not the way to do it in the Porgram startup, then how is it done? Im trying to not use the AZURE_CLIENT_SECRET

The code to get the secrets is just basic:

var client = new SecretClient(new Uri(vaultUrl), new DefaultAzureCredential());
var secretList = client.GetPropertiesOfSecrets();

Solution

    1. Remove the "AZURE_CLIENT_ID + AZURE_TENANT_ID" from your environment variables so the Azure Identity client falls back to using system-assigned managed identity
    2. Check if the system-assigned managed identity of your Arc-enabled server has proper access to your Key Vault.