title: Azure CloudAppendBlob errors with concurrent access
body: <p>My understanding was that the Azure CloudAppendBlob was safe from concurrency issues as you can only append to this blob storage and it does not need to compare E-tags. As stated by this post: </p>
  
  <p><a href="http://blogs.msdn.com/b/windowsazurestorage/archive/2015/04/13/introducing-azure-storage-append-blob.aspx" rel="noreferrer">http://blogs.msdn.com/b/windowsazurestorage/archive/2015/04/13/introducing-azure-storage-append-blob.aspx</a></p>
  
  <p>specifically:</p>
  
  <blockquote>
    <p>In addition, Append Blob supports having multiple clients writing to the same blob without any need for synchronization (unlike block and page blob)</p>
  </blockquote>
  
  <p>However the following unit test raises:</p>
  
  <blockquote>
    <p>412 the append position condition specified was not met.</p>
  </blockquote>
  
  <p>stack trace</p>
  
  <pre><code>Microsoft.WindowsAzure.Storage.Blob.BlobWriteStream.Flush()
  Microsoft.WindowsAzure.Storage.Blob.BlobWriteStream.Commit()
  Microsoft.WindowsAzure.Storage.Blob.CloudAppendBlob.UploadFromStreamHelper
  Microsoft.WindowsAzure.Storage.Blob.CloudAppendBlob.AppendFromStream
  Microsoft.WindowsAzure.Storage.Blob.CloudAppendBlob.AppendFromByteArray
  Microsoft.WindowsAzure.Storage.Blob.CloudAppendBlob.AppendText
  </code></pre>
  
  <p>Here is the unit test. Maybe the service will handle requests from different contexts but not like this as a parallel? </p>
  
  <pre><code>    [TestMethod]
      public void test_append_text_concurrency()
      {
          AppendBlobStorage abs = new AppendBlobStorage(new    TestConnectConfig(), "testappendblob");
  
          string filename = "test-concurrent-blob";
  
          abs.Delete(filename);                       
  
          Parallel.Invoke(
              () =&gt; { abs.AppendText(filename, "message1\r\n"); },
              () =&gt; { abs.AppendText(filename, "message2\r\n"); }
          );
  
          string text = abs.ReadText(filename);
  
          Assert.IsTrue(text.Contains("message1"));
          Assert.IsTrue(text.Contains("message2"));
      }
  </code></pre>
  
  <p>Method in AppendBlobStorage</p>
  
  <pre><code>    public void AppendText(string filename, string text)
      {
          CloudAppendBlob cab = m_BlobStorage.BlobContainer.GetAppendBlobReference(filename);
  
          // Create if it doesn't exist
          if (!cab.Exists())
          {
              try
              {
                  cab.CreateOrReplace(AccessCondition.GenerateIfNotExistsCondition(), null, null);
              }
              catch { }
          }
  
          // Append the text
          cab.AppendText(text);      
      }
  </code></pre>
  
  <p>Maybe I'm missing something. The reason I'm trying to do this as I have multiple web jobs which can all write to this append blob and I figured this was what it was designed for?</p>