The team I work in is looking into debugging future projects in Visual Studio Code. We have set the debugger to work with our project.The project uses Azure Key Vault for our Application Secrets. The issue is that our Startup breaks when the debugger tries to pass the Azure KeyVault portion of the code and returns:
Exception has occurred: CLR/Microsoft.Azure.Services.AppAuthentication.AzureServiceTokenProviderException
In Visual Studio I am signed in with my account and during debug Visual Studio is able to pull the access token from my account.
I tried to sign in using Azure Account Visual Studio Code Extension before attempting to start the debug but it returns the same exception even when I am signed in.
My code for getting the Azure KeyVault looks like this:
AzureServiceTokenProvider azureServiceTokenProvider = new AzureServiceTokenProvider();
KeyVaultClient keyVaultClient = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(azureServiceTokenProvider.KeyVaultTokenCallback));
AzureADAppSettings azureADAppSettings = Configuration.GetSection("Authentication").GetSection("AzureAd").Get<AzureADAppSettings>();
if (azureADAppSettings.ApplicationSecret.StartsWith("https://"))
azureADAppSettings.ApplicationSecret = keyVaultClient.GetSecretAsync(azureADAppSettings.ApplicationSecret).GetAwaiter().GetResult().Value;
I expected that the Azure Account would enable me to use Azure KeyVault the same way as in Visual Studio.
Instead the code breaks on exceptions.
Can someone tell me what I am doing wrong ?