Azure Function 多个作业主机

标签 azure azure-functions

我在启动多个作业主机时遇到了 Azure Functions 的奇怪问题。初始主机似乎启动,后续主机在尝试获取单例锁时出错。当我禁用其中一项作业并且出现错误消息“函数运行时无法启动”时,这一点确实很明显。我注意到我的计时器触发器根据其配置“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.

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

重现步骤:
- 通过动态计划支持 Azure 功能
- 在门户中创建 Azure 函数(之前未执行此操作时遇到问题)
- 使用上面指南中的 WebDeploy 从 VSTS 部署功能
- 确保功能尝试启动
- 禁用其中一项功能以强制重新启动
- 开始显示错误消息

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

我已经停止了 Azure Function App Service,删除了锁定文件夹,以查看这是否有助于获取单例锁(它确实如此),但是一旦使用 Web 部署启用/禁用或从 VSTS 推送功能,就会返回错误。我已经重建了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`
}

项目.json

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

最佳答案

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

关于Azure Function 多个作业主机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43614296/

相关文章:

c# - Azure 表助手检查保存的项目是新的还是旧的

c# - Azure 上具有 ClickOnce 应用程序的 Asp.net MVC 网站

azure - 如何使用 powershell 列出服务主体权限

c# - Asp.NET MVC 和 Azure 存储

azure - 处理 Durable Functions 中的服务总线消息

Azure Functions 的 Azure 队列触发器 : configure minimum polling interval

azure-functions - 如何延迟读取触发器 HTTP 请求的正文,直到稍后在 Azure 函数中?

azure - Azure 应用服务部署版本 4 - ERROR_USER_NOT_AUTHORIZED_FOR_CREATEAPP

c# - 需要在运行时使用 Azure Function 中的 ServiceProvider 创建服务

azure - 在配置中连接两个应用程序设置的任何方法 - Azure Function app