Microsoft Entra 事件

本文說明 Microsoft Entra 事件的屬性和結構描述,這些事件是由 Microsoft Graph API 所發佈。 如需事件結構描述簡介,請參閱 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 string 租用戶事件來源。 此欄位無法寫入。 Microsoft 圖形 API 提供此值。
subject string 發行者定義事件主旨的路徑。
type string 此事件來源的其中一種事件類型。
time string 事件產生的時間,以提供者之 UTC 時間為準
id string 事件的唯一識別碼。
data object 提供關於資源狀態變更之資料的事件承載。
specversion string CloudEvents 結構描述規格版本。

資料物件具有下列屬性:

屬性 類型​ 描述
changeType string 資源狀態變更的類型。
resource string 引起事件的資源識別碼。
tenantId string 保留使用者或群組的組織識別碼。
clientState string 使用者在建立圖形 API 訂用帳戶時所提供的祕密。
@odata.type string 圖形 API 變更類型。
@odata.id string 引起事件的圖形 API 資源識別碼。
id string 引起事件的資源識別碼。
organizationId string Microsoft Entra 租用戶識別碼。
eventTime string 資源狀態變更的時間。
sequenceNumber string 序號。
subscriptionExpirationDateTime string 圖形 API 訂用帳戶到期的時間 (格式為 RFC 3339)。
subscriptionId string 圖形 API 訂用帳戶識別碼。
tenantId string Microsoft Entra 租用戶識別碼。

下一步