4

I have an Azure function v3 in .NET core 3.1 Function works fine locally. Here is the local.settings.json:

{
  "IsEncrypted": false,
  "Values": {
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
    "AzureWebJobsStorage": "UseDevelopmentStorage=true"
  },
  "Foo": {
    "Bar": {
      "test1": true,
      "test2": false
    }
  }
}

I need to write configuration for nested object Foo:Bar:test1 in Azure function configuration.

How to express this nested object there?

lopezbertoni
  • 3,391
  • 3
  • 40
  • 52
Michael Chudinov
  • 2,182
  • 22
  • 34
  • Does this answer your question? [azure application settings - how to add nested item](https://stackoverflow.com/questions/55497468/azure-application-settings-how-to-add-nested-item) (Answer is for web apps, but functions should work the same) – Preben Huybrechts Jul 31 '20 at 11:36
  • Azure functions and web apps behave differently. Look at this for more insight (https://stackoverflow.com/a/63124002/1138731) – lopezbertoni Jul 31 '20 at 13:05

1 Answers1

10

The correct syntax for configuration options for Azure functions to express nested objects is to use double underscore: "CustomSettings__MySpecificSetting".

For a nested object in local.settings.json file:

"Foo": {
   "Bar": {
     "test1": true
    }
}

The Azure configuration looks like:

Foo__Bar__test1
Ian Kemp
  • 26,561
  • 17
  • 107
  • 129
Michael Chudinov
  • 2,182
  • 22
  • 34