Skip to content
This repository was archived by the owner on Aug 3, 2024. It is now read-only.

Commit c44da56

Browse files
committed
Try managed identity before defaultIdentity
1 parent 29c4c0b commit c44da56

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/NuGet.Services.KeyVault/KeyVaultReader.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,17 @@ public async Task<ISecret> GetSecretObjectAsync(string secretName, ILogger logge
5959
private SecretClient InitializeClient()
6060
{
6161
TokenCredential credential = null;
62+
6263
if (_configuration.UseManagedIdentity)
6364
{
64-
credential = new DefaultAzureCredential(new DefaultAzureCredentialOptions
65+
if (string.IsNullOrEmpty(_configuration.ClientId))
66+
{
67+
credential = new DefaultAzureCredential();
68+
}
69+
else
6570
{
66-
ManagedIdentityClientId = _configuration.ClientId
67-
});
71+
credential = new ManagedIdentityCredential(_configuration.ClientId);
72+
}
6873
}
6974
else
7075
{

0 commit comments

Comments
 (0)