简体   繁体   English

Azure 函数存储容器 Blob 触发器

[英]Azure Function Storage Container Blob Trigger

Azure Function Storage Account Blob Container Trigger Azure 函数存储帐户 Blob 容器触发器

In one of our use case, i am looking for Azure function trigger for any activity in Storage account containers with following conditions在我们的一个用例中,我正在为具有以下条件的存储帐户容器中的任何活动寻找 Azure 函数触发器

  • Container with a specific naming convention (name like xxxx-input)具有特定命名约定的容器(名称如 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已创建的 Blob
  • BlobDeleted Blob已删除
  • BlobRenamed重命名的 Blob
  • DirectoryCreated(Data lake Gen2)目录创建(数据湖 Gen2)
  • DirectoryRenamed(Data lake Gen2)目录重命名(数据湖 Gen2)
  • DirectoryDeleted(Data lake Gen2)目录已删除(数据湖 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 .您可以利用 Blob Storage v12 SDK 执行此任务,并获取容器列表 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.将列表保存到某个数据库(例如 CosmosDB),每次触发函数时,您都可以将当前状态与数据库中上次保存的状态进行比较。 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'.如果有差异,您可以将消息推送到 EventHub,这会触发另一个实际对这个“新事件类型”做出反应的函数。

you should use the Azure Event Grid subscribing to the Resource group of your storage account and use for example, the advanced filtering for您应该使用订阅存储帐户资源组的 Azure 事件网格,并使用例如高级筛选

"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",

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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