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

Microsoft Entra 事件

本文提供由 Microsoft Graph API 发布的 Microsoft Entra 事件的属性和架构。 有关事件架构的简介,请参阅 CloudEvents 架构

可用事件类型

在 Microsoft Entra ID 中创建、更新或删除用户或使用 Microsoft Graph API 对这些资源进行操作时,将触发这些事件。

事件名称 说明
Microsoft.Graph.UserUpdated 在创建或更新 Microsoft Entra ID 中的用户时触发。
Microsoft.Graph.UserDeleted 在永久删除 Microsoft Entra ID 中的用户时触发。
Microsoft.Graph.GroupUpdated 在创建或更新 Microsoft Entra ID 中的组时触发。
Microsoft.Graph.GroupDeleted 在永久删除 Microsoft Entra ID 中的组时触发。

注意

默认情况下,删除用户或组只是软删除操作,这意味着用户或组标记为已删除,但用户或组对象仍然存在。 Microsoft Graph 在软删除用户时发送更新的事件。 若要永久删除用户,请导航到 Azure 门户中的“删除用户”页,然后选择“永久删除”。 永久删除组的步骤类似。

示例事件

触发某个事件后,事件网格服务会将有关该事件的数据发送到订阅目标。 本部分包含每个 Microsoft Entra 事件的数据外观示例。

Microsoft.Graph.UserUpdated 事件

{
  "id": "00d8a100-2e92-4bfa-86e1-0056dacd0fce",
  "type": "Microsoft.Graph.UserUpdated",
  "source": "/tenants/<tenant-id>/applications/<application-id>",
  "subject": "Users/<user-id>",
  "time": "2022-05-24T22:24:31.3062901Z",
  "datacontenttype": "application/json",
  "specversion": "1.0",
  "data": {
    "changeType": "updated",
    "clientState": "<guid>",
    "resource": "Users/<user-id>",
    "resourceData": {
      "@odata.type": "#Microsoft.Graph.User",
      "@odata.id": "Users/<user-id>",
      "id": "<user-id>",
      "organizationId": "<tenant-id>",
      "eventTime": "2022-05-24T22:24:31.3062901Z",
      "sequenceNumber": <sequence-number>
    },
    "subscriptionExpirationDateTime": "2022-05-24T23:21:19.3554403+00:00",
    "subscriptionId": "<microsoft-graph-subscription-id>",
    "tenantId": "<tenant-id>
  }
}

Microsoft.Graph.UserDeleted 事件

{
  "id": "00d8a100-2e92-4bfa-86e1-0056dacd0fce",
  "type": "Microsoft.Graph.UserDeleted",
  "source": "/tenants/<tenant-id>/applications/<application-id>",
  "subject": "Users/<user-id>",
  "time": "2022-05-24T22:24:31.3062901Z",
  "datacontenttype": "application/json",
  "specversion": "1.0",
  "data": {
    "changeType": "deleted",
    "clientState": "<guid>",
    "resource": "Users/<user-id>",
    "resourceData": {
      "@odata.type": "#Microsoft.Graph.User",
      "@odata.id": "Users/<user-id>",
      "id": "<user-id>",
      "organizationId": "<tenant-id>",
      "eventTime": "2022-05-24T22:24:31.3062901Z",
      "sequenceNumber": <sequence-number>
    },
    "subscriptionExpirationDateTime": "2022-05-24T23:21:19.3554403+00:00",
    "subscriptionId": "<microsoft-graph-subscription-id>",
    "tenantId": "<tenant-id>
  }
}

Microsoft.Graph.GroupUpdated 事件

{
  "id": "00d8a100-2e92-4bfa-86e1-0056dacd0fce",
  "type": "Microsoft.Graph.GroupUpdated",
  "source": "/tenants/<tenant-id>/applications/<application-id>",
  "subject": "Groups/<group-id>",
  "time": "2022-05-24T22:24:31.3062901Z",
  "datacontenttype": "application/json",
  "specversion": "1.0",
  "data": {
    "changeType": "updated",
    "clientState": "<guid>",
    "resource": "Groups/<group-id>",
    "resourceData": {
      "@odata.type": "#Microsoft.Graph.Group",
      "@odata.id": "Groups/<group-id>",
      "id": "<group-id>",
      "organizationId": "<tenant-id>",
      "eventTime": "2022-05-24T22:24:31.3062901Z",
      "sequenceNumber": <sequence-number>
    },
    "subscriptionExpirationDateTime": "2022-05-24T23:21:19.3554403+00:00",
    "subscriptionId": "<microsoft-graph-subscription-id>",
    "tenantId": "<tenant-id>
  }
}

Microsoft.Graph.GroupDeleted 事件

{
  "id": "00d8a100-2e92-4bfa-86e1-0056dacd0fce",
  "type": "Microsoft.Graph.GroupDeleted",
  "source": "/tenants/<tenant-id>/applications/<application-id>",
  "subject": "Groups/<group-id>",
  "time": "2022-05-24T22:24:31.3062901Z",
  "datacontenttype": "application/json",
  "specversion": "1.0",
  "data": {
    "changeType": "deleted",
    "clientState": "<guid>",
    "resource": "Groups/<group-id>",
    "resourceData": {
      "@odata.type": "#Microsoft.Graph.Group",
      "@odata.id": "Groups/<group-id>",
      "id": "<group-id>",
      "organizationId": "<tenant-id>",
      "eventTime": "2022-05-24T22:24:31.3062901Z",
      "sequenceNumber": <sequence-number>
    },
    "subscriptionExpirationDateTime": "2022-05-24T23:21:19.3554403+00:00",
    "subscriptionId": "<microsoft-graph-subscription-id>",
    "tenantId": "<tenant-id>
  }
}

事件属性

事件具有以下顶级数据:

属性 类型 说明
source 字符串 租户事件源。 此字段不可写入。 Microsoft Graph API 提供此值。
subject string 事件主题的发布者定义路径。
type string 此事件源的事件类型之一。
time 字符串 事件的生成时间,基于提供程序的 UTC 时间
id 字符串 事件的唯一标识符。
data object 提供有关资源状态更改的数据的事件有效负载。
specversion 字符串 CloudEvents 架构规范版本。

数据对象具有以下属性:

属性 类型 说明
changeType 字符串 资源状态更改的类型。
resource 字符串 针对其引发事件的资源标识符。
tenantId 字符串 保留用户或组的组织 ID。
clientState 字符串 创建 Graph API 订阅时由用户提供的机密。
@odata.type 字符串 Graph API 更改类型。
@odata.id 字符串 针对其引发事件的 Graph API 资源标识符。
id 字符串 针对其引发事件的资源标识符。
organizationId string Microsoft Entra 租户标识符。
eventTime string 资源状态更改的时间。
sequenceNumber string 序列号。
subscriptionExpirationDateTime 字符串 RFC 3339 格式的 Graph API 订阅过期时间。
subscriptionId 字符串 Graph API 订阅标识符。
tenantId string Microsoft Entra 租户标识符。

后续步骤