充当事件网格源的 Azure Blob 存储

本文提供 Blob 存储事件的属性和架构。 有关事件架构的简介,请参阅 Azure 事件网格事件架构。 它还提供了一个快速入门和教程的列表,这些快速入门和教程介绍如何使用 Azure Blob 存储作为事件源。

注意

只有种类为“StorageV2 (常规用途 v2)”和“BlobStorage”的存储帐户支持事件集成。 “存储(常规用途 v1)”不支持与事件网格集成。

可用事件类型

Blob 存储事件

当客户端通过调用 Blob REST API 创建、替换或删除 Blob 时,将触发这些事件。

注意

$logs$blobchangefeed 容器未与事件网格集成,因此这些容器中的活动将不会生成事件。 此外,将 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 事件

[{
  "source": "/subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/my-storage-account",
  "subject": "/blobServices/default/containers/test-container/blobs/new-file.txt",
  "type": "Microsoft.Storage.BlobCreated",
  "time": "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.chinacloudapi.cn/testcontainer/new-file.txt",
    "sequencer": "00000000000004420000000000028963",
    "storageDiagnostics": {
      "batchId": "b68529f3-68cd-4744-baa4-3c0498ec19f0"
    }
  },
  "specversion": "1.0"
}]

Microsoft.Storage.BlobDeleted 事件

[{
  "source": "/subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/my-storage-account",
  "subject": "/blobServices/default/containers/testcontainer/blobs/file-to-delete.txt",
  "type": "Microsoft.Storage.BlobDeleted",
  "time": "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.chinacloudapi.cn/testcontainer/file-to-delete.txt",
    "sequencer": "0000000000000281000000000002F5CA",
    "storageDiagnostics": {
      "batchId": "b68529f3-68cd-4744-baa4-3c0498ec19f0"
    }
  },
  "specversion": "1.0"
}]

Microsoft.Storage.BlobTierChanged 事件

{
	"source": "/subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/my-storage-account",
	"subject": "/blobServices/default/containers/testcontainer/blobs/Auto.jpg",
	"type": "Microsoft.Storage.BlobTierChanged",
	"time": "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.chinacloudapi.cn/testcontainer/Auto.jpg",
		"sequencer": "000000000000000000000000000089A4000000000018d6ea",
		"storageDiagnostics": {
			"batchId": "3418f7a9-7006-0014-00f6-406dc6000000"
		}
	},
  "specversion": "1.0"
}

Microsoft.Storage.AsyncOperationInitiated 事件

{
	"source": "/subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/my-storage-account",
	"subject": "/blobServices/default/containers/testcontainer/blobs/00000.avro",
	"type": "Microsoft.Storage.AsyncOperationInitiated",
	"time": "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.chinacloudapi.cn/testcontainer/00000.avro",
		"sequencer": "000000000000000000000000000089A4000000000018c6d7",
		"storageDiagnostics": {
			"batchId": "34128c8a-7006-0014-00f4-406dc6000000"
		}
	},
	"specversion": "1.0"
}

Data Lake Storage Gen2 事件

如果在存储帐户上启用分层命名空间,并且客户端使用 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,若要确保 Microsoft.Storage.BlobCreated 事件仅在块 Blob 完全提交后触发,请为 FlushWithClose REST API 调用筛选此事件。 此 API 调用仅在数据已完全提交到块 Blob 后才触发 Microsoft.Storage.BlobCreated 事件。 若要了解如何创建筛选器,请参阅筛选事件网格的事件

示例事件

Microsoft.Storage.BlobCreated 事件 (Data Lake Storage Gen2)

如果 Blob 存储帐户具有分层命名空间,则数据看起来会与上一个示例类似,但以下这些更改除外:

  • data.api 键设置为字符串 CreateFileFlushWithClose
  • contentOffset 键包含在数据集中。

注意

如果应用程序使用 PutBlockList 操作将新的 Blob 上传到帐户,则数据不会包含这些更改。

[{
  "source": "/subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/my-storage-account",
  "subject": "/blobServices/default/containers/my-file-system/blobs/new-file.txt",
  "type": "Microsoft.Storage.BlobCreated",
  "time": "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.chinacloudapi.cn/my-file-system/new-file.txt",
    "sequencer": "00000000000004420000000000028963",  
    "storageDiagnostics": {
    "batchId": "b68529f3-68cd-4744-baa4-3c0498ec19f0"
    }
  },
  "specversion": "1.0"
}]

Microsoft.Storage.BlobDeleted 事件 (Data Lake Storage Gen2)

如果 Blob 存储帐户具有分层命名空间,则数据看起来会与上一个示例类似,但以下这些更改除外:

  • data.api 键设置为字符串 DeleteFile
  • url 键包含路径 dfs.core.chinacloudapi.cn

注意

如果应用程序使用 DeleteBlob 操作从帐户中删除 Blob,则数据不会包含这些更改。

[{
  "source": "/subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/my-storage-account",
  "subject": "/blobServices/default/containers/my-file-system/blobs/file-to-delete.txt",
  "type": "Microsoft.Storage.BlobDeleted",
  "time": "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.chinacloudapi.cn/my-file-system/file-to-delete.txt",
    "sequencer": "00000000000004420000000000028963",  
    "storageDiagnostics": {
    "batchId": "b68529f3-68cd-4744-baa4-3c0498ec19f0"
    }
  },
  "specversion": "1.0"
}]

Microsoft.Storage.BlobRenamed 事件 (Data Lake Storage Gen2)

[{
  "source": "/subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/my-storage-account",
  "subject": "/blobServices/default/containers/my-file-system/blobs/my-renamed-file.txt",
  "type": "Microsoft.Storage.BlobRenamed",
  "time": "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.chinacloudapi.cn/my-file-system/my-renamed-file.txt",
    "sourceUrl": "https://my-storage-account.dfs.core.chinacloudapi.cn/my-file-system/my-original-file.txt",
    "sequencer": "00000000000004420000000000028963",  
    "storageDiagnostics": {
    "batchId": "b68529f3-68cd-4744-baa4-3c0498ec19f0"
    }
  },
  "specversion": "1.0"
}]

Microsoft.Storage.DirectoryCreated 事件 (Data Lake Storage Gen2)

[{
  "source": "/subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/my-storage-account",
  "subject": "/blobServices/default/containers/my-file-system/blobs/my-new-directory",
  "type": "Microsoft.Storage.DirectoryCreated",
  "time": "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.chinacloudapi.cn/my-file-system/my-new-directory",
    "sequencer": "00000000000004420000000000028963",  
    "storageDiagnostics": {
    "batchId": "b68529f3-68cd-4744-baa4-3c0498ec19f0"
    }
  },
  "specversion": "1.0"
}]

Microsoft.Storage.DirectoryRenamed 事件 (Data Lake Storage Gen2)

[{
  "source": "/subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/my-storage-account",
  "subject": "/blobServices/default/containers/my-file-system/blobs/my-renamed-directory",
  "type": "Microsoft.Storage.DirectoryRenamed",
  "time": "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.chinacloudapi.cn/my-file-system/my-renamed-directory",
    "sourceUrl": "https://my-storage-account.dfs.core.chinacloudapi.cn/my-file-system/my-original-directory",
    "sequencer": "00000000000004420000000000028963",  
    "storageDiagnostics": {
    "batchId": "b68529f3-68cd-4744-baa4-3c0498ec19f0"
    }
  },
  "specversion": "1.0"
}]

Microsoft.Storage.DirectoryDeleted 事件 (Data Lake Storage Gen2)

[{
  "source": "/subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/my-storage-account",
  "subject": "/blobServices/default/containers/my-file-system/blobs/directory-to-delete",
  "type": "Microsoft.Storage.DirectoryDeleted",
  "time": "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.chinacloudapi.cn/my-file-system/directory-to-delete",
    "recursive": "true", 
    "sequencer": "00000000000004420000000000028963",  
    "storageDiagnostics": {
    "batchId": "b68529f3-68cd-4744-baa4-3c0498ec19f0"
    }
  },
  "specversion": "1.0"
}]

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 事件是写入文件内容时生成的。

[{
  "source": "/subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/my-storage-account",
  "subject": "/blobServices/default/containers/testcontainer/blobs/new-file.txt",
  "type": "Microsoft.Storage.BlobCreated",
  "time": "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.chinacloudapi.cn/testcontainer/new-file.txt",
    "sequencer": "00000000000004420000000000028963",
    "identity":"localuser",
    "storageDiagnostics": {
    "batchId": "b68529f3-68cd-4744-baa4-3c0498ec19f0"
    }
  },
  "specversion": "1.0"
}]

