Azure 函数多个作业主机

Azure Function Multiple Job Hosts

我在启动多个作业主机时遇到 Azure Functions 的 st运行ge 问题。初始主机似乎启动,后续主机在尝试获取单例锁时出错。当我禁用其中一项作业并且错误消息显示 "function runtime is unable to start" 时,这确实很明显。我注意到我的计时器触发器根据其配置“0 */30 * * * *”执行了多次,这让我更深入地研究了这种情况。

Pid 1 2017-04-25T13:30:06.680 Staging table updated successfully.
Pid 1 2017-04-25T13:30:06.680 Updating the base table from the staging table.
Pid 2 2017-04-25T13:30:06.680 Staging table updated successfully.
Pid 2 2017-04-25T13:30:06.680 Updating the base table from the staging table.

函数应用详情:
- Dynamic/Consumption 计划
下的 Azure Function 运行 - 来自 class 个库的 5 个函数 运行(遵循本指南 - https://blogs.msdn.microsoft.com/appserviceteam/2017/03/16/publishing-a-net-class-library-as-a-function-app/
- 每 30 分钟从计时器执行 2 个功能 "0 */30 * * * *""
- 等待开发时间时禁用 1 个计时器触发器
- 1 个 blob 触发监视容器以从 IoT 中心上传
- 1 个 EventHub 触发器从 IoT 中心接收事件(稀疏事件,因此这里没有重负载)

重现步骤:
- 使用动态计划支持 Azure 功能
- 在门户中创建 Azure 功能(运行 之前没有这样做的问题)
- 使用上述指南中的 WebDeploy 从 VSTS 部署函数
- 确保函数尝试启动
- 禁用其中一项功能以强制重启
- 开始显示错误信息

从函数中提取的日志:
Link to log file

我已经停止了 Azure Function App Service,删除了锁文件夹以查看这是否有助于获取它所做的单例锁,但是一旦函数是 enabled/disabled 或使用 web 部署从 VSTS 推送错误 return。我已经重建了几次 Azure Function,结果还是一样。

我们正在尝试了解如何解决此问题,以便我们可以围绕此场景创建监控流程。

编辑
执行两次的函数设置如下(所有函数看起来都与此非常相似):
function.json

{
  "scriptFile": "..\bin\IngestionFunctionClassLibrary.dll",
  "entryPoint": "IngestionFunctionClassLibrary.Functions.AnalyticsUpdate.Run",
  "bindings": [
    {
      "name": "myTimer",
      "type": "timerTrigger", 
      "direction": "in",
          "schedule": "0 */30 * * * *"
    }
  ],
  "disabled": true`
}

project.json

{
  "frameworks": {
    "net46":{
      "dependencies": {
      }
    }
   }
}

看起来像Unable to acquire Singleton lock的消息实际上不是错误,而只是信息性消息。这意味着您的 Function App 已扩展到多个实例(在您的情况下约为 5 个)。有一些租赁资源本质上只能由一个实例持有(以支持单例行为)。因此,一旦一个实例获得租约,所有其他实例都会显示此消息。