Azure 函数运行时配置

Azure functions runtime configuration

我正在尝试使用官方 microsoft/azure-functions-node8 图像对 azure 函数进行 docker 化。我根本找不到任何关于配置 运行time 的文档,每当我 运行 the 运行time 时,就会发生以下错误:

      The listener for function 'Functions.health' was unable to start.
Microsoft.Azure.WebJobs.Host.Listeners.FunctionListenerException: The listener for function 'Functions.health' was unable to start. ---> System.AggregateException: One or more errors occurred. (Microsoft Azure WebJobs SDK 'Storage' connection string is missing or empty. The Microsoft Azure Storage account connection string can be set in the following ways:
1. Set the connection string named 'AzureWebJobsStorage' in the connectionStrings section of the .config file in the following format <add name="AzureWebJobsStorage" connectionString="DefaultEndpointsProtocol=http|https;AccountName=NAME;AccountKey=KEY" />, or
2. Set the environment variable named 'AzureWebJobsStorage', or
3. Set corresponding property of JobHostConfiguration.)

我google一些点点滴滴,拼凑成下面的.config文件,但是运行时间还在对我吼叫。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <connectionStrings>
        <add name="AzureWebJobsStorage" connectionString="myconnectionstring"/>
  </connectionStrings>
</configuration>

是否在任何地方记录了.config文件格式?

这是一个老提示,用来提醒我们默认存储连接 AzureWebJobsStorage 设置不正确,很久以前就改进了,更容易理解。看到这个 issue and its fix.

在 docker 图像中看起来像,但不知何故省略了此修复程序。

要解决您的问题,只需在您的 Dockerfile 中设置 AzureWebJobsStorage

ENV AzureWebJobsStorage=DefaultEndpointsProtocol=https;AccountName=xxx;AccountKey=xxx==;EndpointSuffix=core.windows.net

请注意,如果您使用 AzureWebJobsStorage 以外的名称,则需要在 function.json 文件中使用该名称设置 connection 参数。

更新

根据 Connor 的评论,我提到的修复已添加到 cli 工具中,docker 图像没有使用,所以我们仍然看到这个原始的运行时错误。