Azure blob 存储:在同一 Azure 存储帐户中复制具有访问层 ARCHIVE 的 blob 不起作用

Azure blob Storage: Copy blobs with access tier ARCHIVE within the same Azure storage account is not working

我正在使用来自 azure-storage java sdk 版本 8.6.5 的 startCopy API 在同一存储帐户内的容器之间复制 blob。根据文档,它将块 blob 的内容、属性和元数据复制到新的块 blob。这是否也意味着源和目标访问层将匹配?

String copyJobId = cloudBlockBlob.startCopy(sourceBlob);

如果源 blob 访问层是 ARCHIVE,我会收到以下异常 -

com.microsoft.azure.storage.StorageException: This operation is not permitted on an archived blob.
    at com.microsoft.azure.storage.StorageException.translateException(StorageException.java:87) ~[azure-storage-8.6.5.jar:?]
    at com.microsoft.azure.storage.core.StorageRequest.materializeException(StorageRequest.java:305) ~[azure-storage-8.6.5.jar:?]
    at com.microsoft.azure.storage.core.ExecutionEngine.executeWithRetry(ExecutionEngine.java:196) ~[azure-storage-8.6.5.jar:?]
    at com.microsoft.azure.storage.blob.CloudBlob.startCopy(CloudBlob.java:791) ~[azure-storage-8.6.5.jar:?]
    at com.microsoft.azure.storage.blob.CloudBlockBlob.startCopy(CloudBlockBlob.java:302) ~[azure-storage-8.6.5.jar:?]
    at com.microsoft.azure.storage.blob.CloudBlockBlob.startCopy(CloudBlockBlob.java:180) ~[azure-storage-8.6.5.jar:?]

如下所示,我使用 startCopy API 将 container02(src) 中的所有 blob 复制到 container03(destination)。具有访问层 ARCHIVE 的 Blob 失败,并且 test1.txt Blob 的访问层与源中的访问层不同。

我只是想确认这是否符合预期,或者我没有使用正确的 API 并且如果我需要源和目标看起来相同,则需要明确设置这些属性??

提前致谢!!!

1. 具有访问层 ARCHIVE 的 Blob 失败

当访问层为 ARCHIVE 时,您无法执行 startCopy 操作。

请参考这个official documentation:

While a blob is in archive storage, the blob data is offline and can't be read, overwritten, or modified. To read or download a blob in archive, you must first rehydrate it to an online tier. You can't take snapshots of a blob in archive storage. However, the blob metadata remains online and available, allowing you to list the blob, its properties, metadata, and blob index tags. Setting or modifying the blob metadata while in archive is not allowed; however you may set and modify the blob index tags. For blobs in archive, the only valid operations are GetBlobProperties, GetBlobMetadata, SetBlobTags, GetBlobTags, FindBlobsByTags, ListBlobs, SetBlobTier, CopyBlob, and DeleteBlob.

2. test1.txt blob 的访问层与源中的不同。

复制的 blob 的访问层可能与默认访问层相关。

解法:

您可能需要将文件从存档存储移动到热或冷访问层。或者您可以使用此 API 并指定 standardBlobTierrehydratePriority:

public final String startCopy(final CloudBlockBlob sourceBlob, String contentMd5, boolean syncCopy, final StandardBlobTier standardBlobTier, RehydratePriority rehydratePriority, final AccessCondition sourceAccessCondition, final AccessCondition destinationAccessCondition, BlobRequestOptions options, OperationContext opContext)