【问题标题】:Creating topic filter rule for event type Microsoft.Storage.BlobCreated in Azure Portal在 Azure 门户中为事件类型 Microsoft.Storage.BlobCreated 创建主题筛选规则
【发布时间】:2021-03-23 11:07:29
【问题描述】:

在 Azure 门户中,我创建了一个在创建 .zip 文件时触发的 Blob 存储事件。该事件的端点是一个服务总线主题。在本主题中,我有一个带有默认规则(过滤器 1=1)的订阅。

我想创建规则,它只会传递来自此事件的消息。 通常我会使用 Label 属性进行关联过滤,但不幸的是,在来自 blob 存储的消息中,此 Label 属性为空。

我试过了:

Key Value
eventType Microsoft.Storage.BlobCreated

但是没有用。

我收到的消息:

System and Custom Properties

消息文本:

{
  "topic": ***,
  "subject": "/blobServices/default/containers/my-test-subscription/blobs/test.zip",
  "eventType": "Microsoft.Storage.BlobCreated",
  "id": ***,
  "data": {
    "api": "PutBlob",
    "clientRequestId": ***,
    "requestId": ***,
    "eTag": "0x8D8EDDB53852C51",
    "contentType": "application/x-zip-compressed",
    "contentLength": 1118884,
    "blobType": "BlockBlob",
    "url": "***.blob.core.windows.net/my-test-subscription/test.zip",
    "sequencer": "000000000000000000000000000008CE0000000006ddc175",
    "storageDiagnostics": {
      "batchId": ***
    }
  },
  "dataVersion": "",
  "metadataVersion": "1",
  "eventTime": "2021-03-23T09:09:12.7782481Z"
}

我做错了吗?是否可以设置 blob 消息的 Label 属性?

【问题讨论】:

标签: azure azureservicebus azureportal azure-blob-trigger


【解决方案1】:

正如@GauravMantri 所说,我们无法根据 Azure 服务总线主题中的消息内容定义过滤规则。过滤规则只能基于用户自定义属性和系统属性。

因此,如果您实现该功能,我们就可以在事件网格级别上执行此操作。我们可以创建一个包含事件类型和主题的过滤规则。

例如

"filter": {
            "subjectBeginsWith": "<>",
            "subjectEndsWith": ".zip",
            "includedEventTypes": [
                "Microsoft.Storage.BlobCreated"
            ],
            "advancedFilters": [],
            "enableAdvancedFilteringOnArrays": true
        },

更多详情请参考

https://docs.microsoft.com/en-us/azure/service-bus-messaging/topic-filters

https://docs.microsoft.com/en-us/azure/event-grid/event-filtering

https://docs.microsoft.com/en-us/azure/event-grid/handler-service-bus

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-09
    相关资源
    最近更新 更多