Microsoft.Storage.BlobDeleted 事件 (SFTP)

如果 Blob 存储帐户使用 SFTP 来删除 Blob,则数据类似于前一示例,不过存在以下差异:

  • dataVersion 键设置为值 2

  • data.api 键设置为字符串 SftpRemove

  • 不包括 clientRequestId 键。

  • contentType 键设置为 application/octet-stream

  • identity 键包含在数据集中。 这与用于 SFTP 身份验证的本地用户相对应。

[{
  "source": "/subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/my-storage-account",
  "subject": "/blobServices/default/containers/testcontainer/blobs/new-file.txt",
  "type": "Microsoft.Storage.BlobDeleted",
  "time": "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.chinacloudapi.cn/testcontainer/new-file.txt",
    "sequencer": "00000000000004420000000000028963",  
    "identity":"localuser",
    "storageDiagnostics": {
    "batchId": "b68529f3-68cd-4744-baa4-3c0498ec19f0"
    }
  },
  "specversion": "1.0"
}]

Microsoft.Storage.BlobRenamed 事件 (SFTP)

如果 Blob 存储帐户使用 SFTP 来重命名 Blob,则数据类似于前一示例,不过存在以下差异:

  • data.api 键设置为字符串 SftpRename

  • 不包括 clientRequestId 键。

  • identity 键包含在数据集中。 这与用于 SFTP 身份验证的本地用户相对应。

[{
  "source": "/subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/my-storage-account",
  "subject": "/blobServices/default/containers/testcontainer/blobs/my-renamed-file.txt",
  "type": "Microsoft.Storage.BlobRenamed",
  "time": "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.chinacloudapi.cn/testcontainer/my-renamed-file.txt",
    "sourceUrl": "https://my-storage-account.blob.core.chinacloudapi.cn/testcontainer/my-original-file.txt",
    "sequencer": "00000000000004420000000000028963",  
    "identity":"localuser",
    "storageDiagnostics": {
    "batchId": "b68529f3-68cd-4744-baa4-3c0498ec19f0"
    }
  },
  "specversion": "1.0"
}]

Microsoft.Storage.DirectoryCreated 事件 (SFTP)

如果 Blob 存储帐户使用 SFTP 来创建目录,则数据类似于前一示例,不过存在以下差异:

  • dataVersion 键设置为值 2

  • data.api 键设置为字符串 SftpMakeDir

  • 不包括 clientRequestId 键。

  • identity 键包含在数据集中。 这与用于 SFTP 身份验证的本地用户相对应。

[{
  "source": "/subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/my-storage-account",
  "subject": "/blobServices/default/containers/testcontainer/blobs/my-new-directory",
  "type": "Microsoft.Storage.DirectoryCreated",
  "time": "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.chinacloudapi.cn/testcontainer/my-new-directory",
    "sequencer": "00000000000004420000000000028963",  
    "identity":"localuser",
    "storageDiagnostics": {
    "batchId": "b68529f3-68cd-4744-baa4-3c0498ec19f0"
    }
  },
  "specversion": "1.0"
}]

Microsoft.Storage.DirectoryRenamed 事件 (SFTP)

如果 Blob 存储帐户使用 SFTP 来重命名目录,则数据类似于前一示例,不过存在以下差异:

  • data.api 键设置为字符串 SftpRename

  • 不包括 clientRequestId 键。

  • identity 键包含在数据集中。 这与用于 SFTP 身份验证的本地用户相对应。

[{
  "source": "/subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/my-storage-account",
  "subject": "/blobServices/default/containers/testcontainer/blobs/my-renamed-directory",
  "type": "Microsoft.Storage.DirectoryRenamed",
  "time": "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.chinacloudapi.cn/testcontainer/my-renamed-directory",
    "sourceUrl": "https://my-storage-account.blob.core.chinacloudapi.cn/testcontainer/my-original-directory",
    "sequencer": "00000000000004420000000000028963",  
    "identity":"localuser",
    "storageDiagnostics": {
    "batchId": "b68529f3-68cd-4744-baa4-3c0498ec19f0"
    }
  },
  "specversion": "1.0"
}]

Microsoft.Storage.DirectoryDeleted 事件 (SFTP)

