Chips
Chips

Reputation: 65

How to convert from Azure Append Blob to Azure Block Blob

Is their any any to convert from Append Blob to Block Blob .

Regards C

Upvotes: 3

Views: 5967

Answers (5)

Deependra Singh
Deependra Singh

Reputation: 481

Use the below command on 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. If you omit that parameter, then the destination blob infers its tier from the default account access tier setting. To change the tier after you've created a block blob, see Change a blob's tier.

Upvotes: 0

Gurpreet
Gurpreet

Reputation: 1442

Given: i have source blob which is append blob
And: i have to copy source to new blob container as block blob
When: i use CopyBlobToBlobckBlobContainer function
Then: destination container will have same blob as source but as block 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);
    }

Upvotes: 0

Mac MK
Mac MK

Reputation: 21

For a blob conversion, I am using a

--blob-type=BlockBlob 

option at the end of my azcopy.exe statement. So far it works well.

Good luck!

Upvotes: 2

Shui shengbao
Shui shengbao

Reputation: 19195

Is their any any to convert from Append Blob to 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, i.e., writing a block or list of blocks to a block blob, appending blocks to a append blob, and writing pages to a page blob.

More information please refer to this link: Understanding Block Blobs, Append Blobs, and Page Blobs

Upvotes: 1

Gaurav Mantri
Gaurav Mantri

Reputation: 136196

Is their any any to convert from Append Blob to Block Blob .

Automatic conversion between blob types is not allowed. What you would need to do is download the blob and reupload it as Block Blob.

Upvotes: 0

Related Questions