Azure Functions v2-新的.netcore配置和部署

问题描述 投票:5回答:1

现在我们可以使用.NETCore的高度灵活的配置引擎-我们可以执行以下操作:

   private static IConfigurationRoot SetConfig(ExecutionContext executionContext)
    {
        return new ConfigurationBuilder()
           .SetBasePath(executionContext.FunctionAppDirectory)
           .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
           .AddEnvironmentVariables()
           .Build();
    }

这很棒,因为它允许您将更复杂的配置数据放入配置文件中-例如

    {
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "<< removed >>",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
    "APPINSIGHTS_INSTRUMENTATIONKEY": "<< removed >>"
  },
  "MyCustomSettings": [
    {
      "ConnectionString": "<< removed >>",
      "Folders": [
        {
          "ShareName": "share1",
          "FolderName": "folder1"
        },
        {
          "ShareName": "share2",
          "FolderName": "folder2"
        }
      ]
    }
  ]
}

再次-好消息!现在,我可以使用config [“ MyCustomSettings”]

访问我的强类型配置

我不明白的是,发布功能时如何进行部署。仅“值”部分迁移到Azure函数“应用程序设置”。我显然可以将此自定义json放在json文件中,并将其添加到类似local.settings.json]的load语句中。

.AddJsonFile("my-custom-settings.json", optional: false, reloadOnChange: true)

但是此文件必须包含在部署中,并且不能安全地存储。

有什么想法吗?

现在我们可以使用.NETCore的高度灵活的配置引擎-我们可以执行以下操作:private static IConfigurationRoot SetConfig(ExecutionContext executeContext){...

azure configuration azure-functions
1个回答
0
投票

目前尚无正式支持。

© www.soinside.com 2019 - 2024. All rights reserved.