Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Identity] DefaultAzureCredential should properly handle the managedldentityClientId optional parameter #13973

Merged
4 commits merged into from
Feb 26, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions sdk/identity/identity/src/credentials/defaultAzureCredential.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,20 @@ export class DefaultAzureCredential extends ChainedTokenCredential {
constructor(tokenCredentialOptions?: DefaultAzureCredentialOptions) {
const credentials = [];
credentials.push(new EnvironmentCredential(tokenCredentialOptions));
credentials.push(new ManagedIdentityCredential(tokenCredentialOptions));
if (process.env.AZURE_CLIENT_ID) {

// In case a user assigned ID has been provided.
const managedIdentityClientId =
tokenCredentialOptions?.managedIdentityClientId || process.env.AZURE_CLIENT_ID;

if (managedIdentityClientId) {
credentials.push(
new ManagedIdentityCredential(
tokenCredentialOptions?.managedIdentityClientId || process.env.AZURE_CLIENT_ID,
tokenCredentialOptions
)
new ManagedIdentityCredential(managedIdentityClientId, tokenCredentialOptions)
);
} else {
// If the user didn't provide an ID, we'll try with a system assigned ID.
credentials.push(new ManagedIdentityCredential(tokenCredentialOptions));
}

credentials.push(new AzureCliCredential());
credentials.push(new VisualStudioCodeCredential(tokenCredentialOptions));

Expand Down