title: Very occasional 400 Bad Request error when posting to Azure Blob Storage
body: <p>I'm using Azure Blob Storage to cache the intermediate results of some calculations. It all works great, except for very occasionally, the Azure blob storage client returns an error like this:</p>
  
  <p><code>The remote server returned an error: (400) Bad Request.</code></p>
  
  <p>The C# code in question looks like this:</p>
  
  <pre><code>public void Upload(string fileName, T entity)
  {
      try
      {
          var blockBlob = _blobContainer.GetBlockBlobReference(fileName);
          using (var stream = _serializer.Serialize(entity))
          {
              blockBlob.UploadFromStream(stream);
          }
      }
      catch (Exception ex)
      {
          var json = JsonConvert.SerializeObject(entity).SubstringSafe(0, 500);
          _logger.Error("Error uploading object '{0}' of type '{1}' to blob storage container '{2}'; entity='{3}'; error={4}",
              fileName,
              typeof(T).Name,
              _containerName,
              json,
              ex.CompleteMessage());
          throw;
      }
  }
  </code></pre>
  
  <p>The <code>fileName</code> might be something like "4110\GetNodesForPathAnalysis" (which works in other circumstances), and the <code>_containerName</code> might be "segmentedids" (which also works in other circumstances). I know that the usual cause of this 400 error - one that has bit me several times - is a container or blob name that violates <a href="http://msdn.microsoft.com/en-us/library/azure/dd135715.aspx" rel="nofollow">The Rules</a>, but that doesn't seem to be the case here.</p>
  
  <p>The error is transient - if I refresh the page on which it shows up, the object (with the same container and file name) gets uploaded to Azure Blob Storage correctly.</p>
  
  <p>Any suggestions?</p>