Azure AppendBlob number of block/writes

2019-05-21 13:01发布

问题:

I am using AppendBlob in Azure for logging. After some time I experienced 409 Conflict Error. My guess is the maximal amount of block/writes (50.000) was reached.

Is there any way to get count of blocks/writes in the blob?

回答1:

In Azure Reference, you can find the table of Blob Service Error Codes which list the error codes may be returned by an operation against the Blob service includes Conflict 409, please see below.

The details for the maximums of AppendBlob, you can refer to the section About Append Blobs of the reference page Understanding Block Blobs, Append Blobs, and Page Blobs as below.

Each block in an append blob can be a different size, up to a maximum of 4 MB, and an append blob can include up to 50,000 blocks. The maximum size of an append blob is therefore slightly more than 195 GB (4 MB X 50,000 blocks).

As @yonisha said, if using REST API Append Block, you can get the block count for AppendBlob via get the response header x-ms-blob-committed-block-count which is the number of committed blocks present in the blob and can be used to control how many more appends can be done.

For C#, getting the block count via the property AppendBlobCommittedBlockCount form the BlobProperties for the object CloudAppendBlob, please see the reference BlobProperties.AppendBlobCommittedBlockCount Property.



回答2:

For C# you can simply issue appendBlob.Properties.AppendBlobCommittedBlockCount.

Wissam



回答3:

As written in the Operations on Append blob documentation, the only specific available operation on Append blob type is the 'Append Block' operation.

Nevertheless, you can get the committed block count from the x-ms-blob-committed-block-count response header of the Append Block operation. From the documentation:

The number of committed blocks present in the blob. This can be used to control how many more appends can be done.