Azure 函数 v3 设置中 local.settings.json 的嵌套对象

Mik*_*nov 11 azure-functions

我在 .NET core 3.1 中有一个 Azure 函数 v3,函数在本地运行良好。这是 local.settings.json:

{
  "IsEncrypted": false,
  "Values": {
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
    "AzureWebJobsStorage": "UseDevelopmentStorage=true"
  },
  "Foo": {
    "Bar": {
      "test1": true,
      "test2": false
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我需要在 Azure 函数配置中为 Foo:Bar:test1 等嵌套对象编写配置。

如何在那里表达这个嵌套对象?

Mik*_*nov 15

Azure 函数的配置选项表达嵌套对象的正确语法是使用双下划线:“CustomSettings__MySpecificSetting”。

对于 local.settings.json 文件中的嵌套对象:

"Foo": {
   "Bar": {
     "test1": true
    }
}
Run Code Online (Sandbox Code Playgroud)

Azure 配置如下所示:

Foo__Bar__test1
Run Code Online (Sandbox Code Playgroud)