Azure 事件网格中的系统主题System topics in Azure Event Grid

事件网格中的系统主题表示由 Azure 服务(如 Azure 存储和 Azure 事件中心)发布的一个或多个事件。A system topic in Event Grid represents one or more events published by Azure services such as Azure Storage and Azure Event Hubs. 例如,一个系统主题可以表示已为特定存储帐户发布的所有 Blob 事件或仅“Blob 已创建”和“Blob 已删除”事件 。For example, a system topic may represent all blob events or only blob created and blob deleted events published for a specific storage account. 在此示例中,当 Blob 上传到存储帐户时,Azure 存储服务会将“Blob 已创建”事件发布到事件网格中的系统主题,然后,事件网格会将该事件转发给接收和处理该事件的主题订阅服务器In this example, when a blob is uploaded to the storage account, the Azure Storage service publishes a blob created event to the system topic in Event Grid, which then forwards the event to topic's subscribers that receive and process the event.

备注

只有 Azure 服务才可以将事件发布到系统主题。Only Azure services can publish events to system topics. 因此,你不会获得一个可用来像你为自定义主题或域一样发布事件的终结点或访问密钥。Therefore, you don't get an endpoint or access keys that you can use to publish events like you do for custom topics or domains.

支持系统主题的 Azure 服务Azure services that support system topics

下面是支持创建系统主题的 Azure 服务的当前列表。Here is the current list of Azure services that support creation of system topics on them.

作为 Azure 资源的系统主题System topics as Azure resources

在过去,系统主题是隐式的,并且为了简单起见而未公开。In the past, a system topic was implicit and wasn't exposed for simplicity. 系统主题现在作为 Azure 资源可见,并提供以下功能:System topics are now visible as Azure resources and provide the following capabilities:

系统主题的生命周期Lifecycle of system topics

可以通过两种方式创建系统主题:You can create a system topic in two ways:

  • 创建 Azure 资源的事件订阅作为扩展资源,这会自动创建名称采用以下格式的系统主题:<Azure resource name>-<GUID>Create an event subscription on an Azure resource as an extension resource, which automatically creates a system topic with the name in the format: <Azure resource name>-<GUID>. 删除该主题的最后一个事件订阅时,以这种方式创建的系统主题将会自动删除。The system topic created in this way is automatically deleted when the last event subscription for the topic is deleted.

  • 为 Azure 资源创建系统主题,然后为该系统主题创建事件订阅。Create a system topic for an Azure resource, and then create an event subscription for that system topic. 使用此方法时,可以为系统主题指定一个名称。When you use this method, you can specify a name for the system topic. 删除最后一个事件订阅时,系统主题不会自动删除。The system topic isn't deleted automatically when the last event subscription is deleted. 需要手动将其删除。You need to manually delete it.

    使用 Azure 门户时,始终要使用此方法。When you use the Azure portal, you are always using this method. 使用 Azure 资源的“事件”页创建事件订阅时,将首先创建系统主题,然后创建该主题的订阅。When you create an event subscription using the Events page of an Azure resource, the system topic is created first and then the subscription for the topic is created. 可以先使用“事件网格系统主题”页显式创建系统主题,然后创建该主题的订阅。You can explicitly create a system topic first by using the Event Grid System Topics page and then create a subscription for that topic.

使用 CLIRESTAzure 资源管理器模板时,可以选择上述两种方法之一。When you use CLI, REST, or Azure Resource Manager template, you can choose either of the above methods. 建议先创建一个系统主题,然后创建该主题的订阅,因为这是创建系统主题的最新方法。We recommend that you create a system topic first and then create a subscription on the topic, as this is the latest way of creating system topics.

如果设置 Azure 策略的方式导致事件网格服务无法创建系统主题,则系统主题创建将失败。The system topic creation fails if you have set up Azure policies in such a way that the Event Grid service can't create it. 例如,你的某个策略可能仅允许在订阅中创建特定类型的资源(例如:Azure 存储、Azure 事件中心等)。For example, you may have a policy that allows creation of only certain types of resources (for example: Azure Storage, Azure Event Hubs, etc.) in the subscription.

系统主题的位置和资源组Location and resource group for a system topic

对于位于特定区域/位置的 Azure 事件源,将在与 Azure 事件源相同的位置创建系统主题。For Azure event sources that are in a specific region/location, system topic is created in the same location as the Azure event source. 例如,如果为中国北部的 Azure Blob 存储创建事件订阅,则会在中国北部创建系统主题。For example, if you create an event subscription for an Azure blob storage in China North, the system topic is created in China North. 对于 Azure 订阅、资源组或 Azure Maps 等全局 Azure 事件源,事件网格会在全局位置创建系统主题。For global Azure event sources such as Azure subscriptions, resource groups, or Azure Maps, Event Grid creates the system topic in global location.

通常,系统主题在 Azure 事件源所在的资源组中创建。In general, system topic is created in the same resource group that the Azure event source is in. 对于在 Azure 订阅范围内创建的事件订阅,系统主题在资源组“Default-EventGrid” 下创建。For event subscriptions created at Azure subscription scope, system topic is created under the resource group Default-EventGrid. 如果该资源组不存在,则 Azure 事件网格会在创建系统主题之前创建该资源组。If the resource group doesn't exist, Azure Event Grid creates it before creating the system topic.

后续步骤Next steps

请参阅以下文章:See the following articles: