Add text to Blob in Azure

Looking at this blobs tutorial: channel 9 , I thought of using a blob container to save a bunch of tweets (saving the json of every tweet that is). Ideally, I would like to create a blob link for every hour of the day and add new tweets to this blob as they become available. The problem is that the UploadText (string) method overwrites the existing blob content, is there an easy way to add text to an existing blob?

Thanks!

fun (json:string) -> let account = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("DataConnectionString")) let blobs = account.CreateCloudBlobClient(); let tempBlob = blobs.GetBlobReference("tweets/2010-9-26/17/201092617.txt") tempBlob.Properties.ContentType <- "text/plain" tempBlob.UploadText(json) 
+4
source share
3 answers

The Blobs page is the way to go. (vs block blobs)

You create a blob using the Put Blob operation: http://msdn.microsoft.com/en-us/library/dd179451.aspx

Then you can add “pages” using the “Place Page” operation: http://msdn.microsoft.com/en-us/library/ee691975.aspx

Page Blobs will modify pages added immediately and more accurately mimic traditional file systems.

Blockblocks expect a more complex construct, and require a two-phase submit / commit construct. After compilation, you must overwrite to compensate for blob. Block locking is intended for streaming static (weak definition) content, as well as a read / write repository. Blob pages have been added to support these scenarios.

+4
source

Azure now supports Add Blobs . When you create a new blob, you must define it as an additional block. You cannot add to existing block blocks.

Here is a simple code you can use.

Append:

 CloudAppendBlob appendBlob = container.GetAppendBlobReference("myblob.txt") appendBlob.AppendText("new line"); 

Reading:

 appendBlob.DownloadText() 

The technique contains a good tutorial on this. In addition, Azure's official documentation now includes help for using Append Blob.

+6
source

You can try to get a list of blocked blocks using the CloudBlockBlob.DownloadBlockList () method, and then add new content via CloudBlockBlob.PutBlock () .

+1
source

All Articles