Azure 函数运行时配置

标签 azure azure-functions azure-functions-runtime

我正在尝试使用官方 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设置不正确,很久以前就已经改进得更容易理解了。看这个issueits 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/

相关文章:

设置应用程序设置后,Azure Functions 应用程序产生错误

azure - 无法为隔离的 AZ 功能的 ScheduleMonitor 创建 BlobContainerClient

c# - 找不到方法 : 'Microsoft. Extensions.Primitives.StringValues Microsoft.AspNetCore.Http.IQueryCollection.get_Item(System.String)

Azure功能失败: ModuleNotFoundError: No module named _cffi_backend

本地开发的Azure函数-无法注册EventHub触发的函数

c# - 无法解析与 ServiceBus 队列远程名称的 Azure 网站连接

azure - 无法确定在 Azure 流分析中使用哪个窗口

azure - 使用 Azure 负载均衡器在 terraform 上使用 for_each

azure - 上传的文件不是有效的 X.509 证书,或者密码无效

Azure 函数运行时无法启动