Description
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