简体   繁体   中英

Azure Function Storage Container Blob Trigger

Azure Function Storage Account Blob Container Trigger

In one of our use case, i am looking for Azure function trigger for any activity in Storage account containers with following conditions

  • Container with a specific naming convention (name like xxxx-input)
  • It should automatically detect if a new container(with specific naming convention) is created

Currently, the following events are supported at the moment, per the documentation :

  • BlobCreated
  • BlobDeleted
  • BlobRenamed
  • DirectoryCreated(Data lake Gen2)
  • DirectoryRenamed(Data lake Gen2)
  • DirectoryDeleted(Data lake Gen2)

This means that it is not possible to create such event, but you can try to change the approach(if feasible for your use-case) from 'push' to 'pull'.

I suggest to write a time-triggered function that checks whether container with the given schemes were created. You can leverage the Blob Storage v12 SDK for this task, and get list of the containers . Save the list to some database(for example CosmosDB), and every time the function gets triggered, you can compare the current state, with the last saved state from the db. If there is a difference, you can push the message to the EventHub, that triggers another function that actually reacts on this 'new event-type'.

you should use the Azure Event Grid subscribing to the Resource group of your storage account and use for example, the advanced filtering for

"operationName":"Microsoft.Storage/storageAccounts/blobServices/containers/write",
"subject":"/subscriptions/<yourId>/resourcegroups/<yourRG>/providers/Microsoft.Storage/storageAccounts/<youraccount>/blobServices/default/containers/xxxx-input",
"eventType":"Microsoft.Resources.ResourceWriteSuccess",

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM