作為 Event Grid 來源的 Azure Blob 儲存體

本文提供 blob 儲存體事件的屬性與結構描述。 如需事件結構描述的簡介,請參閱 Azure Event Grid 事件結構描述。 其也會提供快速入門和教學課程的清單,以使用 Azure Blob 儲存體作為事件來源。

注意

只有種類為 StorageV2 (一般用途 v2)BlockBlobStorageBlobStorage 的儲存體帳戶支援事件整合。 Storage (一般用途 v1)支援與 Event Grid 整合。

可用的事件類型

Blob 儲存體事件

當用戶端藉由呼叫 Blob REST API 來建立、取代或刪除 Blob 時,就會觸發這些事件。

注意

$logs$blobchangefeed 容器未與 Event Grid 整合,因此這些容器中的活動不會產生事件。 此外,針對啟用非階層命名空間的帳戶使用 dfs 端點 (abfss://URI) 並不會產生事件,但 Blob 端點 (wasb:// URI) 則會產生事件。

事件名稱 描述
Microsoft.Storage.BlobCreated 建立或取代 Blob 時觸發。
具體來說,當用戶端使用 Blob REST API 中可用的 PutBlobPutBlockListCopyBlob 作業,並且完全認可區塊 Blob 時,就會觸發此事件。
如果用戶端在已啟用 [階層命名空間] 功能的帳戶上使用 CopyBlob 作業,則 CopyBlob 作業的運作方式稍有不同。 在此情況下,Microsoft.Storage.BlobCreated 事件會在啟動CopyBlob 作業時觸發,而不是在完全認可區塊 Blob 時觸發。
Microsoft.Storage.BlobDeleted 刪除 Blob 時觸發。
具體來說,當用戶端呼叫 Blob REST API 中可用的 DeleteBlob 作業時,就會觸發此事件。
Microsoft.Storage.BlobTierChanged 變更 Blob 存取層時觸發。 具體來說,當用戶端呼叫 Blob REST API 中可用的 Set Blob Tier 作業時,會在階層變更完成之後觸發此事件。
Microsoft.Storage.AsyncOperationInitiated 當啟動的作業涉及到將資料從封存存取層移動或複製到經常性存取層或非經常性存取層時,即會觸發。 具體來說,當用戶端呼叫 Set Blob Tier API 以便將 Blob 從封存存取層移至經常性存取層或非經常性存取層時,或是當用戶端呼叫 Copy Blob API 以便將資料從封存存取層中的 Blob 複製到經常性存取層或非經常性存取層中的 Blob 時,就會觸發此事件。

範例事件

Microsoft.Storage.BlobCreated event

[{
  "topic": "/subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/my-storage-account",
  "subject": "/blobServices/default/containers/test-container/blobs/new-file.txt",
  "eventType": "Microsoft.Storage.BlobCreated",
  "eventTime": "2017-06-26T18:41:00.9584103Z",
  "id": "831e1650-001e-001b-66ab-eeb76e069631",
  "data": {
    "api": "PutBlockList",
    "clientRequestId": "6d79dbfb-0e37-4fc4-981f-442c9ca65760",
    "requestId": "831e1650-001e-001b-66ab-eeb76e000000",
    "eTag": "\"0x8D4BCC2E4835CD0\"",
    "contentType": "text/plain",
    "contentLength": 524288,
    "blobType": "BlockBlob",
    "url": "https://my-storage-account.blob.core.windows.net/testcontainer/new-file.txt",
    "sequencer": "00000000000004420000000000028963",
    "storageDiagnostics": {
      "batchId": "b68529f3-68cd-4744-baa4-3c0498ec19f0"
    }
  },
  "dataVersion": "",
  "metadataVersion": "1"
}]

Microsoft.Storage.BlobDeleted event

[{
  "topic": "/subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/my-storage-account",
  "subject": "/blobServices/default/containers/testcontainer/blobs/file-to-delete.txt",
  "eventType": "Microsoft.Storage.BlobDeleted",
  "eventTime": "2017-11-07T20:09:22.5674003Z",
  "id": "4c2359fe-001e-00ba-0e04-58586806d298",
  "data": {
    "api": "DeleteBlob",
    "requestId": "4c2359fe-001e-00ba-0e04-585868000000",
    "contentType": "text/plain",
    "blobType": "BlockBlob",
    "url": "https://my-storage-account.blob.core.windows.net/testcontainer/file-to-delete.txt",
    "sequencer": "0000000000000281000000000002F5CA",
    "storageDiagnostics": {
      "batchId": "b68529f3-68cd-4744-baa4-3c0498ec19f0"
    }
  },
  "dataVersion": "",
  "metadataVersion": "1"
}]

Microsoft.Storage.BlobTierChanged event

{
	"topic": "/subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/my-storage-account",
	"subject": "/blobServices/default/containers/testcontainer/blobs/Auto.jpg",
	"eventType": "Microsoft.Storage.BlobTierChanged",
	"eventTime": "2021-05-04T15:00:00.8350154Z",
	"id": "0fdefc06-b01e-0034-39f6-4016610696f6",
	"data": {
		"api": "SetBlobTier",
		"clientRequestId": "68be434c-1a0d-432f-9cd7-1db90bff83d7",
		"requestId": "0fdefc06-b01e-0034-39f6-401661000000",
		"contentType": "image/jpeg",
		"contentLength": 105891,
		"blobType": "BlockBlob",
		"url": "https://my-storage-account.blob.core.windows.net/testcontainer/Auto.jpg",
		"sequencer": "000000000000000000000000000089A4000000000018d6ea",
		"storageDiagnostics": {
			"batchId": "3418f7a9-7006-0014-00f6-406dc6000000"
		}
	},
	"dataVersion": "",
	"metadataVersion": "1"
}

Microsoft.Storage.AsyncOperationInitiated event

{
	"topic": "/subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/my-storage-account",
	"subject": "/blobServices/default/containers/testcontainer/blobs/00000.avro",
	"eventType": "Microsoft.Storage.AsyncOperationInitiated",
	"eventTime": "2021-05-04T14:44:59.3204652Z",
	"id": "8ea4e3f2-101e-003d-5ff4-4053b2061016",
	"data": {
		"api": "SetBlobTier",
		"clientRequestId": "777fb4cd-f890-4c5b-b024-fb47300bae62",
		"requestId": "8ea4e3f2-101e-003d-5ff4-4053b2000000",
		"contentType": "application/octet-stream",
		"contentLength": 3660,
		"blobType": "BlockBlob",
		"url": "https://my-storage-account.blob.core.windows.net/testcontainer/00000.avro",
		"sequencer": "000000000000000000000000000089A4000000000018c6d7",
		"storageDiagnostics": {
			"batchId": "34128c8a-7006-0014-00f4-406dc6000000"
		}
	},
	"dataVersion": "",
	"metadataVersion": "1"
}

Data Lake Storage Gen 2 事件

如果您在儲存體帳戶上啟用階層命名空間,而且用戶端使用 Azure Data Lake Storage Gen2 REST API 時,就會觸發這些事件。 如需 Azure Data Lake Storage Gen2 的詳細資訊,請參閱 Azure Data Lake Storage Gen2 簡介

事件名稱 描述
Microsoft.Storage.BlobCreated 建立或取代 Blob 時觸發。
具體來說,當用戶端使用 Azure Data Lake Storage Gen2 REST API 中可用的 CreateFileFlushWithClose 作業時,就會觸發此事件。
Microsoft.Storage.BlobDeleted 刪除 Blob 時觸發。
具體來說,當用戶端呼叫 Azure Data Lake Storage Gen2 REST API 中可用的 DeleteFile 作業時,也會觸發此事件。
Microsoft.Storage.BlobRenamed 重新命名 Blob 時觸發。
具體來說,當用戶端使用 Azure Data Lake Storage Gen2 REST API 中可用的 RenameFile 作業時,就會觸發此事件。
Microsoft.Storage.DirectoryCreated 建立目錄時觸發。
具體來說,當用戶端使用 Azure Data Lake Storage Gen2 REST API 中可用的 CreateDirectory 作業時,就會觸發此事件。
Microsoft.Storage.DirectoryRenamed 重新命名目錄時觸發。
具體來說,當用戶端使用 Azure Data Lake Storage Gen2 REST API 中可用的 RenameDirectory 作業時,就會觸發此事件。
Microsoft.Storage.DirectoryDeleted 刪除目錄時觸發。
具體來說,當用戶端使用 Azure Data Lake Storage Gen2 REST API 中可用的 DeleteDirectory 作業時,就會觸發此事件。

注意

對於 Azure Data Lake Storage Gen2,如果您想要確保只有在完全認可區塊 Blob 時才會觸發 Microsoft.Storage.BlobCreated 事件,請篩選 FlushWithClose REST API 呼叫的事件。 只有在完全將資料認可至區塊 Blob 之後,此 API 呼叫才會觸發 Microsoft.Storage.BlobCreated 事件。 若要了解如何建立篩選,請參閱 Event Grid 的篩選事件

範例事件

Microsoft.Storage.BlobCreated event (Data Lake Storage Gen2)

如果 Blob 儲存體帳戶具有階層命名空間,則資料看起來會與 Blob 儲存體範例類似,但下列變更除外:

  • dataVersion 索引鍵設為 2 的值。

  • data.api 索引鍵設為字串 CreateFileFlushWithClose

  • contentOffset 索引鍵包含在資料集中。

注意

如果應用程式使用 PutBlockList 作業將新的 Blob 上傳至帳戶,則資料不會包含這些變更。

[{
  "topic": "/subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/my-storage-account",
  "subject": "/blobServices/default/containers/my-file-system/blobs/new-file.txt",
  "eventType": "Microsoft.Storage.BlobCreated",
  "eventTime": "2017-06-26T18:41:00.9584103Z",
  "id": "831e1650-001e-001b-66ab-eeb76e069631",
  "data": {
    "api": "CreateFile",
    "clientRequestId": "6d79dbfb-0e37-4fc4-981f-442c9ca65760",
    "requestId": "831e1650-001e-001b-66ab-eeb76e000000",
    "eTag": "\"0x8D4BCC2E4835CD0\"",
    "contentType": "text/plain",
    "contentLength": 0,
    "contentOffset": 0,
    "blobType": "BlockBlob",
    "url": "https://my-storage-account.dfs.core.windows.net/my-file-system/new-file.txt",
    "sequencer": "00000000000004420000000000028963",  
    "storageDiagnostics": {
    "batchId": "b68529f3-68cd-4744-baa4-3c0498ec19f0"
    }
  },
  "dataVersion": "2",
  "metadataVersion": "1"
}]

Microsoft.Storage.BlobDeleted event (Data Lake Storage Gen2)

如果 Blob 儲存體帳戶具有階層命名空間,則資料看起來會與上一個範例類似,但下列變更除外:

  • dataVersion 索引鍵設為 2 的值。

  • data.api 索引鍵設為字串 DeleteFile

  • url 索引鍵包含路徑 dfs.core.windows.net

注意

如果應用程式使用 DeleteBlob 作業從帳戶中刪除 Blob,則資料不會包含這些變更。

[{
  "topic": "/subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/my-storage-account",
  "subject": "/blobServices/default/containers/my-file-system/blobs/file-to-delete.txt",
  "eventType": "Microsoft.Storage.BlobDeleted",
  "eventTime": "2017-06-26T18:41:00.9584103Z",
  "id": "831e1650-001e-001b-66ab-eeb76e069631",
    "data": {
    "api": "DeleteFile",
    "clientRequestId": "6d79dbfb-0e37-4fc4-981f-442c9ca65760",
    "requestId": "831e1650-001e-001b-66ab-eeb76e000000",
    "contentType": "text/plain",
    "blobType": "BlockBlob",
    "url": "https://my-storage-account.dfs.core.windows.net/my-file-system/file-to-delete.txt",
    "sequencer": "00000000000004420000000000028963",  
    "storageDiagnostics": {
    "batchId": "b68529f3-68cd-4744-baa4-3c0498ec19f0"
    }
  },
  "dataVersion": "2",
  "metadataVersion": "1"
}]

Microsoft.Storage.BlobRenamed event (Data Lake Storage Gen2)

[{
  "topic": "/subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/my-storage-account",
  "subject": "/blobServices/default/containers/my-file-system/blobs/my-renamed-file.txt",
  "eventType": "Microsoft.Storage.BlobRenamed",
  "eventTime": "2017-06-26T18:41:00.9584103Z",
  "id": "831e1650-001e-001b-66ab-eeb76e069631",
  "data": {
    "api": "RenameFile",
    "clientRequestId": "6d79dbfb-0e37-4fc4-981f-442c9ca65760",
    "requestId": "831e1650-001e-001b-66ab-eeb76e000000",
    "destinationUrl": "https://my-storage-account.dfs.core.windows.net/my-file-system/my-renamed-file.txt",
    "sourceUrl": "https://my-storage-account.dfs.core.windows.net/my-file-system/my-original-file.txt",
    "sequencer": "00000000000004420000000000028963",  
    "storageDiagnostics": {
    "batchId": "b68529f3-68cd-4744-baa4-3c0498ec19f0"
    }
  },
  "dataVersion": "1",
  "metadataVersion": "1"
}]

Microsoft.Storage.DirectoryCreated event (Data Lake Storage Gen2)

[{
  "topic": "/subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/my-storage-account",
  "subject": "/blobServices/default/containers/my-file-system/blobs/my-new-directory",
  "eventType": "Microsoft.Storage.DirectoryCreated",
  "eventTime": "2017-06-26T18:41:00.9584103Z",
  "id": "831e1650-001e-001b-66ab-eeb76e069631",
  "data": {
    "api": "CreateDirectory",
    "clientRequestId": "6d79dbfb-0e37-4fc4-981f-442c9ca65760",
    "requestId": "831e1650-001e-001b-66ab-eeb76e000000",
    "url": "https://my-storage-account.dfs.core.windows.net/my-file-system/my-new-directory",
    "sequencer": "00000000000004420000000000028963",  
    "storageDiagnostics": {
    "batchId": "b68529f3-68cd-4744-baa4-3c0498ec19f0"
    }
  },
  "dataVersion": "1",
  "metadataVersion": "1"
}]

Microsoft.Storage.DirectoryRenamed event (Data Lake Storage Gen2)

[{
  "topic": "/subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/my-storage-account",
  "subject": "/blobServices/default/containers/my-file-system/blobs/my-renamed-directory",
  "eventType": "Microsoft.Storage.DirectoryRenamed",
  "eventTime": "2017-06-26T18:41:00.9584103Z",
  "id": "831e1650-001e-001b-66ab-eeb76e069631",
  "data": {
    "api": "RenameDirectory",
    "clientRequestId": "6d79dbfb-0e37-4fc4-981f-442c9ca65760",
    "requestId": "831e1650-001e-001b-66ab-eeb76e000000",
    "destinationUrl": "https://my-storage-account.dfs.core.windows.net/my-file-system/my-renamed-directory",
    "sourceUrl": "https://my-storage-account.dfs.core.windows.net/my-file-system/my-original-directory",
    "sequencer": "00000000000004420000000000028963",  
    "storageDiagnostics": {
    "batchId": "b68529f3-68cd-4744-baa4-3c0498ec19f0"
    }
  },
  "dataVersion": "1",
  "metadataVersion": "1"
}]

Microsoft.Storage.DirectoryDeleted event (Data Lake Storage Gen2)

[{
  "topic": "/subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/my-storage-account",
  "subject": "/blobServices/default/containers/my-file-system/blobs/directory-to-delete",
  "eventType": "Microsoft.Storage.DirectoryDeleted",
  "eventTime": "2017-06-26T18:41:00.9584103Z",
  "id": "831e1650-001e-001b-66ab-eeb76e069631",
  "data": {
    "api": "DeleteDirectory",
    "clientRequestId": "6d79dbfb-0e37-4fc4-981f-442c9ca65760",
    "requestId": "831e1650-001e-001b-66ab-eeb76e000000",
    "url": "https://my-storage-account.dfs.core.windows.net/my-file-system/directory-to-delete",
    "recursive": "true", 
    "sequencer": "00000000000004420000000000028963",  
    "storageDiagnostics": {
    "batchId": "b68529f3-68cd-4744-baa4-3c0498ec19f0"
    }
  },
  "dataVersion": "1",
  "metadataVersion": "1"
}]

SFTP 事件

如果您在儲存體帳戶上啟用階層命名空間,而且用戶端使用 SFTP API 時,就會觸發這些事件。 如需 Azure Blob 儲存體中 SFTP 支援的詳細資訊,請參閱 Azure Blob 儲存體中的 SSH 檔案傳輸通訊協定 (SFTP)

事件名稱 描述
Microsoft.Storage.BlobCreated 建立或覆寫 Blob 時觸發。
具體而言,當用戶端使用與 SftpCreateSftpCommit API 對應的 put 作業時,就會觸發此事件。 開啟檔案時會建立空的 Blob,並在關閉檔案時認可上傳的內容。
Microsoft.Storage.BlobDeleted 刪除 Blob 時觸發。
具體而言,當用戶端呼叫與 SftpRemove API 對應的 rm 作業時,也會觸發此事件。
Microsoft.Storage.BlobRenamed 重新命名 Blob 時觸發。
具體而言,當用戶端在檔案上使用與 SftpRename API 對應的 rename 作業時,就會觸發此事件。
Microsoft.Storage.DirectoryCreated 建立目錄時觸發。
具體而言,當用戶端使用與 SftpMakeDir API 對應的 mkdir 作業時,就會觸發此事件。
Microsoft.Storage.DirectoryRenamed 重新命名目錄時觸發。
具體而言,當用戶端在目錄上使用與 SftpRename API 對應的 rename 作業時,就會觸發此事件。
Microsoft.Storage.DirectoryDeleted 刪除目錄時觸發。
具體而言,當用戶端使用與 SftpRemoveDir API 對應的 rmdir 作業時,就會觸發此事件。

範例事件

觸發事件時,事件方格服務會將該事件的相關資料傳送至訂閱端點。 本節包含每個 Blob 儲存體事件的資料外觀範例。

Microsoft.Storage.BlobCreated 事件 (SFTP)

如果 Blob 儲存體帳戶使用 SFTP 來建立或覆寫 Blob,則資料看起來會與上一個範例類似,但下列變更除外:

  • dataVersion 索引鍵設為 3 的值。

  • data.api 索引鍵設為字串 SftpCreateSftpCommit

  • 不包含 clientRequestId 金鑰。

  • contentType 索引鍵設定為 application/octet-stream

  • contentOffset 索引鍵包含在資料集中。

  • identity 索引鍵包含在資料集中。 這會對應至用於 SFTP 驗證的本機使用者。

注意

SFTP 上傳會產生 2 個事件。 一個 SftpCreate 在開啟檔案時用於建立的初始空白 Blob,另一個 SftpCommit 在寫入檔案內容時使用。 如果您想要確保只有在完全認可區塊 Blob 時才會觸發 Microsoft.Storage.BlobCreated 事件,請篩選 SftpCommit REST API 呼叫的事件。

[{
  "topic": "/subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/my-storage-account",
  "subject": "/blobServices/default/containers/testcontainer/blobs/new-file.txt",
  "eventType": "Microsoft.Storage.BlobCreated",
  "eventTime": "2022-04-25T19:13:00.1522383Z",
  "id": "831e1650-001e-001b-66ab-eeb76e069631",
  "data": {
    "api": "SftpCommit",
    "requestId": "831e1650-001e-001b-66ab-eeb76e000000",
    "eTag": "\"0x8D4BCC2E4835CD0\"",
    "contentType": "application/octet-stream",
    "contentLength": 0,
    "contentOffset": 0,
    "blobType": "BlockBlob",
    "url": "https://my-storage-account.blob.core.windows.net/testcontainer/new-file.txt",
    "sequencer": "00000000000004420000000000028963",
    "identity":"localuser",
    "storageDiagnostics": {
    "batchId": "b68529f3-68cd-4744-baa4-3c0498ec19f0"
    }
  },
  "dataVersion": "3",
  "metadataVersion": "1"
}]

Microsoft.Storage.BlobDeleted 事件 (SFTP)

如果 Blob 儲存體帳戶使用 SFTP 來刪除 Blob,則資料看起來會與上一個範例類似,但下列變更除外:

  • dataVersion 索引鍵設為 2 的值。

  • data.api 索引鍵設為字串 SftpRemove

  • 不包含 clientRequestId 金鑰。

  • contentType 索引鍵設定為 application/octet-stream

  • identity 索引鍵包含在資料集中。 這會對應至用於 SFTP 驗證的本機使用者。

[{
  "topic": "/subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/my-storage-account",
  "subject": "/blobServices/default/containers/testcontainer/blobs/new-file.txt",
  "eventType": "Microsoft.Storage.BlobDeleted",
  "eventTime": "2022-04-25T19:13:00.1522383Z",
  "id": "831e1650-001e-001b-66ab-eeb76e069631",
  "data": {
    "api": "SftpRemove",
    "requestId": "831e1650-001e-001b-66ab-eeb76e000000",
    "contentType": "text/plain",
    "blobType": "BlockBlob",
    "url": "https://my-storage-account.blob.core.windows.net/testcontainer/new-file.txt",
    "sequencer": "00000000000004420000000000028963",  
    "identity":"localuser",
    "storageDiagnostics": {
    "batchId": "b68529f3-68cd-4744-baa4-3c0498ec19f0"
    }
  },
  "dataVersion": "2",
  "metadataVersion": "1"
}]

Microsoft.Storage.BlobRenamed 事件 (SFTP)

如果 Blob 儲存體帳戶使用 SFTP 來重新命名 Blob,則資料看起來會與上一個範例類似,但下列變更除外:

  • data.api 索引鍵設為字串 SftpRename

  • 不包含 clientRequestId 金鑰。

  • identity 索引鍵包含在資料集中。 這會對應至用於 SFTP 驗證的本機使用者。

[{
  "topic": "/subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/my-storage-account",
  "subject": "/blobServices/default/containers/testcontainer/blobs/my-renamed-file.txt",
  "eventType": "Microsoft.Storage.BlobRenamed",
  "eventTime": "2022-04-25T19:13:00.1522383Z",
  "id": "831e1650-001e-001b-66ab-eeb76e069631",
  "data": {
    "api": "SftpRename",
    "requestId": "831e1650-001e-001b-66ab-eeb76e000000",
    "destinationUrl": "https://my-storage-account.blob.core.windows.net/testcontainer/my-renamed-file.txt",
    "sourceUrl": "https://my-storage-account.blob.core.windows.net/testcontainer/my-original-file.txt",
    "sequencer": "00000000000004420000000000028963",  
    "identity":"localuser",
    "storageDiagnostics": {
    "batchId": "b68529f3-68cd-4744-baa4-3c0498ec19f0"
    }
  },
  "dataVersion": "1",
  "metadataVersion": "1"
}]

Microsoft.Storage.DirectoryCreated 事件 (SFTP)

如果 Blob 儲存體帳戶使用 SFTP 來建立目錄,則資料看起來會與上一個範例類似,但下列變更除外:

  • dataVersion 索引鍵設為 2 的值。

  • data.api 索引鍵設為字串 SftpMakeDir

  • 不包含 clientRequestId 金鑰。

  • identity 索引鍵包含在資料集中。 這會對應至用於 SFTP 驗證的本機使用者。

[{
  "topic": "/subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/my-storage-account",
  "subject": "/blobServices/default/containers/testcontainer/blobs/my-new-directory",
  "eventType": "Microsoft.Storage.DirectoryCreated",
  "eventTime": "2022-04-25T19:13:00.1522383Z",
  "id": "831e1650-001e-001b-66ab-eeb76e069631",
  "data": {
    "api": "SftpMakeDir",
    "requestId": "831e1650-001e-001b-66ab-eeb76e000000",
    "url": "https://my-storage-account.blob.core.windows.net/testcontainer/my-new-directory",
    "sequencer": "00000000000004420000000000028963",  
    "identity":"localuser",
    "storageDiagnostics": {
    "batchId": "b68529f3-68cd-4744-baa4-3c0498ec19f0"
    }
  },
  "dataVersion": "2",
  "metadataVersion": "1"
}]

Microsoft.Storage.DirectoryRenamed 事件 (SFTP)

如果 Blob 儲存體帳戶使用 SFTP 來重新命名目錄,則資料看起來會與上一個範例類似,但下列變更除外:

  • data.api 索引鍵設為字串 SftpRename

  • 不包含 clientRequestId 金鑰。

  • identity 索引鍵包含在資料集中。 這會對應至用於 SFTP 驗證的本機使用者。

[{
  "topic": "/subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/my-storage-account",
  "subject": "/blobServices/default/containers/testcontainer/blobs/my-renamed-directory",
  "eventType": "Microsoft.Storage.DirectoryRenamed",
  "eventTime": "2022-04-25T19:13:00.1522383Z",
  "id": "831e1650-001e-001b-66ab-eeb76e069631",
  "data": {
    "api": "SftpRename",
    "requestId": "831e1650-001e-001b-66ab-eeb76e000000",
    "destinationUrl": "https://my-storage-account.blob.core.windows.net/testcontainer/my-renamed-directory",
    "sourceUrl": "https://my-storage-account.blob.core.windows.net/testcontainer/my-original-directory",
    "sequencer": "00000000000004420000000000028963",  
    "identity":"localuser",
    "storageDiagnostics": {
    "batchId": "b68529f3-68cd-4744-baa4-3c0498ec19f0"
    }
  },
  "dataVersion": "1",
  "metadataVersion": "1"
}]

Microsoft.Storage.DirectoryDeleted 事件 (SFTP)

如果 Blob 儲存體帳戶使用 SFTP 來刪除目錄,則資料看起來會與上一個範例類似,但下列變更除外:

  • data.api 索引鍵設為字串 SftpRemoveDir

  • 不包含 clientRequestId 金鑰。

  • identity 索引鍵包含在資料集中。 這會對應至用於 SFTP 驗證的本機使用者。

[{
  "topic": "/subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/my-storage-account",
  "subject": "/blobServices/default/containers/testcontainer/blobs/directory-to-delete",
  "eventType": "Microsoft.Storage.DirectoryDeleted",
  "eventTime": "2022-04-25T19:13:00.1522383Z",
  "id": "831e1650-001e-001b-66ab-eeb76e069631",
  "data": {
    "api": "SftpRemoveDir",
    "requestId": "831e1650-001e-001b-66ab-eeb76e000000",
    "url": "https://my-storage-account.blob.core.windows.net/testcontainer/directory-to-delete",
    "recursive": "false", 
    "sequencer": "00000000000004420000000000028963",  
    "identity":"localuser",
    "storageDiagnostics": {
    "batchId": "b68529f3-68cd-4744-baa4-3c0498ec19f0"
    }
  },
  "dataVersion": "1",
  "metadataVersion": "1"
}]

執行原則所定義的動作時,會觸發這些事件。

事件名稱 描述
Microsoft.Storage.BlobInventoryPolicyCompleted 當定義清查原則的規則之清查執行完成時觸發。 如果清查執行失敗,並在使用者開始執行之前發生錯誤,也會發生此事件。 例如,無效的原則或是目的地容器不存在時所發生的錯誤將會觸發事件。
Microsoft.Storage.LifecyclePolicyCompleted 執行生命週期管理原則所定義的動作時觸發。

範例事件

觸發事件時,事件方格服務會將該事件的相關資料傳送至訂閱端點。 本節包含每個 Blob 儲存體事件的資料外觀範例。

Microsoft.Storage.BlobInventoryPolicyCompleted 事件

{
  "topic": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/BlobInventory/providers/Microsoft.EventGrid/topics/BlobInventoryTopic",
  "subject": "BlobDataManagement/BlobInventory",
  "eventType": "Microsoft.Storage.BlobInventoryPolicyCompleted",
  "eventTime": "2021-05-28T15:03:18Z",  
  "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "data": {
    "scheduleDateTime": "2021-05-28T03:50:27Z",
    "accountName": "testaccount",
    "ruleName": "Rule_1",
    "policyRunStatus": "Succeeded",
    "policyRunStatusMessage": "Inventory run succeeded, refer manifest file for inventory details.",
    "policyRunId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "manifestBlobUrl": "https://testaccount.blob.core.windows.net/inventory-destination-container/2021/05/26/13-25-36/Rule_1/Rule_1.csv"
  },
  "dataVersion": "1.0",
  "metadataVersion": "1"
}

Microsoft.Storage.LifecyclePolicyCompleted 事件

{
    "topic": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/contosoresourcegroup/providers/Microsoft.Storage/storageAccounts/contosostorageaccount",
    "subject": "BlobDataManagement/LifeCycleManagement/SummaryReport",
    "eventType": "Microsoft.Storage.LifecyclePolicyCompleted",
    "eventTime": "2022-05-26T00:00:40.1880331",    
    "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "data": {
        "scheduleTime": "2022/05/24 22:57:29.3260160",
        "deleteSummary": {
            "totalObjectsCount": 16,
            "successCount": 14,
            "errorList": ""
        },
        "tierToCoolSummary": {
            "totalObjectsCount": 0,
            "successCount": 0,
            "errorList": ""
        },
        "tierToArchiveSummary": {
            "totalObjectsCount": 0,
            "successCount": 0,
            "errorList": ""
        }
    },
    "dataVersion": "1",
    "metadataVersion": "1"
}

事件屬性

事件具有下列的最高層級資料:

屬性 類型​ 描述
topic string 事件來源的完整資源路徑。 此欄位無法寫入。 事件方格提供此值。
subject string 發行者定義事件主旨的路徑。
eventType string 此事件來源已註冊的事件類型之一。
eventTime string 事件產生的時間,以提供者的 UTC 時間為準。
id string 事件的唯一識別碼。
data object blob 儲存體帳戶。
dataVersion string 資料物件的結構描述版本。 發行者會定義結構描述版本。
metadataVersion string 事件中繼資料的結構描述版本。 「事件方格」會定義最上層屬性的結構描述。 事件方格提供此值。

