Home > database >  appsettings.json files or App Service - App Settings in Azure Portal?
appsettings.json files or App Service - App Settings in Azure Portal?

Time:08-02

I have so far used the appsettings.{environment}.json files to keep application level configuration settings. Now I encounter this tab in Azure Portal for an App Service.

What is the difference between using the appsettings.json files and "Application Settings" Tab in the Azure Portal? And which one to use When?

enter image description here

CodePudding user response:

difference between using the appsettings.json files and "Application Settings" Tab in the Azure Portal? And which one to use When?

If you are using more than one environment like Production, Staging and Development for your application. You need specific Environment appsettings i.e., appsettings.{environment}.json.

Or if you don't want to use any specific environment. In this case you are using only production (Default) Environment you can use appsettings.json file.

CodePudding user response:

Few reasons to use Azure Application Settings -

1st - Let's assume that in order to avoid leaking configurations in appsettings.json, you aren't committing it to your repo. But you also deploy your web app on Azure AppServices. In this situation Application Settings tab can help you to configure your configurations directly and then Azure will auto create appsettings.json by reading those values.

2nd - This time we are committing appsettings.json and deployed web app on Azure. We also have a property as

{
  "Users": {
     "CanAccessApp": [ "[email protected]", "[email protected]" ],
     "CanAccessHangfire": [ "[email protected]", "[email protected]" ],
     "CanAccessLog": [ "[email protected]", "[email protected]" ]
   }  
}

Now, I also want one more user to be able to access logs. How you will do it? Generally, update in your appsettings.json and redeploy.

Or you can create similar property in Application Settings by

Users:CanAccessLog:0 -> [email protected]
Users:CanAccessLog:1 -> [email protected]
Users:CanAccessLog:2 -> [email protected]

and so on where 0,1,2 are indexes of the array (Azure style). This one will help us to test quickly without redeploying or modifying appsettings.json.

  • Related