Chavi Gupta
Chavi Gupta

Reputation: 255

How can we prevent an azure function from processing already processed blob?

I have an azure function, which is binded to blob storage. Once the blob is successfully processed I rename the file with a suffix '-Processed'.

But my azure function again picks up the same blob for processing. I tried putting {name}.csv filter in the BlobTrigger binding but that didn't help as the file will still be a csv even after the rename.

I know I can filter blobs to have a particular string in file name, for eg "original-{name}" will filter files starting with original. But Is there a way in azure functions using which I can filter the blob names to not include a particular string, in my case '-Processed'?

Upvotes: 1

Views: 760

Answers (2)

Alexey Rodionov
Alexey Rodionov

Reputation: 1446

  1. Just use two different paths for processed and not processed blobs.
  2. Put your new blobs with prefix ("notprocessed-" for example), when renaming remove prefix. Set "path": "input/notprocessed-{name}"

Upvotes: 4

Joey Cai
Joey Cai

Reputation: 20127

Actually, blob service only supports filtering by blob prefix and not by suffix. Your only option would be to list blobs and then do client side filtering.

Also, the list blobs operation has an additional delimiter parameter that enables the caller to traverse the blob namespace by using a user-configured delimiter.

You could refer to this article for more details.

Upvotes: 0

Related Questions