在 Azure 门户中为事件类型 Microsoft.Storage.BlobCreated 创建主题过滤规则
Creating topic filter rule for event type Microsoft.Storage.BlobCreated in Azure Portal
在 Azure 门户中,我创建了一个 Blob 存储事件,该事件在创建 .zip 文件时触发。该事件的端点是服务总线主题。在本主题中,我有一个具有默认规则的订阅(过滤器 1=1)。
我想创建规则,只传递来自该事件的消息。
通常我会用标签 属性 做一个相关过滤器,但不幸的是,在来自 blob 存储的消息中,这个标签 属性 是空的。
我试过:
SQL 过滤器:
Subject like "%containers/my-test-container/%"
correlation filter with custom property
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 消息的标签 属性?
正如@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
在 Azure 门户中,我创建了一个 Blob 存储事件,该事件在创建 .zip 文件时触发。该事件的端点是服务总线主题。在本主题中,我有一个具有默认规则的订阅(过滤器 1=1)。
我想创建规则,只传递来自该事件的消息。 通常我会用标签 属性 做一个相关过滤器,但不幸的是,在来自 blob 存储的消息中,这个标签 属性 是空的。
我试过:
SQL 过滤器:
Subject like "%containers/my-test-container/%"
correlation filter with custom property
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 消息的标签 属性?
正如@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