Mitulát báti
Mitulát báti

Reputation: 2166

Azure App Service doesn't fetch configuration key/values from appsettings.Staging.json

I have an Azure App Service that hosts a .net core 3 application. I populated my appsettings.Staging.json file with keys and values but once I publish the project to the app service, the Configuration section of the App Service remains unchanged.

My question is if that's possible to mirror the settings in appsettings.{env}.json (or similar file) to the Configuration section of the Azure App Service everytime a publish happens? And if yes, how?

Upvotes: 0

Views: 1951

Answers (1)

Alex
Alex

Reputation: 18526

You can't have AppService pull the configuration values it displays in the AzurePortal from a certain file you deploy. Actually it is the other way around: Anything you configure via the Azure Portal will override any settings you have in the JSON.

https://learn.microsoft.com/en-us/azure/app-service/configure-common

For ASP.NET and ASP.NET Core developers, setting app settings in App Service are like setting them in in Web.config or appsettings.json, but the values in App Service override the ones in Web.config or appsettings.json. You can keep development settings (for example, local MySQL password) in Web.config or appsettings.json, but production secrets (for example, Azure MySQL database password) safe in App Service. The same code uses your development settings when you debug locally, and it uses your production secrets when deployed to Azure.

Also, if you want your application to use the configuration stored in appsettings.Staging.json, you should use the AppService Configuration to set DOTNET_ENVIRONMENT or ASPNETCORE_ENVIRONMENT to Staging. Otherwise it will only read appsettings.json and appsettings.Production.json by default.

Upvotes: 1

Related Questions