Blob 快照Blob snapshots

快照是在某一时间点拍摄的只读版本的 Blob。A snapshot is a read-only version of a blob that's taken at a point in time.

关于 Blob 快照About blob snapshots

备注

本文中所述的功能现在可用于具有分层命名空间的帐户。The features described in this article are now available to accounts that have a hierarchical namespace. 若要查看限制,请参阅 Azure Data Lake Storage Gen2 中可用的 Blob 存储功能一文。To review limitations, see the Blob storage features available in Azure Data Lake Storage Gen2 article.

Blob 的快照与其基本 Blob 相同,不过,Blob URI 的后面追加了一个 DateTime 值,用于指示快照的生成时间。A snapshot of a blob is identical to its base blob, except that the blob URI has a DateTime value appended to the blob URI to indicate the time at which the snapshot was taken. 例如,如果页 Blob URI 为 http://storagesample.core.blob.chinacloudapi.cn/mydrives/myvhd,则快照 URI 将类似于 http://storagesample.core.blob.chinacloudapi.cn/mydrives/myvhd?snapshot=2011-03-09T01:42:34.9360000ZFor example, if a page blob URI is http://storagesample.core.blob.chinacloudapi.cn/mydrives/myvhd, the snapshot URI is similar to http://storagesample.core.blob.chinacloudapi.cn/mydrives/myvhd?snapshot=2011-03-09T01:42:34.9360000Z.

备注

所有快照共享基本 Blob 的 URI。All snapshots share the base blob's URI. 基本 Blob 与快照之间的唯一区别体现在追加的 DateTime 值。The only distinction between the base blob and the snapshot is the appended DateTime value.

一个 Blob 可以有任意数目的快照。A blob can have any number of snapshots. 快照会一直保留,直到被显式删除,这意味着快照的生存期不能长于其基本 Blob。Snapshots persist until they are explicitly deleted, meaning that a snapshot cannot outlive its base blob. 可以枚举与基本 Blob 关联的快照,以跟踪当前快照。You can enumerate the snapshots associated with the base blob to track your current snapshots.

创建 Blob 的快照时,会将该 Blob 的系统属性复制到具有相同值的快照。When you create a snapshot of a blob, the blob's system properties are copied to the snapshot with the same values. 基本 Blob 的元数据也会复制到快照,除非创建快照时为其指定了单独的元数据。The base blob's metadata is also copied to the snapshot, unless you specify separate metadata for the snapshot when you create it. 创建快照后,可以读取、复制或删除它,但无法修改它。After you create a snapshot, you can read, copy, or delete it, but you cannot modify it.

任何与基本 Blob 关联的租约都不会影响快照。Any leases associated with the base blob do not affect the snapshot. 无法获取快照上的租约。You cannot acquire a lease on a snapshot.

VHD 文件用于存储 VM 磁盘的当前信息和状态。A VHD file is used to store the current information and status for a VM disk. 可以将磁盘从 VM 分离或者关闭 VM,并拍摄其 VHD 文件的快照。You can detach a disk from within the VM or shut down the VM, and then take a snapshot of its VHD file. 可以在以后使用该快照文件检索该时间点的 VHD 文件并重新创建 VM。You can use that snapshot file later to retrieve the VHD file at that point in time and recreate the VM.

了解快照如何产生费用Understand how snapshots accrue charges

创建快照(它是 Blob 的只读副本)会导致帐户产生额外的数据存储费用。Creating a snapshot, which is a read-only copy of a blob, can result in additional data storage charges to your account. 在设计应用程序时,有必要了解在哪些情况下会产生这些费用,以便最大程度地减少费用。When designing your application, it is important to be aware of how these charges might accrue so that you can minimize costs.

重要计费注意事项Important billing considerations

以下列表包含创建快照时要考虑的要点。The following list includes key points to consider when creating a snapshot.

  • 不管唯一的块或页是在 Blob 还是快照中,存储帐户都会产生费用。Your storage account incurs charges for unique blocks or pages, whether they are in the blob or in the snapshot. 在更新快照所基于的 Blob 之前,你的帐户不会就与 Blob 关联的快照产生额外费用。Your account does not incur additional charges for snapshots associated with a blob until you update the blob on which they are based. 更新基本 Blob 后,它与其快照分离。After you update the base blob, it diverges from its snapshots. 发生这种情况时,需要支付每个 Blob 或快照中唯一块或页的费用。When this happens, you are charged for the unique blocks or pages in each blob or snapshot.
  • 在替换块 Blob 中的某个块后,会将该块作为唯一块进行收费。When you replace a block within a block blob, that block is subsequently charged as a unique block. 即使该块具有的块 ID 和数据与它在快照中所具有的 ID 和数据相同也是如此。This is true even if the block has the same block ID and the same data as it has in the snapshot. 重新提交块后,它将偏离它在任何快照中的对应部分,并且要为数据支付费用。After the block is committed again, it diverges from its counterpart in any snapshot, and you will be charged for its data. 对于使用相同数据更新的页 Blob 中的页面来说,情况也是如此。The same holds true for a page in a page blob that's updated with identical data.
  • 通过调用 [UploadFromFile][dotnet_UploadFromFile]、[UploadText][dotnet_UploadText]、[UploadFromStream][dotnet_UploadFromStream] 或 [UploadFromByteArray][dotnet_UploadFromByteArray] 方法来替换块 Blob 即可替换该 Blob 中的所有块。Replacing a block blob by calling the [UploadFromFile][dotnet_UploadFromFile], [UploadText][dotnet_UploadText], [UploadFromStream][dotnet_UploadFromStream], or [UploadFromByteArray][dotnet_UploadFromByteArray] method replaces all blocks in the blob. 如果你有与该 Blob 关联的快照,则基本 Blob 和快照中的所有块现在将发生偏离,你需要为这两个 Blob 中的所有块支付费用。If you have a snapshot associated with that blob, all blocks in the base blob and snapshot now diverge, and you will be charged for all the blocks in both blobs. 即使基本 Blob 和快照中的数据保持相同也是如此。This is true even if the data in the base blob and the snapshot remain identical.
  • Azure Blob 服务无法确定这两个块是否包含相同的数据。The Azure Blob service does not have a means to determine whether two blocks contain identical data. 每个上传和提交的块均被视为唯一的快,即使它具有相同的数据和块 ID 也是如此。Each block that is uploaded and committed is treated as unique, even if it has the same data and the same block ID. 由于唯一的块会产生费用,因此必须考虑到:在更新具有快照的 Blob 时,会产生额外的唯一块,因此也会产生额外的费用。Because charges accrue for unique blocks, it's important to consider that updating a blob that has a snapshot results in additional unique blocks and additional charges.

