Azure Functions Blob is triggered 5 times

148 Views Asked by At

Since we switched to Azure Functions with the Python V2 programming model, we experience a lot more problems during and after deployment then before. One that keeps puzzling me is that a blob trigger function is executed 5 times every time a new file is added in blob storage. The triggers are always 10min apart.

The code starts an Azure ML Training Job. I can't tell how long the function runs each time, because they dont show up in monitoring.

Has anyone else experienced this behavior?

2

There are 2 best solutions below

1
Ikhtesam Afrin On

I have created a blob triggered python v2 function using python interpreter 10.0

function_app.py

import  azure.functions  as  func
import  logging
app  =  func.FunctionApp()
@app.blob_trigger(arg_name="myblob", path="mycontainer",
connection="BlobStorageConnectionString")
def  blob_trigger(myblob: func.InputStream):
logging.info(f"Python blob trigger function processed blob"
f"Name: {myblob.name}"
f"Blob Size: {myblob.length} bytes")

I am getting expected output locally.

enter image description here

Then I published my function to function app (consumption plan) and added the connection string in app settings.

enter image description here

When I uploaded a blob, I got two requests in application insight. One which was uploaded during local testing also processed a long with the one I uploaded later.

enter image description here

Please note, blob triggered function will process all the outstanding blob. Once blobs are processed, it maintains blob receipts to ensure no blob trigger function gets called more than once for a new blob or updated blob. Refer this ms docs for more details about blob receipt.

Later, I uploaded two more blobs keeping 2min difference between them. Both of them processed and got single request for each blob.

enter image description here

Please refer to application insight to get detailed logging information about your function.

0
Shreya On

To respond to Pietz' comment -

Apple Silicon support for Azure Functions is now live -

https://azure.microsoft.com/en-us/updates/generally-available-azure-functions-support-on-apple-silicon-macs/

This will enable you to test locally on your M1 machine without any workarounds.