In a zip-deployed function app that is triggered off of an event hub, the app inconsistently triggers (only seems to trigger when debugging the app int he Azure Portal and ~15 minutes afterwards).
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://learn.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"
}
}
This is a long, known outstanding issue that is caused by function triggers not being sync (see https://github.com/Azure/Azure-Functions/issues/210)
add this local-exec
provisioner in terraform that use the azure cli to syncfunctiontriggers
works well
# 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"
}