I am asking for your help because i have some trouble with the connection of my app to Azure key vault (title of the subject).
The architecture of my project looks like this : (I can't upload images yet)
Web.Client
- Properties
- wwwroot
- Shared
- ...
- Program.cs
Web.Server
- Properties
- Controllers
- Pages
- appsettings.json
- Startup.cs
- Program.cs
So far, I managed to connect to my AAD using appsettings.json files to configure the ids etc. and I've add Msal authentication in the Program.cs file in Web.Client part of the project.
To connect to my key vault, I've done this in my Startup.cs (I'm following this tutorial https://learn.microsoft.com/en-us/azure/key-vault/general/tutorial-net-create-vault-azure-web-app) :
SecretClientOptions options = new SecretClientOptions()
{
Retry =
{
Delay= TimeSpan.FromSeconds(2),
MaxDelay = TimeSpan.FromSeconds(16),
MaxRetries = 5,
Mode = RetryMode.Exponential
}
};
var client = new SecretClient(new Uri("https://<kv-name>.vault.azure.net/"), new DefaultAzureCredential());
KeyVaultSecret secret = client.GetSecret("test-secret");
string secretValue = secret.Value;
But I'm getting the following error :
Azure.RequestFailedException : 'AKV10032: Invalid issuer. Expected one of https://sts.windows.net/<...>/, https://sts.windows.net/<...>/, https://sts.windows.net/<...>/, found https://sts.windows.net/<...>/.
Status: 401 (Unauthorized)
ErrorCode: Unauthorized