none
Unable to create local AppendBlob

    Question

  • Hi,

    I'm trying to create an AppendBlob in Storage Emulator v 4.2, but this fails with a 400 error; Bad request.

    I've tried the most recent versions of the nuget storage package, 6.2.0.

    I have copied the code from the "Getting started with Azure storage" sample, and I am able to create the container, but when I call appendBlob.CreateOrReplace() it throws the exception.

    Which version of the storage emulator is supposed to support Append Blobs?

    InnerException:
           HResult=-2146233079
           Message=The remote server returned an error: (400) Bad Request.
           Source=System
           StackTrace:
                at System.Net.HttpWebRequest.GetResponse()
                at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Executor\Executor.cs:line 677

    Sample code:

    //Parse the connection string for the storage account.
    CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
        Microsoft.Azure.CloudConfigurationManager.GetSetting("StorageConnectionString"));
    
    //Create service client for credentialed access to the Blob service.
    CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
    
    //Get a reference to a container.
    CloudBlobContainer container = blobClient.GetContainerReference("my-append-blobs");
    
    //Create the container if it does not already exist.
    container.CreateIfNotExists();
    
    //Get a reference to an append blob.
    CloudAppendBlob appendBlob = container.GetAppendBlobReference("append-blob.log");
    
    //Create the append blob. Note that if the blob already exists, the CreateOrReplace() method will overwrite it.
    //You can check whether the blob exists to avoid overwriting it by using CloudAppendBlob.Exists().
    appendBlob.CreateOrReplace();
    
    int numBlocks = 10;
    
    //Generate an array of random bytes.
    Random rnd = new Random();
    byte[] bytes = new byte[numBlocks];
    rnd.NextBytes(bytes);
    
    //Simulate a logging operation by writing text data and byte data to the end of the append blob.
    for (int i = 0; i < numBlocks; i++)
    {
        appendBlob.AppendText(String.Format("Timestamp: {0:u} \tLog Entry: {1}{2}",
            DateTime.UtcNow, bytes[i], Environment.NewLine));
    }
    
    //Read the append blob to the console window.
    Console.WriteLine(appendBlob.DownloadText());



    • Edited by TTLied Monday, February 8, 2016 9:50 PM
    Monday, February 8, 2016 9:43 PM

Answers