块 blob 的对象复制Object replication for block blobs

对象复制在源存储帐户和目标帐户之间异步复制块 blob。Object replication asynchronously copies block blobs between a source storage account and a destination account. 对象复制支持的部分方案包括:Some scenarios supported by object replication include:

  • 最大程度地降低延迟。Minimizing latency. 通过使客户端可以从物理位置更接近的区域使用数据,对象复制可以降低读取请求的延迟。Object replication can reduce latency for read requests by enabling clients to consume data from a region that is in closer physical proximity.
  • 提高计算工作负载的效率。Increase efficiency for compute workloads. 通过对象复制,计算工作负载可以在不同区域中处理相同的块 blob 集。With object replication, compute workloads can process the same sets of block blobs in different regions.
  • 优化数据分发。Optimizing data distribution. 您可以在单个位置处理或分析数据,然后仅将结果复制到其他区域。You can process or analyze data in a single location and then replicate just the results to additional regions.
  • 优化成本。Optimizing costs. 复制数据后,可以使用生命周期管理策略将数据转移到存档层,从而降低成本。After your data has been replicated, you can reduce costs by moving it to the archive tier using life cycle management policies.

下图显示了对象复制如何将块 blob 从一个区域中的源存储帐户复制到两个不同区域中的目标帐户。The following diagram shows how object replication replicates block blobs from a source storage account in one region to destination accounts in two different regions.

显示对象复制工作方式的图

若要了解如何配置对象复制,请参阅配置对象复制To learn how to configure object replication, see Configure object replication.

备注

具有分层命名空间 (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.

对象复制的先决条件Prerequisites for object replication

对象复制还需要启用以下 Azure 存储功能:Object replication requires that the following Azure Storage features are also enabled:

启用 blob 版本控制可能会产生额外的成本。Enabling blob versioning may incur additional costs. 有关更多详细信息,请参阅 Azure 存储定价页For more details, refer to the Azure Storage pricing page.

只有常规用途 v2 存储帐户支持对象复制。Object replication is supported only for general-purpose v2 storage accounts. 源帐户和目标帐户都必须是常规用途 v2。Both the source and destination accounts must be general-purpose v2.

对象复制的工作原理How object replication works

对象复制根据你配置的规则异步复制容器中的块 blob。Object replication asynchronously copies block blobs in a container according to rules that you configure. blob 的内容、与 blob 关联的任何版本以及 blob 的元数据和属性都从源容器复制到目标容器。The contents of the blob, any versions associated with the blob, and the blob's metadata and properties are all copied from the source container to the destination container.

重要

因为块 blob 数据是以异步方式复制的,所以源帐户和目标帐户不会立即同步。目前没有关于将数据复制到目标帐户所需时间的 SLA。Because block blob data is replicated asynchronously, the source account and destination account are not immediately in sync. There's currently no SLA on how long it takes to replicate data to the destination account. 你可以在源 blob 上检查复制状态,确定复制是否已完成。You can check the replication status on the source blob to determine whether replication is complete. 有关详细信息,请参阅查看 blob 的复制状态For more information, see Check the replication status of a blob.

Blob 版本控制Blob versioning

对象复制要求同时在源帐户和目标帐户上启用 blob 版本控制。Object replication requires that blob versioning is enabled on both the source and destination accounts. 当源帐户中复制的 blob 被修改时,源帐户中将创建一个新的 blob 版本来反映修改前 blob 以前的状态。When a replicated blob in the source account is modified, a new version of the blob is created in the source account that reflects the previous state of the blob, before modification. 源帐户中(或基 blob)的当前版本反映了最新的更新。The current version (or base blob) in the source account reflects the most recent updates. 更新的当前版本和新的早期版本都将复制到目标帐户。Both the updated current version and the new previous version are replicated to the destination account. 要详细了解写入操作如何影响 blob 版本,请参阅对写入操作进行版本控制For more information about how write operations affect blob versions, see Versioning on write operations.

删除源帐户中的 blob 时,将在先前版本中捕获 blob 的当前版本,然后将其删除。When a blob in the source account is deleted, the current version of the blob is captured in a previous version, and then deleted. 即使删除了当前版本,该 blob 的所有早期版本仍然存在。All previous versions of the blob persist even after the current version is deleted. 此状态将被复制到目标帐户。This state is replicated to the destination account. 要详细了解删除操作如何影响 blob 版本,请参阅对删除操作进行版本控制For more information about how delete operations affect blob versions, see Versioning on delete operations.

快照Snapshots

对象复制不支持 blob 快照。Object replication does not support blob snapshots. 源帐户中 blob 上的任何快照都不会复制到目标帐户。Any snapshots on a blob in the source account are not replicated to the destination account.

Blob 分层Blob tiering

如果源帐户和目标帐户位于热层或冷层,则支持对象复制。Object replication is supported when the source and destination accounts are in the hot or cool tier. 源帐户和目标帐户可能位于不同的层级。The source and destination accounts may be in different tiers. 但如果源帐户或目标帐户中的 blob 已移至存档层,则对象复制将失败。However, object replication will fail if a blob in either the source or destination account has been moved to the archive tier. 有关 blob 层的详细信息,请参阅 Azure Blob 存储的访问层 - 热、冷和存档For more information on blob tiers, see Access tiers for Azure Blob Storage - hot, cool, and archive.

不可变 blobImmutable blobs

对象复制不支持不可变 blob。Object replication does not support immutable blobs. 如果源或目标容器具有基于时间的保留策略或法定保留,则对象复制将失败。If a source or destination container has a time-based retention policy or legal hold, then object replication fails. 有关不可变 blob 的详细信息,请参阅使用不可变存储来存储业务关键型 blob 数据For more information about immutable blobs, see Store business-critical blob data with immutable storage.

对象复制策略和规则Object replication policies and rules

配置对象复制时,需要创建复制策略,以指定源存储帐户和目标帐户。When you configure object replication, you create a replication policy that specifies the source storage account and the destination account. 复制策略包括一个或多个规则,用于指定源容器和目标容器,并指明复制源容器中的哪些块 blob。A replication policy includes one or more rules that specify a source container and a destination container and indicate which block blobs in the source container will be replicated.

配置对象复制以后,Azure 存储会定期检查源帐户的更改源,并将所有写入或删除操作以异步方式复制到目标帐户。After you configure object replication, Azure Storage checks the change feed for the source account periodically and asynchronously replicates any write or delete operations to the destination account. 复制延迟取决于要复制的块 blob 的大小。Replication latency depends on the size of the block blob being replicated.

复制策略Replication policies

配置对象复制时,需要通过 Azure 存储资源提供程序针对源帐户和目标帐户创建复制策略。When you configure object replication, a replication policy is created on both the source account and the destination account via the Azure Storage resource provider. 复制策略通过策略 ID 进行标识。The replication policy is identified by a policy ID. 源帐户和目标帐户的策略必须具有相同的策略 ID,才能进行复制。The policy on the source and destination accounts must have the same policy ID in order for replication to take place.

存储帐户可用作最多两个目标帐户的源帐户。A storage account can serve as the source account for up to two destination accounts. 源帐户和目标帐户可以位于相同区域,也可以位于不同区域。The source and destination accounts may be in the same region or in different regions. 它们还可以位于不同的订阅以及不同的 Azure Active Directory (Azure AD) 租户中。They may also reside in different subscriptions and in different Azure Active Directory (Azure AD) tenants. 只能为每个源帐户/目标帐户对创建一个复制策略。Only one replication policy may be created for each source account/destination account pair.

复制规则Replication rules

复制规则指定 Azure 存储如何将 blob 从源容器复制到目标容器。Replication rules specify how Azure Storage will replicate blobs from a source container to a destination container. 可以为每个复制策略最多指定 10 个复制规则。You can specify up to 10 replication rules for each replication policy. 每个复制规则定义一个源和目标容器,并且每个源和目标容器只能在一个规则中使用。Each replication rule defines a single source and destination container, and each source and destination container can be used in only one rule.

创建复制规则时,默认情况下仅复制随后添加到源容器的新块 blob。When you create a replication rule, by default only new block blobs that are subsequently added to the source container are copied. 你可以指定复制新的和现有的块 blob,也可以定义自定义复制范围,以复制从指定的时间开始创建的块 blob。You can specify that both new and existing block blobs are copied, or you can define a custom copy scope that copies block blobs created from a specified time onward.

也可以将一个或多个筛选器指定为复制规则的一部分,以按前缀筛选块 blob。You can also specify one or more filters as part of a replication rule to filter block blobs by prefix. 指定前缀时,只会将源容器中与该前缀匹配的 blob 复制到目标容器。When you specify a prefix, only blobs matching that prefix in the source container will be copied to the destination container.

源和目标容器必须都存在,然后才能在规则中指定它们。The source and destination containers must both exist before you can specify them in a rule. 创建复制策略后,不允许将操作写入目标容器。After you create the replication policy, write operations to the destination container are not permitted. 任何尝试写入目标容器的操作都会失败,错误代码为 409(冲突)。Any attempts to write to the destination container fail with error code 409 (Conflict). 若要写入为其配置了复制规则的目标容器,则必须删除为该容器配置的规则,或者删除复制策略。To write to a destination container for which a replication rule is configured, you must either delete the rule that is configured for that container, or remove the replication policy. 当复制策略处于活动状态时,允许对目标容器执行读取和删除操作。Read and delete operations to the destination container are permitted when the replication policy is active.

你可以针对目标容器中的 blob 调用设置 Blob 层操作,将其移动到存档层。You can call the Set Blob Tier operation on a blob in the destination container to move it to the archive tier. 有关存档层的详细信息,请参阅 Azure Blob 存储:热、冷和存档访问层For more information about the archive tier, see Azure Blob storage: hot, cool, and archive access tiers.

复制状态Replication status

你可以在源帐户中查看 blob 的复制状态。You can check the replication status for a blob in the source account. 有关详细信息,请参阅查看 blob 的复制状态For more information, see Check the replication status of a blob.

如果源帐户中 blob 的复制状态指示失败,则请调查以下可能的原因:If the replication status for a blob in the source account indicates failure, then investigate the following possible causes:

  • 请确保已在目标帐户上配置对象复制策略。Make sure that the object replication policy is configured on the destination account.
  • 请验证目标容器是否仍然存在。Verify that the destination container still exists.
  • 如果在写入操作中已使用客户提供的密钥对源 blob 进行了加密,则对象复制将失败。If the source blob has been encrypted with a customer-provided key as part of a write operation, then object replication will fail. 有关客户提供的密钥的详细信息,请参阅在对 Blob 存储的请求中提供加密密钥For more information about customer-provided keys, see Provide an encryption key on a request to Blob storage.

计费Billing

对于源帐户和目标帐户的读写事务,对象复制会产生额外的成本,在将数据从源帐户复制到目标帐户时,会产生出站费用,处理更改源时,还会产生读取费用。Object replication incurs additional costs on read and write transactions against the source and destination accounts, as well as egress charges for the replication of data from the source account to the destination account and read charges to process change feed.

后续步骤Next steps