0
votes

first of all thx for ur attention.

My question here: is that possible and how can I maybe use a webjob to monitor if new blob is uploaded to a certain blob container?

Background of the questions: I write webjob in python3.6 for my azure webapp (windows).

I used to use azure function app for similar requirements, but because of wish of exploring and also of the cost-saving issue, I choose to use webjob here.

below is how I build up the connection / client to azure storage account in my webjob

from azure.storage.blob import BlockBlobService

service = BlockBlobService(account_name=Storage_account_name, account_key=Storage_account_credential)
1

1 Answers

0
votes

I think you can not effectively get the event of new blob uploaded within WebJob, if the blob names are not formatted with a prefix pattern of datetime. The reason is that the only solution to get the new blob uploaded event is to list all blobs and sort them by their last modifed properties, then to get the latest blobs after a given timestamp, and the trigger scheduler is up to time.

Assumed that these blob names in a container are like mycontainer: 2019/07/31/HHMMSS/filename, so you can list the latest blobs with a prefix of datetime string to reduce the number of the candidated blobs to sort by last modified to get the latest ones.

If not, there is not a mechanism for helping to notificate a new event to your webjob only using Azure Blob Storage.

Otherwise, if you can control the blob upload operation, you can send a message into a queue of Azure Queue Storage per uploading a blob and retrieve these message from WebJob within a short interval, then you can approximately get the new blob in time for triggering your logic.

So the best solution is also use Azure Function with Blob Trigger or Azure Logic App.

Hope it helps.