I have an Azure Linux Function App that I am deploying using TerraForm.
I have Linux Function + Consumption Plan.
The .zip function contains 3 .py scripts, one __init__.py and function.json
.
The code deployment goes well, but the triggering does not work (the function is an Azure Storage Blob Trigger that fires when a specific file is uploaded on the blob container).
If I use the Azure Function Core Tools, the deployment goes well and the triggering works (I open the log streams/monitor and I see the function is constantly polling for objects inside that container).
If I use the CLI or TerraForm to upload the code, the triggering does not work.
Here is my code for the function_app
:
resource "azurerm_linux_function_app" "blurring_fn_app" {
name = "blurring-app-new4"
location = var.location
resource_group_name = var.resource_group
storage_account_name = var.storage_account
storage_account_access_key = data.azurerm_key_vault_secret.sensestgaccountkey.value
service_plan_id = azurerm_service_plan.blurring_app_service_plan.id
functions_extension_version = "~4"
app_settings = {
"APPINSIGHTS_INSTRUMENTATIONKEY" = "${data.azurerm_key_vault_secret.appinsightskey.value}"
"AzureWebJobsStorage" = "${data.azurerm_key_vault_secret.azure_web_jobs_storage.value}"
"ENABLE_ORYX_BUILD" = true
"SCM_DO_BUILD_DURING_DEPLOYMENT" = true
}
site_config {
application_insights_key = data.azurerm_key_vault_secret.appinsightskey.value
application_insights_connection_string = data.azurerm_key_vault_secret.appinsightsconnstr.value
application_stack {
python_version = "3.9"
}
}
}
What I already tried:
-
I tried using the func CLI deployment, which works for the uploading, but the function is not triggered.
-
I tried using the
"WEBSITE_RUN_FROM_PACKAGE"= azurerm_storage_blob.storage_blob_function.url
(.zip of scripts uploaded to an Azure Storage Blob, this must be an URL in case of Linux apps + Consumption Plan), which works as well for the uploading, but the function is not triggered. -
I also tried using
zip_deploy_file = path_to_local_zip
as a parameter inside theazurerm_linux_function_app
and it still did not work. -
For all 3 options above, I tried to manually sync the triggers : https://learn.microsoft.com/en-us/rest/api/appservice/web-apps/sync-function-triggers?tryIt=true&source=docs#code-try-0 but that did not work either.
The function.json
is the following:
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "myblob",
"type": "blobTrigger",
"direction": "in",
"path": "blobcontainername/{name}.mp4",
"connection": "AzureWebJobsStorage"
}
]
}
How can I make sure the function is triggered?
2
Answers
Yes, it does work for me when i deploy it using Azure CLI using below commands:
Deployed:
After successfull deployment, I uploaded a file as below:
Then to test, I checked the logs as below:
I am providing an alternative way to do it, it may work for you or this answer may help for community. I have given in cli as you mentioned in question about not working with cli too.
Here are a few things you can try:
Check the function app’s log files for any errors related to the
function trigger. You can access the log files by going to the
"Functions" tab in the Azure Portal, selecting your function app,
and clicking on "Logs".
Try deploying the function app without the function code to ensure
that the function trigger is set up correctly. You can then add the
function code and deploy it separately.
Try using the
WEBSITE_RUN_FROM_PACKAGE
setting to deploy thefunction code. This setting allows you to deploy the function code
as a zip file to a storage account and then reference it in the app
settings. This can help ensure that the function code is deployed
correctly and that the function trigger is synced with the function
app.
Double-check that the function.json file is included in the function
code zip file. It should be located in the root directory of the zip
file.
Try synchronizing the function triggers manually using the Azure
CLI. You can do this by running the following command:
az functionapp deployment source sync -g <resource-group> -n <function-app-name>
This command will sync the function app’striggers with its deployed code.
Please follow the above steps and let me know how the details.