© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
1 reply
L

❔ Unauthorized while reading secrets from Azure Keyvault

I am trying to read secrets from Keyvault locally in my API application with the following code:

SecretClient client = new(new Uri($"<url>"), new DefaultAzureCredential());
KeyVaultSecret secret = client.GetSecretAsync("<key>").GetAwaiter().GetResult(); 
return secret.Value;
SecretClient client = new(new Uri($"<url>"), new DefaultAzureCredential());
KeyVaultSecret secret = client.GetSecretAsync("<key>").GetAwaiter().GetResult(); 
return secret.Value;


and I am facing this error:

{"error":{"code":"Unauthorized","message":"AKV10032: Invalid issuer. Expected one of https://sts.windows.net/<guid1>/, https://sts.windows.net/<guid2>/, https://sts.windows.net/<guid3>/, found https://sts.windows.net/<guid4>/."}}

when I run the same code on a console application, I am able to read the secret without errors. I am not able to understand why is it throwing Unauthorized when I am running it on API application. how can I solve this?

I also tried this but no luck..

var options = new DefaultAzureCredentialOptions();
options.VisualStudioTenantId = "<tenantGuid>";
SecretClient client = new(new Uri($"<url>"), new DefaultAzureCredential()); KeyVaultSecret secret = client.GetSecretAsync("<key>").GetAwaiter().GetResult(); 
return secret.Value;
var options = new DefaultAzureCredentialOptions();
options.VisualStudioTenantId = "<tenantGuid>";
SecretClient client = new(new Uri($"<url>"), new DefaultAzureCredential()); KeyVaultSecret secret = client.GetSecretAsync("<key>").GetAwaiter().GetResult(); 
return secret.Value;
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,828Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Azure KeyVault duplicated API calls
C#CC# / help
3y ago
❔ Content reading from azure storage!
C#CC# / help
3y ago
Reading file content from Azure Blob Storage
C#CC# / help
4y ago
❔ Writing tests for Minimal API that calls KeyVault and Azure
C#CC# / help
3y ago