Question

What is the behaviour of CloudBlockBlob.UploadText if the blob already exist? does it append to the existing blob? or throws an exception?

Was it helpful?

Solution

If you call CloudBlockBlob.UploadText on an existing blob, the contents of the blob will be updated with the new text. Old contents will be overwritten.

To append text to an existing blob, you could do two things:

  1. Before calling UploadText, get the contents of the blob by downloading the blob and append the new text and then call UploadText. This would work fine for small sized blobs but not for large sized blobs.
  2. Make sure the original blob is uploaded by uploading in chunks i.e. using PutBlock and PutBlockList. Then you get the block list before uploading, append a new block to your blob and then call PutBlockList to commit the changes. This may be an overkill for small sized blobs but work well for large sized blobs.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top