There are a couple other topics out there, but none with solutions or none pertaining to Python Functions.
Background:
- EventGrid-triggered, Python Azure Function
- EventGrid messages created only when a blob is uploaded to a given Storage Account
- Function receives message, downloads blob from message URL and does "stuff"
- Function can run for several seconds/minutes (up to 120 seconds for large blobs)
Example of issue:
- 4 files uploaded to blob container in correct Storage Account
- Function successfully triggered 4 times, by 4 separate EventGrid messages
- Function downloads blob from URL in each message, does "stuff"
- ~55 seconds later, 4 more EventGrid messages trigger the Function all over again (for the same 4 files!)
- Everything repeats
This happens multiple times resulting in 12 Function executions for 4 files:
- And corresponding output from the "stuff" the Function does!
It gets ridiculous when 2500 files are uploaded to the Storage Account!
Seems like I need to adjust the EventGrid retry timing. But I don't see a setting for this in the Portal:
How do I prevent this behavior?
EDIT 1: Then today... no issue with 16 files uploaded... why is this Function inconsistently being triggered by EventGrid?
EDIT 2: And again today... for no reason, ~an hour later... EventGrid fired off a bunch more triggers though NO MORE FILES have been uploaded to the storage account.
Here are the EventGrid stats for 16 files being uploaded to storage account.
- You can clearly see the numbers are all over the place with in some cases, ~1hour between retries.
- Looks quite arbitrary to me
EDIT 3: For anyone interested...
- What appears to be happening is: EventGrid is being triggered by TWO events within the Storage Account for a SINGLE file upload.
- This is generating two EventGrid schemas (one for a "Microsoft.Storage.BlobCreated event" and one for "Microsoft.Storage.BlobCreated event (Data Lake Storage Gen2)"
- Because the
data.url
parameter of the EventGrid message is different (xxx.blob.core.windows.net
vs.xxx.dfs.core.windows.net
), my Function is failing (as it usesBlobClient.from_blob_url
- More to come.