【发布时间】:2021-03-23 11:07:29
【问题描述】:
在 Azure 门户中,我创建了一个在创建 .zip 文件时触发的 Blob 存储事件。该事件的端点是一个服务总线主题。在本主题中,我有一个带有默认规则(过滤器 1=1)的订阅。
我想创建规则,它只会传递来自此事件的消息。 通常我会使用 Label 属性进行关联过滤,但不幸的是,在来自 blob 存储的消息中,此 Label 属性为空。
我试过了:
-
SQL 过滤器:
Subject like "%containers/my-test-container/%"
| Key | Value |
|---|---|
| eventType | Microsoft.Storage.BlobCreated |
但是没有用。
我收到的消息:
消息文本:
{
"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 属性?
【问题讨论】:
-
AFAIK,您无法根据 Azure 服务总线中的消息内容设置过滤规则。
-
您可以改为在事件网格级别应用过滤,并且仅将过滤后的事件发送到您的 Azure 服务总线订阅。详情请参阅:docs.microsoft.com/en-us/azure/event-grid/how-to-filter-events.
标签: azure azureservicebus azureportal azure-blob-trigger