如果 Blob 存储帐户使用 SFTP 来删除目录,则数据类似于前一示例,不过存在以下差异:

  • data.api 键设置为字符串 SftpRemoveDir

  • 不包括 clientRequestId 键。

  • identity 键包含在数据集中。 这与用于 SFTP 身份验证的本地用户相对应。

[{
  "source": "/subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/my-storage-account",
  "subject": "/blobServices/default/containers/testcontainer/blobs/directory-to-delete",
  "type": "Microsoft.Storage.DirectoryDeleted",
  "time": "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.chinacloudapi.cn/testcontainer/directory-to-delete",
    "recursive": "false", 
    "sequencer": "00000000000004420000000000028963",  
    "identity":"localuser",
    "storageDiagnostics": {
    "batchId": "b68529f3-68cd-4744-baa4-3c0498ec19f0"
    }
  },
  "specversion": "1.0"
}]

执行策略定义的操作时会触发这些事件。

事件名称 说明
Microsoft.Storage.BlobInventoryPolicyCompleted 当为定义为清单策略的规则完成清单运行时触发。 如果清单运行由于在开始运行之前出现用户错误而失败,则也会发生此事件。 例如,无效的策略或在目标容器不存在时出现的错误会触发该事件。
Microsoft.Storage.LifecyclePolicyCompleted 在执行生命周期管理策略定义的操作时触发。

示例事件

触发某个事件后,事件网格服务会将有关该事件的数据发送到订阅终结点。 本部分包含有关每个 Blob 存储事件的数据外观示例。

Microsoft.Storage.BlobInventoryPolicyCompleted event

{
  "source": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/BlobInventory/providers/Microsoft.EventGrid/topics/BlobInventoryTopic",
  "subject": "BlobDataManagement/BlobInventory",
  "type": "Microsoft.Storage.BlobInventoryPolicyCompleted",
  "time": "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.chinacloudapi.cn/inventory-destination-container/2021/05/26/13-25-36/Rule_1/Rule_1.csv"
  },
  "specversion": "1.0"
}

Microsoft.Storage.LifecyclePolicyCompleted event

{
    "source": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/contosoresourcegroup/providers/Microsoft.Storage/storageAccounts/contosostorageaccount",
    "subject": "BlobDataManagement/LifeCycleManagement/SummaryReport",
    "type": "Microsoft.Storage.LifecyclePolicyCompleted",
    "time": "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": ""
        }
    },
    "specversion": "1.0"
}

事件属性

事件具有以下顶级数据:

属性 类型​​ 说明
source string 事件源的完整资源路径。 此字段不可写入。 事件网格提供此值。
subject string 事件主题的发布者定义路径。
type string 此事件源的一个注册事件类型。
time string 基于提供程序 UTC 时间的事件生成时间。
id string 事件的唯一标识符。
data object Blob 存储事件数据。
specversion 字符串 CloudEvents 架构规范版本。

数据对象具有以下属性:

属性 类型​​ 说明
api string 触发事件的操作。
clientRequestId string 客户端提供的用于存储 API 操作的请求 ID。 此 ID 可用于通过 Azure 存储诊断日志中的“client-request-id”字段关联到这些日志,并且可以通过“x-ms-client-request-id”标头提供到客户端请求中。 请参阅日志格式
requestId string 服务生成的用于存储 API 操作的请求 ID。 可用于通过 Azure 存储诊断日志中的“request-id-header”字段关联到这些日志,并且由“x-ms-request-id”标头中的初始化 API 调用返回。 请参阅日志格式
eTag string 可用于根据条件运行操作的值。
contentType string 为 Blob 指定的内容类型。
contentLength integer Blob 大小,以字节为单位。
blobType string Blob 的类型。 有效值为“BlockBlob”或“PageBlob”。
contentOffset number 在事件触发应用程序完成写入文件时执行的写入操作的偏移量(以字节为单位)。
只有对具有分层命名空间的 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.chinacloudapi.cn\<container-name>\<file-name>
如果客户端使用 Data Lake Storage REST API,则 URL 采用以下结构:<storage-account-name>.dfs.core.chinacloudapi.cn/<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。
资源管理器模板:创建 Blob 存储和订阅 部署 Azure Blob 存储帐户并订阅该存储帐户的事件。 它将事件发送到 WebHook。
概述:响应 Blob 存储事件 概述 Blob 存储与事件网格的集成。

后续步骤