【问题标题】:Azure Function App inconsistently triggeringAzure Function App 触发不一致
【发布时间】:2019-05-30 22:32:14
【问题描述】:

在从事件中心触发的 zip 部署函数应用中,应用的触发不一致(似乎仅在在 Azure 门户中调试应用时以及大约 15 分钟后才会触发)。

resource "azurerm_function_app" "helloworld" {
  name                      = "helloworld-func"
  location                  = "${azurerm_resource_group.helloworld.location}"
  resource_group_name       = "${azurerm_resource_group.helloworld.name}"
  app_service_plan_id       = "${azurerm_app_service_plan.helloworld.id}"
  storage_connection_string = "${azurerm_storage_account.helloworld.primary_connection_string}"
  version                   = "~2"

  app_settings {
    # key must match bindings.connection in functionapp/eventHubsMessages/function.json and must include EntityPath
    # bindings.eventHubName in functionapp/eventHubMessages/function.json is purposelly kept empty to avoid overriding the EntityPath in connection string
    # see https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-event-hubs#output---configuration
    LOGSEVENTHUBCONNECTIONSTRING = "${azurerm_eventhub_authorization_rule.helloworld.primary_connection_string}"

    # TODO figure out how to use Azure AD and RBAC to allow the Function App access to the storage blob without a time-based token
    WEBSITE_USE_ZIP              = "${azurerm_storage_blob.helloworld.url}${data.azurerm_storage_account_sas.helloworld.sas}"
    HASH                         = "${data.archive_file.helloworld.output_base64sha256}"
    WEBSITE_NODE_DEFAULT_VERSION = "10.14.1"
  }
}

【问题讨论】:

    标签: azure terraform azure-eventhub terraform-provider-azure


    【解决方案1】:

    这是一个由函数触发器不同步引起的长期已知的未决问题(请参阅https://github.com/Azure/Azure-Functions/issues/210

    在使用 azure cli 的 terraform 中将此 local-exec 配置程序添加到 syncfunctiontriggers 效果很好

      # required to sync the function trigger (event hub trigger); without, function app will trigger inconsistently
      provisioner "local-exec" {
        command = "az resource invoke-action --resource-group ${azurerm_resource_group.datadog_logs.name} --action syncfunctiontriggers --name ${azurerm_function_app.datadog_logs.name} --resource-type Microsoft.Web/sites"
      }
    

    【讨论】:

    • 这对我不起作用。我的一些事件中心仍然不会触发,运行此命令后的事件
    • 当您进入试图在门户中触发的函数应用程序时,您会收到任何错误消息吗?
    • 没有。它只是不会触发。
    • 如果它没有在本地触发,那么问题可能出在代码上。该命令专门用于 azure 中基于 zip 的部署
    猜你喜欢
    • 2020-02-27
    • 2021-11-27
    • 1970-01-01
    • 2018-11-17
    • 1970-01-01
    • 2017-12-22
    • 2022-10-08
    • 1970-01-01
    • 2023-02-01
    相关资源
    最近更新 更多