9

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,551
  • 3
  • 37
  • 53
Michael Chudinov
  • 2,620
  • 28
  • 43
  • 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
  • but how are you reading the configuration in the function? – Tiju John Jul 18 '22 at 15:09

1 Answers1

15

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
  • 28,293
  • 19
  • 112
  • 138
Michael Chudinov
  • 2,620
  • 28
  • 43