你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

作为 Azure 事件网格命名空间主题订阅中处理程序目标的 Azure 事件中心

事件处理程序是发送事件的位置。 处理程序将通过一个操作来处理事件。 下面是命名空间主题支持的事件处理程序列表:

如果解决方案从事件网格获取事件的速度快于处理事件的速度,请使用事件中心。 事件位于事件中心后,应用程序可以按自己的计划处理事件中心的事件。 可以通过缩放事件处理来处理传入的事件。

消息标头

下面是在发送到事件中心的事件或消息标头中收到的属性:

属性名称 说明
aeg-subscription-name 事件订阅的名称。
aeg-delivery-count 针对该事件进行尝试的次数。
aeg-output-event-id 系统生成的事件 ID。
aeg-compatibility-mode-enabled 此属性仅在通过事件网格命名空间传递时才能使用和设置。 目前,唯一可能的值为 false。 它旨在帮助事件处理程序区分通过事件网格命名空间与通过事件网格自定义主题/系统主题/合作伙伴命名空间等传递的事件。
aeg-metadata-version 事件的元数据版本。 表示云事件架构的规范版本。

REST 示例

使用系统分配的标识,以事件中心作为事件处理程序的事件订阅

{
  "properties": {
    "deliveryConfiguration": {
      "deliveryMode": "Push",
      "push": {
        "deliveryWithResourceIdentity": {
          "identity": {
            "type": "SystemAssigned"
          },
          "destination": {
            "endpointType": "EventHub",
            "properties": {
              "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/{resource-group}/providers/Microsoft.EventHub/namespaces/{namespace-name}/eventhubs/{eventhub-name}"
            }
          }
        }
      }
    }
  }
}

使用用户分配的标识,以事件中心作为事件处理程序的事件订阅

{
  "properties": {
    "deliveryConfiguration": {
      "deliveryMode": "Push",
      "push": {
        "deliveryWithResourceIdentity": {
          "identity": {
            "type": "UserAssigned",
            "userAssignedIdentities": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/{resource-group}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{user-identity-name}"
          },
          "destination": {
            "endpointType": "EventHub",
            "properties": {
              "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/{resource-group}/providers/Microsoft.EventHub/namespaces/{namespace-name}/eventhubs/{eventhub-name}"
            }
          }
        }
      }
    }
  }
}

在事件中心事件处理程序上配置了死信目标的事件订阅

{
  "properties": {
    "deliveryConfiguration": {
      "deliveryMode": "Push",
      "push": {
        "deliveryWithResourceIdentity": {
          "identity": {
            "type": "UserAssigned",
            "userAssignedIdentities": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/{resource-group}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{user-identity-name}"
          },
          "destination": {
            "endpointType": "EventHub",
            "properties": {
              "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/{resource-group}/providers/Microsoft.EventHub/namespaces/{namespace-name}/eventhubs/{eventhub-name}"
            }
          }
        },
        "deadLetterDestinationWithResourceIdentity": {
          "identity": {
            "type": "UserAssigned",
            "userAssignedIdentities": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/{resource-group}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{user-identity-name}"
          },
          "deadLetterDestination": {
            "endpointType": "StorageBlob",
            "properties": {
              "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/{resource-group}/providers/Microsoft.Storage/storageAccounts/{storage-account-name}",
              "blobContainerName": "{blob-container-name}"
            }
          }
        }
      }
    }
  }
}

在事件中心事件处理程序上配置了传递属性的事件订阅

{
  "properties": {
    "deliveryConfiguration": {
      "deliveryMode": "Push",
      "push": {
        "deliveryWithResourceIdentity": {
          "identity": {
            "type": "SystemAssigned"
          },
          "destination": {
            "endpointType": "EventHub",
            "properties": {
              "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/{resource-group}/providers/Microsoft.EventHub/namespaces/{namespace-name}/eventhubs/{eventhub-name}",
              "deliveryAttributeMappings": [
                {
                  "name": "somestaticname",
                  "type": "Static",
                  "properties": {
                    "value": "somestaticvalue"
                  }
                },
                {
                  "name": "somedynamicname",
                  "type": "Dynamic",
                  "properties": {
                    "sourceField": "subject"
                  }
                }
              ]
            }
          }
        }
      }
    }
  }
}

事件中心特定的传递属性

通过事件订阅,可以设置已传递事件中包含的 HTTP 头。 此功能可用于设置目标所需的自定义标头。 可以对传递到 Azure 事件中心的事件设置自定义标头。

如果需要将事件发布到某个事件中心内的特定分区,请在事件订阅上设置 PartitionKey 属性,以指定用于标识目标事件中心分区的分区键。

标头名称 标头类型
PartitionKey 静态或动态

有关详细信息,请参阅《自定义命名空间上的传递属性》。

Azure 门户

创建将事件发送模式设置为“推送”的事件订阅时,可以选择将事件中心作为事件处理程序的类型,并将某个事件中心配置为处理程序。

显示“创建订阅”页的屏幕截图,已为“发送模式”选择“推送”。

有关分步说明,请参阅将事件中心用作命名空间主题的目标

Azure CLI

有关分步说明,请参阅将事件中心配置为目标

后续步骤