简体   繁体   English

如何从 Azure Append Blob 转换为 Azure Block Blob

[英]How to convert from Azure Append Blob to Azure Block Blob

Is their any any to convert from Append Blob to Block Blob.他们的 any 是从 Append Blob 转换为 Block Blob。

Regards C问候 C

Is their any any to convert from Append Blob to Block Blob .它们是否可以从 Append Blob 转换为 Block Blob 。

Once the blob has been created, its type cannot be changed, and it can be updated only by using operations appropriate for that blob type, ie, writing a block or list of blocks to a block blob, appending blocks to a append blob, and writing pages to a page blob.一旦 blob 被创建,它的类型就不能改变,并且只能通过使用适合该 blob 类型的操作来更新它,即将块或块列表写入块 blob,将块附加到附加 blob,以及将页面写入页面 blob。

More information please refer to this link: Understanding Block Blobs, Append Blobs, and Page Blobs更多信息请参考这个链接: Understanding Block Blobs, Append Blobs, and Page Blobs

For a blob conversion, I am using a对于 blob 转换,我使用的是

--blob-type=BlockBlob 

option at the end of my azcopy.exe statement. azcopy.exe 语句末尾的选项。 So far it works well.到目前为止,它运行良好。

Good luck!祝你好运!

Is their any any to convert from Append Blob to Block Blob .它们是否可以从 Append Blob 转换为 Block Blob 。

Automatic conversion between blob types is not allowed.不允许在 blob 类型之间进行自动转换。 What you would need to do is download the blob and reupload it as Block Blob.您需要做的是下载 Blob 并将其重新上传为 Block Blob。

Given: i have source blob which is append blob鉴于:我有源 blob,它是附加 blob
And: i have to copy source to new blob container as block blob并且:我必须将源作为块 blob 复制到新的 blob 容器
When: i use CopyBlobToBlobckBlobContainer function时间:我使用 CopyBlobToBlobckBlobContainer 函数
Then: destination container will have same blob as source but as block blob.然后:目标容器将具有与源相同的 blob,但与块 blob 相同。

    public void CopyBlobToBlobckBlobContainer(string sourceBlobName)
    {
        var sourceContainerClient = new BlobContainerClient(sourceConnectionString, BlobContainerName);
        var destinationContainerClient = new BlobContainerClient(destinationConnectionString, OutBlobContainerName);
        destinationContainerClient.CreateIfNotExists();
        
        var sourceBlobClient = sourceContainerClient.GetBlockBlobClient(sourceBlobName);
        var sourceUri = sourceBlobClient.GenerateSasUri(BlobSasPermissions.Read, ExpiryOffset);

        var destBlobClient = destinationContainerClient.GetBlockBlobClient(sourceBlobName);
        var result = destBlobClient.SyncUploadFromUri(sourceUri, overwrite: true);
        var response = result.GetRawResponse();
        if (response.Status != 201) throw new BlobCopyException(response.ReasonPhrase);
    }

Use the below command on azure cli.在 azure cli 上使用以下命令。

azcopy copy 'https://<storage-account-name>.<blob or dfs>.core.windows.net/<container-name>/<append-or-page-blob-name>' 'https://<storage-account-name>.<blob or dfs>.core.windows.net/<container-name>/<name-of-new-block-blob>' --blob-type BlockBlob --block-blob-tier <destination-tier>

The --block-blob-tier parameter is optional. --block-blob-tier 参数是可选的。 If you omit that parameter, then the destination blob infers its tier from the default account access tier setting.如果省略该参数,则目标 blob 会根据默认帐户访问层设置推断其层。 To change the tier after you've created a block blob, see Change a blob's tier.若要在创建块 blob 后更改层,请参阅更改 blob 的层。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM