Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop Azure blob trigger function from being triggered on existing blobs when function is published to the cloud

I have an Azure Function which is initiated on a blob trigger. Interestingly, if I publish an updated version of this Azure Function to the cloud and if there are blobs already existing, then the Azure Function will be triggered on each of those already-existing blobs.

This is not the functionality I would like. Instead, I would like a newly published Azure Function to only be triggered on newly uploaded blobs, not on blobs that already exist. How can I disable triggering on existing blobs?

like image 643
aBlaze Avatar asked Aug 03 '18 15:08

aBlaze


1 Answers

How can I disable triggering on existing blobs?

There is no way to do this currently and not recommended.

Internally we track which blobs we have processed by storing receipts in our control container azure-webjobs-hosts. Any blob not having a receipt, or an old receipt (based on blob ETag) will be processed (or reprocessed). That's why your existing blobs are being processed, they don't have receipts.

BlobTrigger is currently designed to ensure that all blobs in a container matching the path pattern are eventually processed, and reprocessed any time they are updated. So after all the blobs have a receipt, when you upload a new blob, it will only triggered by newly blob.

For more details, you could refer to this article.

The blob trigger function is triggered when files are uploaded to or updated in Azure Blob storage. If you disable triggering on existing blobs, when you update you blob it would not get the latest content, not recommended.

Workaround:

If you still want to trigger on newly uploaded blobs, you could add a judgement when invoke the function.

List all of existing blobs in the container and when a blob triggered invoke, check if the blob name is in the list, if not you could go ahead the triggered method.

like image 115
Joey Cai Avatar answered Oct 07 '22 00:10

Joey Cai