【发布时间】:2018-12-13 10:16:12
【问题描述】:
对于部署后应该在 Azure 函数中使用的设置存储位置,我感到有些困惑。
在本地测试中,我在local.settings.json 中有连接字符串之类的设置,建议阅读以下代码:
[FunctionName("SomeEvent")]
public static void Run(
[EventHubTrigger("some-hub", Connection = "EventHubConnection" )]
EventData ev,
ILogger log,
ExecutionContext context,
IConfiguration configuration,
[EventHub("brd-iot-eventhubs", Connection = "OutputEventHubConnection")]
ICollector<EventData> outputEvents)
{
var config = new ConfigurationBuilder()
.SetBasePath(context.FunctionAppDirectory)
.AddJsonFile(SETTINGS, optional: true, reloadOnChange: true)
.AddEnvironmentVariables()
.Build();
string customername = config.GetValue<string>("Customer");
string connectionString = config.GetConnectionString("myDatabase");
[...]
现在我想在 Azure 上部署后进行设置(具有不同的值)。 AFAIK host.json 有所不同,因为这不是按功能配置,而是全局配置。
我可以直接在 Azure 中手动编辑属性,但我想要一个可以部署的设置文件。这样做的方法是什么?也许我只需要知道,设置文件必须有什么名称。
【问题讨论】:
标签: azure azure-functions