Issues with adding text to Append Blob

Hello,

I would like to use append blob for storing browsing history per user. 

Based on this post - http://blogs.msdn.com/b/windowsazurestorage/archive/2015/04/13/introducing-azure-storage-append-blob.aspx I thought that I don't need to use blob leases since it says - "Append Blob supports having multiple clients writing to the same blob without any need for synchronization (unlike block and page blob)" 

However, when I append text from multiple threads I got the following error : "The remote server returned an error: (412) The append position condition specified was not met.."

This is my code:

try
{
    var storageAccount = CloudStorageAccount.Parse(connectionString);
    var blobClient = storageAccount.CreateCloudBlobClient();
    var container = blobClient.GetContainerReference(containerName);
    await container.CreateIfNotExistsAsync();
   var appendBlob =    container.GetAppendBlobReference(blobPath);
   if (!await appendBlob.ExistsAsync())
   {
     await appendBlob.CreateOrReplaceAsync();
   }
   await appendBlob.AppendTextAsync(text); 
   }
   catch (Exception ex)
   {
     _log.Error("Error in AddTextToAppendBlob", ex);
     throw;
    }



I am not able to find good materials for append blob dealing with this issue.

I guess the problem described above is an issue with the AppendTextAsync method. I found a work around for now that is described here - https://azurekan.wordpress.com/2015/09/08/issues-with-adding-text-to-azure-storage-append-blob/ But it will be great if somebody from the team is able to give a little bit more information what is the right way to use AppendTextAsync.

Thank you!

Kanio


September 9th, 2015 1:45am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics