2

I'm trying to resize the image from blob storage using the Azure function - the easy task, lots of samples, works great, but. works only when resized image is saved to a different file. My problem is that I would like to replace the original image with resized one - with the sane location and name.

when I set output blob to be the same as input blob, it is triggered over and over again without the finish.

is there any way I could change blob using azure function and store result in the same file?

always-a-learner
  • 3,671
  • 10
  • 41
  • 81
Misiakw
  • 902
  • 8
  • 28
  • Please see if this answers your question: https://stackoverflow.com/questions/44304746/check-if-file-exists-on-blob-storage-with-azure-functions. – Gaurav Mantri Jul 19 '17 at 12:51
  • no, it' didnt answer my problem. if blob wouldn't exist - it wouldn't trigger function. as i told - my problem is that saving resized image to the same blob as source triggers function all over again. this is because blob trigger trigger on creation and on change of blob. i was wondering if i could stop triggering on update and trigger only on change – Misiakw Jul 19 '17 at 13:00
  • 1
    I guess you could check if the size of the incoming file is already OK, and do nothing if yes (so the function will be invoked two times and then stop). – Mikhail Shilkov Jul 19 '17 at 13:02
  • @Mikhail this is solution i'm going for now. as far as I searched there is no way to stop triggering blob trigger from azure function. and yes, your' solution works (I've checked it) – Misiakw Jul 19 '17 at 13:29

1 Answers1

2

The easiest option is to accept two invocations for the same file, but add a check of the size of the incoming file. If the size is already OK, do nothing and quit without changing the file again. This should break you out of the loop.


Blob trigger uses Storage Logs to watch for new or changed blobs. It then compares the changed blob against Blob Receipts in a container named azure-webjobs-hosts in the Azure storage account. Each receipt has ETag associated with it, so when you change a blob, the ETag changes and the Blob is submitted to the function again.

Unless you want to go fancy and update ETag's in receipts from within a function (not sure if it's feasible), your changed files will go for re-processing.

Mikhail Shilkov
  • 34,128
  • 3
  • 68
  • 107