I want to store a secret in Azure Key vault, pull into the application settings in an app service (which is working) and when I run the app I can retrieve the data.
Now I want to obtain this value in my local development using visual studio
Thanks to help from this video:
https://www.youtube.com/watch?v=vEaCnhvggz0
If you skip to the 9 min mark I was able to
- link the KV to the app service using managed identity
- store a value in my KV
- pull the value from KV and use as an app setting – which is then displayed as a Key Vault Reference in the source
Using the value for this as:
@Microsoft.KeyVault(SecretUri=https://keyVaultName/secrets/SecretName/1121283182091283/)
Then reference Secret_Value in code using:
in my web.config:
<add key="Secret_Value" value="localDev" />
var Secret = ConfigurationManager.AppSettings[“Secret_Value”];
which when I run the app locally on VS this returns ‘localDev’ but correctly when I run on app service this returns the value from the KV
How do I grab the value on my local dev? because obv I cant do this:
<add key="Secret_Value" value="@Microsoft.KeyVault(SecretUri=https://keyVaultName/secrets/SecretName/1121283182091283/)" />
Is this possible? I know I can add KeyVault as Nuget package and obtian with something like:
var client = new SecretClient(new Uri(keyVaultURL), new DefaultAzureCredential());
var secret = client.GetSecret(CRM_Secret_KeyVaultName);
but I dont want this.
I want to pull the value from the local webconfig directly from the KV, is this possible? thanks for any replies