資料物件具有下列屬性:

屬性 類型​ 描述
api string 觸發事件的作業。
clientRequestId string 儲存體 API 作業由用戶端所提供的要求識別碼。 此識別碼可用於利用記錄中的 "client-request-id" 欄位與 Azure 儲存體診斷記錄建立關聯,並且可使用 "x-ms-client-request-id" 標頭於用戶端要求中提供。 請參閱記錄格式
requestId string 儲存體 API 作業由服務所產生的要求識別碼。 可用於利用記錄中的 "request-id-header" 欄位與 Azure 儲存體診斷記錄建立關聯,並從 'x-ms-request-id' 標頭中的 API 呼叫初始化傳回。 請參閱記錄格式
eTag string 此值可讓您依條件執行作業。
contentType string 為 blob 指定內容類型。
contentLength 整數 Blob 大小 (以位元組為單位)。
blobType string Blob 的類型。 有效值為 "BlockBlob" 或 "PageBlob"。
contentOffset 數值 在事件觸發應用程式完成寫入至檔案的作業時,所發生的寫入作業的位元組位移。
只有當事件是在具有階層命名空間的 Blob 儲存體帳戶上觸發時,才會出現此情形。
destinationUrl string 作業完成之後會存在的檔案 URL。 例如,如果重新命名檔案,destinationUrl 屬性會包含新檔案名稱的 URL。
只有當事件是在具有階層命名空間的 Blob 儲存體帳戶上觸發時,才會出現此情形。
sourceUrl string 作業完成之前就存在的檔案 URL。 例如,如果重新命名檔案,則 sourceUrl 會包含在重新命名作業之前的原始檔案名稱 URL。
只有當事件是在具有階層命名空間的 Blob 儲存體帳戶上觸發時,才會出現此情形。
url string blob 的路徑。
如果用戶端使用 Blob REST API,則 URL 會具有此結構:<storage-account-name>.blob.core.windows.net\<container-name>\<file-name>
如果用戶端使用 Data Lake Storage REST API,則 URL 會具有此結構:<storage-account-name>.dfs.core.windows.net/<file-system-name>/<file-name>
recursive string True 可在所有子目錄上執行作業;否則為 False
只有當事件是在具有階層命名空間的 Blob 儲存體帳戶上觸發時,才會出現此情形。
sequencer string 不透明的字串值表示任何特定 Blob 名稱之事件的邏輯順序。 使用者可使用標準字串比較,以了解 Blob 名稱相同之兩個事件的相對順序。
identity string 字串值,表示與事件相關聯的身分識別。 針對 SFTP,這是本機使用者名稱。
storageDiagnostics object Azure 儲存體服務偶爾包含診斷資料。 出現時,事件消費者應該予以忽略。

教學課程和操作說明

標題 描述
快速入門:使用 Azure CLI 將 Blob 儲存體事件路由至自訂的 Web 端點 示範如何使用 Azure CLI 將 Blob 儲存體事件傳送至 WebHook。
快速入門:使用 PowerShell 將 Blob 儲存體事件路由至自訂的 Web 端點 示範如何使用 Azure PowerShell 將 Blob 儲存體事件傳送至 WebHook。
快速入門:使用 Azure 入口網站建立和路由傳送 Blob 儲存體事件 示範如何使用入口網站將 Blob 儲存體事件傳送至 WebHook。
Azure CLI:訂閱 Blob 儲存體帳戶的事件 訂閱 Blob 儲存體帳戶事件的範例指令碼。 它會將事件傳送至 WebHook。
PowerShell:訂閱 Blob 儲存體帳戶的事件 訂閱 Blob 儲存體帳戶事件的範例指令碼。 它會將事件傳送至 WebHook。
Resource Manager 範本:建立 Blob 儲存體和訂用帳戶 部署 Azure Blob 儲存體帳戶及訂閱該儲存體帳戶的事件。 它會將事件傳送到 WebHook。
概觀:回應 Blob 儲存體事件 整合 Blob 儲存體與事件方格的概觀。

下一步