Skip to content

[BUG] Azure.Identity 1.5.0 freezes up ChainedTokenCredential with ManagedIdentityCredential listed first in local dev #24767

Closed
@mikequ-taggysoft

Description

@mikequ-taggysoft

Describe the bug

Immediately after upgrading Azure.Identity from 1.4.1 to 1.5.0, I noticed all my web projects freeze up at startup in local dev (VS Kestrel).

In my host builder inside Program.cs, I have

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

var secretClient = new SecretClient(
                        new Uri($"https://my-keyvault.vault.azure.net/"),
                        tokenCred);

var certificatesClient = new CertificateClient(
                        new Uri($"https://my-keyvault.vault.azure.net/"),
                            tokenCred);

config.AddAzureKeyVault(secretClient, new KeyVaultSecretManager());

...//load some necessary secret/certs etc

Note that I use ChainedTokenCredential with ManagedIdentityCredential listed first, followed by AzureCliCredential. This would ensure that when the project runs in Azure, managed identity is immediately used. In local dev, managed identity is attempted first which would fail quickly, then AzureCliCredential is successfully used next.

Expected behavior

Normally, the ManagedIdentityCredential should fail quickly (within a second or so) when running in local dev environment, which allows the chained credential to fall through to the next available credential.

Actual behavior

Something changed in Azure.Identity 1.5.0, which makes the program freeze up at ManagedIdentityCredential in local dev for a minute+. No exception/error messages (except Kestrel would time out, saying host is unable to start). But eventually, AzureCliCredential hits and code flows through. Maybe the timetout on ManagedIdentityCredential was misconfigured in the newer package.

Environment:

  • Azure.Identity 1.5.0
  • Visual Studio 2022 RC1
  • ASP.NET Core Web API and Razor projects set to start up via Kestrel

Metadata

Metadata

Labels

Azure.IdentityClientThis issue is related to a non-management packagecustomer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions