This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.47k
stars
4.8k
forks
source link
[BUG] API consistency issue, ManagedIdentityCredential() does not read default values from environment variables, like other Credentials. #44588
The majority of the CredentialOptions classes obtain default values from Environment Variables, example client_id which allows applications to run on multiple platforms with runtime configuration injected via env vars (i.e. AZURE_CLIENT_ID, AZURE_TENANT_ID) without application code.
However, ManagedIdentityCredential doesn't follow this pattern.
For context, my org is the process of transitioning thousands of applications running across multiple hosting platforms to AKS. At the same time, we're moving from ManagedIdentity to WorkloadIdentity. All of our apps obtain credentials using DefaultAzureCredential(), as it allows env vars to control the runtime behavior without additional application code. Some hosting platforms assign multiple MSI's to compute nodes, requiring applications declare the client-id to use, others do not. Controlling this behavior via env vars avoids conditional application code.
Christopher recommended we not use DefaultAzureCredential() in production and replace it with `new ChainedTokenCredential(new ManagedIdentityCredential(), new WorkloadIdentityCredential()), however ManagedIdentityCredentialOptions doesn't obtain default values from env vars.
Expected behavior
ManagedIdentityCredential() parameterless ctor/ManagedIdentityCredentialOptions applies default values read from env vars, like other ...CredentialOptions classes. Example for client_id.
Actual behavior
ManagedIdentityCredential() parameter-less ctor applies null defaults, which is inconsistent with other credential options which apply default values from reading env vars.
Reproduction Steps
Define env var AZURE_CLIENT_ID=123
var cred = new ManagedIdentityCredential();
cred.ClientId is "123"
Library name and version
Azure.Identity 1.*
Describe the bug
The majority of the CredentialOptions classes obtain default values from Environment Variables, example client_id which allows applications to run on multiple platforms with runtime configuration injected via env vars (i.e. AZURE_CLIENT_ID, AZURE_TENANT_ID) without application code.
However, ManagedIdentityCredential doesn't follow this pattern.
For context, my org is the process of transitioning thousands of applications running across multiple hosting platforms to AKS. At the same time, we're moving from ManagedIdentity to WorkloadIdentity. All of our apps obtain credentials using DefaultAzureCredential(), as it allows env vars to control the runtime behavior without additional application code. Some hosting platforms assign multiple MSI's to compute nodes, requiring applications declare the client-id to use, others do not. Controlling this behavior via env vars avoids conditional application code.
Christopher recommended we not use DefaultAzureCredential() in production and replace it with `new ChainedTokenCredential(new ManagedIdentityCredential(), new WorkloadIdentityCredential()), however ManagedIdentityCredentialOptions doesn't obtain default values from env vars.
Expected behavior
ManagedIdentityCredential() parameterless ctor/ManagedIdentityCredentialOptions applies default values read from env vars, like other ...CredentialOptions classes. Example for client_id.
Actual behavior
ManagedIdentityCredential() parameter-less ctor applies null defaults, which is inconsistent with other credential options which apply default values from reading env vars.
Reproduction Steps
Define env var AZURE_CLIENT_ID=123 var cred = new ManagedIdentityCredential(); cred.ClientId is "123"
Environment
No response