将快照管理成本降至最低Minimize cost with snapshot management

我们建议仔细管理快照,避免额外费用。We recommend managing your snapshots carefully to avoid extra charges. 遵循下述最佳做法可以将存储快照的费用降至最低:You can follow these best practices to help minimize the costs incurred by the storage of your snapshots:

  • 除非应用程序设计需要保留与 Blob 关联的快照,否则请在更新 Blob 时删除并重新创建这些快照,即使你使用相同的数据进行更新也是如此。Delete and re-create snapshots associated with a blob whenever you update the blob, even if you are updating with identical data, unless your application design requires that you maintain snapshots. 通过删除并重新创建 Blob 的快照,可以确保 Blob 和快照不会发生偏离。By deleting and re-creating the blob's snapshots, you can ensure that the blob and snapshots do not diverge.
  • 如果要保留 Blob 的快照,请避免调用 [UploadFromFile][dotnet_UploadFromFile]、[UploadText][dotnet_UploadText]、[UploadFromStream][dotnet_UploadFromStream] 或 [UploadFromByteArray][dotnet_UploadFromByteArray] 来更新该 Blob。If you are maintaining snapshots for a blob, avoid calling [UploadFromFile][dotnet_UploadFromFile], [UploadText][dotnet_UploadText], [UploadFromStream][dotnet_UploadFromStream], or [UploadFromByteArray][dotnet_UploadFromByteArray] to update the blob. 这些方法将替换 Blob 中的所有块,导致基本 Blob 和其快照发生明显偏离。These methods replace all of the blocks in the blob, causing your base blob and its snapshots to diverge significantly. 请改为使用 [PutBlock][dotnet_PutBlock] 和 [PutBlockList][dotnet_PutBlockList] 方法更新尽可能少的块。Instead, update the fewest possible number of blocks by using the [PutBlock][dotnet_PutBlock] and [PutBlockList][dotnet_PutBlockList] methods.

快照计费方案Snapshot billing scenarios

下列方案说明了块 Blob 及其快照如何产生费用。The following scenarios demonstrate how charges accrue for a block blob and its snapshots.

方案 1Scenario 1

在方案 1 中,基本 Blob 自创建快照后未进行更新,因此仅唯一块 1、2 和 3 会产生费用。In scenario 1, the base blob has not been updated after the snapshot was taken, so charges are incurred only for unique blocks 1, 2, and 3.

Azure 存储资源

方案 2Scenario 2

在方案 2 中,已更新基本 Blob,但未更新快照。In scenario 2, the base blob has been updated, but the snapshot has not. 已更新块 3,即使它包含相同的数据和 ID,它也与快照中的块 3 不同。Block 3 was updated, and even though it contains the same data and the same ID, it is not the same as block 3 in the snapshot. 因此,帐户需要为四个块支付费用。As a result, the account is charged for four blocks.

Azure 存储资源

方案 3Scenario 3

在方案 3 中,已更新基本 Blob,但未更新快照。In scenario 3, the base blob has been updated, but the snapshot has not. 块 3 已替换为基础 Blob 中的块 4,但快照仍反映块 3。Block 3 was replaced with block 4 in the base blob, but the snapshot still reflects block 3. 因此,帐户需要为四个块支付费用。As a result, the account is charged for four blocks.

Azure 存储资源

方案 4Scenario 4

在方案 4 中,已完全更新基本 Blob,并且其中不包含任何原始块。In scenario 4, the base blob has been completely updated and contains none of its original blocks. 因此,帐户需要为所有八个唯一块支付费用。As a result, the account is charged for all eight unique blocks. 如果使用 [UploadFromFile][dotnet_UploadFromFile]、[UploadText][dotnet_UploadText]、[UploadFromStream][dotnet_UploadFromStream] 或 [UploadFromByteArray][dotnet_UploadFromByteArray] 等更新方法,则会出现此情况,因为这些方法将替换 Blob 的所有内容。This scenario can occur if you are using an update method such as [UploadFromFile][dotnet_UploadFromFile], [UploadText][dotnet_UploadText], [UploadFromStream][dotnet_UploadFromStream], or [UploadFromByteArray][dotnet_UploadFromByteArray], because these methods replace all of the contents of a blob.

Azure 存储资源

后续步骤Next steps