I have an appsettings.json in my ASP.NET Core 6 Web API and a secrets.json I use for development connection strings, like below:
{
"ConnectionStrings:MainDatabase": "CONNECTION STRING HERE"
}
After publishing my API as an Azure Container App, how can I override these connection strings from Azure?
I see the "Secrets" settings to configure a KeyVault, but how can I link those secrets to the User Secrets/appsettings used by my Web Api?
After updating or changing the
User Secretswe need to restart or recreate the revision.My Secrets:
Reading Secret Key:
Make sure the name of the key must be same as the local Secret name.
Even if you have
secretscreated in theSecretssection of the Azure Container App, you can see theEnvironment variablesinContainerSection is unavailable.For the secrets to work, we need to map the secrets into the
Environment variables.Edit and deployCreate new Revision
Click on the
container image=> CreateEnvironment variableswith mapping to the existing secrets =>Save => RefreshEvery time you make changes to the
secretsin portal, If you don`t have the revision we need to create it or restart the existing Revision.Use the below command to restart the revision.