azureazure-functionsazure-web-app-serviceappsettings

Converting keys in appsettings.json to Azure Portal App Settings


My appsettings.json file looks like this:

{
   "sqlDatabase": {
      "name": "my-sql-db",
      "connectionString": "my-connection-string-for-my-sql-db"
   },
   "documentDatabase": {
      "name": "my-document-db",
      "connectionString": "my-connection-string-for-my-document-db"
   }
}

What keys do I use when enter these settings into "App Settings" under Settings > Environment Variables on Azure Portal?

For example I tried using sqlDatabase:name as the key for my SQL Database name but : is not allowed in key names. How do "convert" my keys to what Azure Portal would accept?

I'm trying to do this for my Azure Functions app but I'll also need it for my API that runs on Azure App Service.


Solution

  • As per Configuration keys and values:

    In environment variables, a colon separator may not work on all platforms. A double underscore, __, is supported by all platforms and is automatically converted into a colon :

    So try sqlDatabase__nameinstead of sqlDatabase:name