如何在 Blob 文件为 Uploaded/Updated 时创建 Azure 队列存储消息?

How to Create an Azure Queue Storage Message when a Blob File is Uploaded/Updated?

我正在使用 Azure 存储资源管理器将 blob 文件上传到 Azure 存储帐户。并希望为每个 uploaded/updated 个文件向 Azure 存储队列发送一条消息。

消息将包含文件名。 Azure Webjob 将使用这些消息来识别要处理的文件。

如何实现?有更好的方法吗?

注意:我没有在webjob中使用BlobTrigger因为不能保证它会被触发器通知(according to the documentation).

根据我的经验,BlobTrigger 在大多数情况下都能按预期工作。正如您提到的文件中所述:

If the speed and reliability limitations of blob triggers are not acceptable for your application, the recommended method is to create a queue message when you create the blob, and use the QueueTrigger attribute instead of the BlobTrigger attribute on the function that processes the blob.

正如 evilSnobu 评论的那样,在通过 Azure 存储资源管理器上传 blob 时,没有任何 in-build 功能可以让您向存储队列发送消息。根据你的场景,如果你放弃BlobTrigger,我假设你需要构建你的网站API或服务client-user来上传文件,然后将用户上传的文件上传到你的Azure自行存储并向 back-end 中的存储队列发送消息(例如文件名等)。此时,QueueTrigger 将在您的 WebJob 中触发,您可以处理文件 (blob)。