我正在尝试使用官方 microsoft/azure-functions-node8
镜像对 azure 函数进行 dockerize。我根本找不到任何有关配置运行时的文档,每当我运行运行时时都会发生以下错误:
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.)
我在谷歌上搜索了一些零碎内容,并设法编写了以下 .config
文件,但运行时仍然对我大喊大叫。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="AzureWebJobsStorage" connectionString="myconnectionstring"/>
</connectionStrings>
</configuration>
.config
文件格式是否记录在任何地方?
最佳答案
这是一个旧提示,用于提醒我们默认存储连接AzureWebJobsStorage
设置不正确,很久以前就已经改进得更容易理解了。看这个issue和 its fix .
看起来像在 docker 镜像中,此修复以某种方式被省略。
要解决您的问题,只需在 Dockerfile 中设置 AzureWebJobsStorage
即可。
ENV AzureWebJobsStorage=DefaultEndpointsProtocol=https;AccountName=xxx;AccountKey=xxx==;EndpointSuffix=core.windows.net
请注意,如果您使用 AzureWebJobsStorage
以外的名称,则需要使用 function.json
文件中的名称设置 connection
参数.
更新
根据 Connor 的评论,我提到的修复已添加到 cli 工具中,而 docker 镜像不使用该工具,因此我们仍然看到这个原始的运行时错误。
关于Azure 函数运行时配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51177675/