1
votes

I would like to store my Db password in the Azure KeyVault and be able to use it in the connection string in appsettings.json. Possible? My Application is registered and configured with the Azure Key Vault. I also created a secret value of which is identical with my Db password). I can see that my App Service application is configured with the key vault since there is a relevant configuration entry in launchSettings.json. This is what I would like to do in appsettings.json :

"myContext": "Server=myServer;Database=myDb;User Id=myUser; Password={KEYVAULTSECRET}"

Possible?

1

1 Answers

1
votes

Yes, you can use Key Vault references for this. The high level instructions are:

  1. Add your secret to Key Vault.
  2. Create a managed identity for the webapp which has access to the key vault.
  3. Create a key vault reference as the value of an application setting. (App settings are just environment variables.)

  4. Finally, in your config file just reference your environment variable ( ... ${MY_DB_PASSWORD} ..

The official docs on this are here. I wrote an example of this for Java apps here.