blob 的软删除Soft delete for blobs
Blob 的软删除可防止意外地或错误地修改或删除数据。Soft delete for blobs protects your data from being accidentally or erroneously modified or deleted. 为存储帐户启用了 Blob 的软删除时，该存储帐户中的 Blob、Blob 版本（预览版）和快照被删除后可以在指定的保留期内恢复。When soft delete for blobs is enabled for a storage account, blobs, blob versions (preview), and snapshots in that storage account may be recovered after they are deleted, within a retention period that you specify.
如果你的数据有可能被应用程序或其他存储帐户用户意外修改或删除，Azure 建议启用软删除。If there is a possibility that your data may accidentally be modified or deleted by an application or another storage account user, Azure recommends turning on soft delete. 有关启用软删除的详细信息，请参阅启用和管理 Blob 的软删除。For more information about enabling soft delete, see Enable and manage soft delete for blobs.
具有分层命名空间 (Azure Data Lake Storage Gen2) 的帐户尚不支持此功能。This feature is not yet supported in accounts that have a hierarchical namespace (Azure Data Lake Storage Gen2). 若要了解详细信息，请参阅 Azure Data Lake Storage Gen2 中可用的 Blob 存储功能。To learn more, see Blob storage features available in Azure Data Lake Storage Gen2.
关于 Blob 的软删除About soft delete for blobs
在存储帐户上启用了 Blob 的软删除时，可以在已删除对象之后（在指定的数据保留期内）恢复这些对象。When soft delete for blobs is enabled on a storage account, you can recover objects after they have been deleted, within the specified data retention period. 此保护可扩展到因覆盖而擦除的任何 Blob（块 Blob、追加 Blob 或页 Blob）。This protection extends to any blobs (block blobs, append blobs, or page blobs) that are erased as the result of an overwrite.
除非显式列出，否则软删除对象不可见。Soft deleted objects are invisible unless explicitly listed.
Blob 软删除向后兼容，因此无需对应用程序进行任何更改即可利用此功能提供的保护。Blob soft delete is backwards compatible, so you don't have to make any changes to your applications to take advantage of the protections this feature affords. 但是，数据恢复会引入新的撤销删除 Blob API。However, data recovery introduces a new Undelete Blob API.
Blob 软删除适用于新的和现有的常规用途 v2、常规用途 v1 和 Blob 存储帐户。Blob soft delete is available for both new and existing general-purpose v2, general-purpose v1, and Blob storage accounts. 支持标准和高级帐户类型。Both standard and premium account types are supported. Blob 软删除适用于所有存储层，包括热、冷和存档层。Blob soft delete is available for all storage tiers including hot, cool, and archive. 软删除适用于非托管磁盘（实际上是页 blob），但不可用于托管磁盘。Soft delete is available for unmanaged disks, which are page blobs under the covers, but is not available for managed disks.
创建新帐户时，默认禁用软删除。When you create a new account, soft delete is disabled by default. 对于现有的存储帐户，默认情况下也禁用软删除。Soft delete is also disabled by default for existing storage accounts. 可以在任何时候启用或禁用存储帐户的软删除。You can enable or disable soft delete for a storage account at any time.
启用软删除时，必须配置保持期。When you enable soft delete, you must configure the retention period. 保持期指示已软删除数据的存储和可恢复时间期限。The retention period indicates the amount of time that soft deleted data is stored and available for recovery. 对于显式删除的对象，保持期从删除数据时开始计时。For objects that are explicitly deleted, the retention period clock starts when the data is deleted. 对于覆盖数据时软删除功能生成的软删除版本或快照，保持期从生成版本或快照时开始计时。For soft deleted versions or snapshots generated by the soft delete feature when data is overwritten, the clock starts when the version or snapshot is generated. 保持期可能介于 1 到 365 天之间。The retention period may be between 1 and 365 days.
可随时更改软删除保持期。You can change the soft delete retention period at any time. 更新后的保持期仅适用于新删除的数据。An updated retention period applies only to newly deleted data. 之前删除的数据的过期时间取决于删除该数据时配置的保持期。Previously deleted data expires based on the retention period that was configured when that data was deleted. 尝试删除某个软删除的对象不会影响其到期时间。Attempting to delete a soft deleted object does not affect its expiry time.
如果禁用软删除，则可以继续访问和恢复启用该功能时保存在存储帐户中的软删除数据。If you disable soft delete, you can continue to access and recover soft deleted data in your storage account that was saved while the feature was enabled.
保存已删除的数据Saving deleted data
软删除在删除或覆盖对象的许多情况下保存数据。Soft delete preserves your data in many cases where objects are deleted or overwritten.
使用“放置 Blob”、“放置块列表”或“复制 Blob”覆盖 blob 时，将自动生成写入操作前 blob 的状态的版本或快照 。When a blob is overwritten using Put Blob, Put Block List, or Copy Blob, a version or snapshot of the blob's state prior to the write operation is automatically generated. 除非显式列出，否则软删除对象不可见。This object is invisible unless soft-deleted objects are explicitly listed. 请参阅恢复部分，了解如何列出软删除对象。See the Recovery section to learn how to list soft deleted objects.
*软删除数据呈现为灰色，而活动数据为蓝色。新写入的数据显示在旧数据下方。使用 B1 覆盖 B0 时会生成 B0 的软删除快照。使用 B2 覆盖 B1 时会生成 B1 的软删除快照。Soft deleted data is grey, while active data is blue. More recently written data appears beneath older data. When B0 is overwritten with B1, a soft deleted snapshot of B0 is generated. When B1 is overwritten with B2, a soft deleted snapshot of B1 is generated.
对目标 blob 的帐户启用软删除时，软删除仅对复制操作提供覆盖保护。Soft delete only affords overwrite protection for copy operations when it is turned on for the destination blob's account.
软删除不会对存档层中的 blob 提供覆盖保护。Soft delete does not afford overwrite protection for blobs in the archive tier. 如果存档层中的 blob 被任何层中的新 blob 覆盖，则被覆盖的 blob 将永久过期。If a blob in archive is overwritten with a new blob in any tier, the overwritten blob is permanently expired.
对快照调用“删除 Blob”时，该快照会被标记为软删除。When Delete Blob is called on a snapshot, that snapshot is marked as soft deleted. 此时不会生成新的快照。A new snapshot is not generated.
软删除数据呈现为灰色，而活动数据为蓝色。新写入的数据显示在旧数据下方。调用Snapshot Blob时，B0 将变为快照，B1 成为该 blob 的活动状态。如果删除 B0 快照，它将被标记为软删除。Soft deleted data is grey, while active data is blue. More recently written data appears beneath older data. When Snapshot Blob is called, B0 becomes a snapshot and B1 is the active state of the blob. When the B0 snapshot is deleted, it is marked as soft deleted.
如果对基础 blob（本身不是快照的任何 blob）调用“删除 Blob”，该 blob 将被标记为软删除。When Delete Blob is called on a base blob (any blob that is not itself a snapshot), that blob is marked as soft deleted. 与以前的行为一致，对具有活动快照的 blob 调用“删除 Blob”将返回错误。Consistent with previous behavior, calling Delete Blob on a blob that has active snapshots returns an error. 对具有软删除快照的 blob 调用“删除 Blob”不会返回错误。Calling Delete Blob on a blob with soft deleted snapshots does not return an error. 启用软删除后，仍可在单个操作中删除 blob 及其所有快照。You can still delete a blob and all its snapshots in single operation when soft delete is turned on. 执行该操作会将基础 blob 和快照标记为软删除。Doing so marks the base blob and snapshots as soft deleted.
*软删除数据呈现为灰色，而活动数据为蓝色。新写入的数据显示在旧数据下方。此处调用了“删除 Blob”来删除 B2 和所有相关快照 。活动 blob B2 和所有相关快照均被标记为软删除。Soft deleted data is grey, while active data is blue. More recently written data appears beneath older data. Here, a Delete Blob call is made to delete B2 and all associated snapshots. The active blob, B2, and all associated snapshots are marked as soft deleted.
覆盖软删除 blob 时，将自动生成写入操作前 blob 状态的软删除快照。When a soft deleted blob is overwritten, a soft deleted snapshot of the blob's state prior to the write operation is automatically generated. 新 blob 将继承被覆盖 blob 的层级。The new blob inherits the tier of the overwritten blob.
如果删除容器或帐户或者覆盖 blob 元数据和 blob 属性，软删除皆不会保存数据。Soft delete does not save your data in cases of container or account deletes, nor when blob metadata and blob properties are overwritten. 若要防止存储帐户被错误删除，可以使用 Azure 资源管理器配置锁定。To protect a storage account from erroneous deletion, you can configure a lock using the Azure Resource Manager. 有关详细信息，请参阅 Azure 资源管理器文章锁定资源以防止意外更改。For more information, see the Azure Resource Manager article Lock Resources to Prevent Unexpected Changes.
下表详述了启用软删除后的预期行为：The following table details expected behavior when soft delete is turned on:
|REST API 操作REST API operation||资源类型Resource type||说明Description||行为更改Change in behavior|
|删除Delete||帐户Account||删除存储帐户，包括它包含的所有容器和 blob。Deletes the storage account, including all containers and blobs that it contains.||无更改。No change. 已删除帐户中的容器和 blob 不可恢复。Containers and blobs in the deleted account are not recoverable.|
|删除容器Delete Container||容器Container||删除容器，包括它包含的所有 blob。Deletes the container, including all blobs that it contains.||无更改。No change. 已删除容器中的 blob 不可恢复。Blobs in the deleted container are not recoverable.|
|放置 BlobPut Blob||块、追加和页 blobBlock, append, and page blobs||创建新的 blob 或替换容器内的现有 blobCreates a new blob or replaces an existing blob within a container||如果用于替换现有 blob，将自动生成调用之前的 blob 状态的快照。If used to replace an existing blob, a snapshot of the blob's state prior to the call is automatically generated. 对于以前软删除的 blob，当且仅当使用相同类型的 blob （块、追加或页 blob）进行替换时，才会生成快照。This also applies to a previously soft deleted blob if and only if it is replaced by a blob of the same type (Block, append, or Page). 如果由不同类型的 blob 替换，所有现有软删除数据都将永久过期。If it is replaced by a blob of a different type, all existing soft deleted data will be permanently expired.|
|删除 BlobDelete Blob||块、追加和页 blobBlock, append, and page blobs||标记要删除的 blob 或 blob 快照。Marks a blob or blob snapshot for deletion. blob 或快照将稍后在垃圾回收过程中进行删除The blob or snapshot is later deleted during garbage collection||如果用于删除 blob 快照，该快照将标记为软删除。If used to delete a blob snapshot, that snapshot is marked as soft deleted. 如果用于删除 blob，该 blob 将标记为软删除。If used to delete a blob, that blob is marked as soft deleted.|
|复制 BlobCopy Blob||块、追加和页 blobBlock, append, and page blobs||将源 blob 复制到相同存储帐户或其他存储帐户中的目标 blob 中。Copies a source blob to a destination blob in the same storage account or in another storage account.||如果用于替换现有 blob，将自动生成调用之前的 blob 状态的快照。If used to replace an existing blob, a snapshot of the blob's state prior to the call is automatically generated. 对于以前软删除的 blob，当且仅当使用相同类型的 blob （块、追加或页 blob）进行替换时，才会生成快照。This also applies to a previously soft deleted blob if and only if it is replaced by a blob of the same type (Block, append, or Page). 如果由不同类型的 blob 替换，所有现有软删除数据都将永久过期。If it is replaced by a blob of a different type, all existing soft deleted data will be permanently expired.|
|放置块Put Block||块 BlobBlock blobs||创建新块，作为块 blob 的一部分进行提交。Creates a new block to be committed as part of a block blob.||如果用于将块提交到活动 blob 中，则不发生任何更改。If used to commit a block to a blob that is active, there is no change. 如果用于将块提交到软删除的 blob 中，将创建新的 blob 并自动生成快照，以捕获软删除 blob 的状态。If used to commit a block to a blob that is soft deleted, a new blob is created and a snapshot is automatically generated to capture the state of the soft deleted blob.|
|放置块列表Put Block List||块 BlobBlock blobs||通过指定构成块 blob 的块 ID 集来提交 blob。Commits a blob by specifying the set of block IDs that comprise the block blob.||如果用于替换现有 blob，将自动生成调用之前的 blob 状态的快照。If used to replace an existing blob, a snapshot of the blob's state prior to the call is automatically generated. 对于以前软删除的 blob，当且仅当其为块 blob 时，才会生成快照。This also applies to a previously soft deleted blob if and only if it is a block blob. 如果由不同类型的 blob 替换，所有现有软删除数据都将永久过期。If it is replaced by a blob of a different type, all existing soft deleted data will be permanently expired.|
|放置页Put Page||页 BlobPage blobs||将一系列页写入页 blob。Writes a range of pages to a page blob.||无更改。No change. 通过该操作覆盖或清除的页 blob 数据不会保存，且不可恢复。Page blob data that is overwritten or cleared using this operation is not saved and is not recoverable.|
|追加块Append Block||追加 BlobAppend Blobs||将数据块写入追加 Blob 的末尾Writes a block of data to the end of an append blob||无更改。No change.|
|设置 Blob 属性Set Blob Properties||块、追加和页 blobBlock, append, and page blobs||为对 blob 定义的系统属性设置值。Sets values for system properties defined for a blob.||无更改。No change. 被覆盖的 blob 属性不可恢复。Overwritten blob properties are not recoverable.|
|设置 Blob 元数据Set Blob Metadata||块、追加和页 blobBlock, append, and page blobs||将特定 blob 的用户定义元数据设置为一个或多个名称/值对。Sets user-defined metadata for the specified blob as one or more name-value pairs.||无更改。No change. 被覆盖的 blob 元数据不可恢复。Overwritten blob metadata is not recoverable.|
请务必注意，通过调用“Put Page”来覆盖或清除页 blob 的范围时不会自动生成快照。It is important to notice that calling Put Page to overwrite or clear ranges of a page blob will not automatically generate snapshots. 虚拟机磁盘受页 blob 支持，且使用“放置页”来写入数据。Virtual machine disks are backed by page blobs and use Put Page to write data.
对软删除的基础 blob 调用撤销删除 Blob 操作会将该 blob 及所有相关软删除快照还原为活动状态。Calling the Undelete Blob operation on a soft deleted base blob restores it and all associated soft deleted snapshots as active. 对活动基础 blob 调用“撤销删除 Blob”操作会将所有相关软删除快照还原为活动状态。Calling the Undelete Blob operation on an active base blob restores all associated soft deleted snapshots as active. 快照还原为活动状态后与用户生成的快照相似；这些快照不会覆盖基础 blob。When snapshots are restored as active, they look like user-generated snapshots; they do not overwrite the base blob.
若要将 blob 还原到特定的软删除快照，可对基础 blob 调用“撤销删除 Blob”。To restore a blob to a specific soft deleted snapshot, you can call Undelete Blob on the base blob. 然后可将该快照复制到现在处于活动状态的 blob。Then, you can copy the snapshot over the now-active blob. 也可将该快照复制到新的 blob 中。You can also copy the snapshot to a new blob.
软删除数据呈现为灰色，而活动数据为蓝色。新写入的数据显示在旧数据下方。此处对 blob B 调用了撤销删除 Blob，从而将基础 blob B1 和所有相关快照（此处仅为 B0）还原为活动状态。第二步中将 B0 复制到了基础 blob。此复制操作将生成 B1 的软删除快照。Soft deleted data is grey, while active data is blue. More recently written data appears beneath older data. Here, Undelete Blob is called on blob B, thereby restoring the base blob, B1, and all associated snapshots, here just B0, as active. In the second step, B0 is copied over the base blob. This copy operation generates a soft deleted snapshot of B1.
若要查看软删除 blob 和 blob 快照，可选择将已删除数据包含在列表 Blob 中。To view soft deleted blobs and blob snapshots, you can choose to include deleted data in List Blobs. 可选择仅查看软删除的基础 blob，或者也将软删除的 blob 快照包含在内。You can choose to view only soft deleted base blobs, or to include soft deleted blob snapshots as well. 对于所有软删除数据，可以查数据删除的时间以及数据永久过期的剩余天数。For all soft deleted data, you can view the time when the data was deleted as well as the number of days before the data will be permanently expired.
启用软删除后，对名为 HelloWorld 的 blob 执行上传、覆盖、拍摄快照、删除和还原操作。下面为其 .NET 脚本的控制台输出：The following is the console output of a .NET script that uploads, overwrites, snapshots, deletes, and restores a blob named HelloWorld when soft delete is turned on:
Upload: - HelloWorld (is soft deleted: False, is snapshot: False) Overwrite: - HelloWorld (is soft deleted: True, is snapshot: True) - HelloWorld (is soft deleted: False, is snapshot: False) Snapshot: - HelloWorld (is soft deleted: True, is snapshot: True) - HelloWorld (is soft deleted: False, is snapshot: True) - HelloWorld (is soft deleted: False, is snapshot: False) Delete (including snapshots): - HelloWorld (is soft deleted: True, is snapshot: True) - HelloWorld (is soft deleted: True, is snapshot: True) - HelloWorld (is soft deleted: True, is snapshot: False) Undelete: - HelloWorld (is soft deleted: False, is snapshot: True) - HelloWorld (is soft deleted: False, is snapshot: True) - HelloWorld (is soft deleted: False, is snapshot: False) Copy a snapshot over the base blob: - HelloWorld (is soft deleted: False, is snapshot: True) - HelloWorld (is soft deleted: False, is snapshot: True) - HelloWorld (is soft deleted: True, is snapshot: True) - HelloWorld (is soft deleted: False, is snapshot: False)
定价和计费Pricing and billing
所有软删除数据按与活动数据相同的费率计费。All soft deleted data is billed at the same rate as active data. 不会对在配置的保持期后永久删除的数据计费。You will not be charged for data that is permanently deleted after the configured retention period. 若要深入了解快照以及它们产生费用的方式，请参阅了解快照如何产生费用。For a deeper dive into snapshots and how they accrue charges, see Understanding how snapshots accrue charges.
不会对快照自动生成相关事务进行计费。You will not be billed for the transactions related to the automatic generation of snapshots. 将按写入操作费率对“撤销删除 Blob ”事务进行计费。You will be billed for Undelete Blob transactions at the rate for write operations.
初次启用软删除时，Azure 建议使用较短的保持期，以便更好地了解因该功能产生的费用变动。When you initially turn on soft delete, Azure recommends using a short retention period to better understand how the feature will affect your bill.
为频繁覆盖的数据启用软删除可能会导致在列出 Blob 时存储容量费用增加且延迟增加。Enabling soft delete for frequently overwritten data may result in increased storage capacity charges and increased latency when listing blobs. 可以通过将频繁覆盖的数据存储在禁用了软删除的单独存储帐户中来缓解这种额外的成本和延迟问题。You can mitigate this additional cost and latency by storing the frequently overwritten data in a separate storage account where soft delete is disabled.
是否可以使用“设置 Blob 层 API”将 Blob 与软删除的快照置于一层？Can I use the Set Blob Tier API to tier blobs with soft deleted snapshots?
是的。Yes. 软删除的快照会保留在原始层中，但基础 Blob 会移到新层中。The soft deleted snapshots will remain in the original tier, but the base blob will move to the new tier.
高级存储帐户每个 Blob 的快照上限为 100。Premium storage accounts have a per blob snapshot limit of 100. 软删除快照是否计入此限制？Do soft deleted snapshots count toward this limit?
不，软删除快照不记入此限制。No, soft deleted snapshots do not count toward this limit.
如果在启用软删除的情况下删除整个帐户或容器，是否会保存所有相关 Blob？If I delete an entire account or container with soft delete turned on, will all associated blobs be saved?
不会，如果删除整个帐户或容器，将永久删除所有相关 blob。No, if you delete an entire account or container, all associated blobs will be permanently deleted. 若要了详细解如何防止意外删除存储帐户，请参阅锁定资源以防止意外更改。For more information about protecting a storage account from accidental deletes, see Lock Resources to Prevent Unexpected Changes.
能否查看已删除数据的容量指标？Can I view capacity metrics for deleted data?
软删除数据属于存储帐户总容量的一部分。Soft deleted data is included as a part of your total storage account capacity. 有关跟踪和监视存储容量的详细信息，请参阅存储分析。For more information on tracking and monitoring storage capacity, see Storage Analytics.
能否读取和复制 Blob 的软删除快照？Can I read and copy out soft deleted snapshots of my blob?
可以，但必须首先对该 blob 调用撤销删除。Yes, but you must call Undelete on the blob first.
软删除是否适用于虚拟机磁盘？Is soft delete available for virtual machine disks?
软删除适用于高级和标准非托管磁盘（实际上是页 blob）。Soft delete is available for both premium and standard unmanaged disks, which are page blobs under the covers. 软删除只能帮助恢复由“删除 Blob”、“放置 Blob”、“放置块列表”和“复制 Blob”操作删除的数据 。Soft delete will only help you recover data deleted by Delete Blob, Put Blob, Put Block List, and Copy Blob operations. 通过调用放置页覆盖的数据不可恢复。Data overwritten by a call to Put Page is not recoverable.
Azure 虚拟机通过调用“放置页”来写入非托管磁盘，因此不支持使用软删除来撤消从 Azure VM 写入到非托管磁盘的操作。An Azure virtual machine writes to an unmanaged disk using calls to Put Page, so using soft delete to undo writes to an unmanaged disk from an Azure VM is not a supported scenario.
是否需要更改现有应用程序才能使用软删除？Do I need to change my existing applications to use soft delete?
无论使用何种 API 版本，均可以使用软删除。It is possible to take advantage of soft delete regardless of the API version you are using. 但是，若要列出和恢复软删除 blob 和 blob 快照，则需要使用 2017-07-29 版 Azure 存储 REST API 或更高版本。However, to list and recover soft deleted blobs and blob snapshots, you will need to use version 2017-07-29 of the Azure Storage REST API or greater. Azure 建议始终使用最新版的 Azure 存储 API。Azure recommends always using the latest version of the Azure Storage API.