Skip to content

Instantly share code, notes, and snippets.

@conficient
Last active October 6, 2023 09:55
Show Gist options
  • Save conficient/ece8e7d1e480b7cd8879acb281b3417d to your computer and use it in GitHub Desktop.
Save conficient/ece8e7d1e480b7cd8879acb281b3417d to your computer and use it in GitHub Desktop.
AppSettings - in different environments

appsettings

In a JSON file, appsettings can be a nested heirachy, e.g.

{
    "Top": {
        "Second": {
            "Key": "value"
        }
    }
}

Reading from C#

Use : as the separator

  // key contains 'value'
  var key = Configuration.GetValue<string>("Top:Second:Key");

Setting via Windows Environment

Use __ (double underscore) as the separator

SET Top__Second__Key = value

Setting via Azure App Service 'Application Settings' page

Use __ (double underscore)

See https://docs.microsoft.com/en-us/azure/app-service/configure-common#:~:text=In%20the%20Azure%20portal%2C%20search,config%20or%20appsettings.

Top__Second__Key

Setting via Azure DevOps release variables

Use . as the separator

name:                   value:

Top.Second.Key          value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment