What Is Azure Append Blob?

An Append Blob is comprised of blocks and is optimized for append operations. When you modify an Append Blob, blocks are added to the end of the blob only, via the Append Block operation.

Append Blob is optimized for fast append operations, making it ideal for scenarios where the data must be added to an existing blob without modifying the existing contents of that blob (Eg. logging, auditing).

Steps to create storage account

  1. Log on to Azure Portal.

  2. Click on Browse and select Storage Account (Classic)

  3. Click on Add button.

  4. Provide the input and click on Create button.

    Create

Steps to create Append Blob and write content in the Blob

  1. Open Visual Studio.

  2. Create new console application.

  3. In Solution Explorer, right-click References, then click Manage NuGet Packages.

  4. Install WindowsAzure.Storage

  5. Add below reference in program.cs file,
    1. using Microsoft.WindowsAzure.Storage;  
    2. using Microsoft.WindowsAzure.Storage.Auth;  
    3. using Microsoft.WindowsAzure.Storage.Blob;  
  6. Add the following code in Main() function.
    1. string accName = "[StorageAccountName]";  
    2. string accKey = "[StorageAccountKey]";  
    3.   
    4. // Implement the accout, set true for https for SSL.  
    5. StorageCredentials creds = new StorageCredentials(accName, accKey);  
    6. CloudStorageAccount strAcc = new CloudStorageAccount(creds, true);  
    7.   
    8. // Create the blob client.  
    9. CloudBlobClient blobClient = strAcc.CreateCloudBlobClient();  
    10.   
    11. // Retrieve a reference to a container.   
    12. CloudBlobContainer container = blobClient.GetContainerReference("mycontainer");  
    13.   
    14. // Create the container if it doesn't already exist.  
    15. container.CreateIfNotExistsAsync();  
    16.   
    17. DateTime dateLogEntry = DateTime.Now;  
    18. // This creates a reference to the append blob.  
    19. CloudAppendBlob appBlob = container.GetAppendBlobReference("appandtext.txt");  
    20.   
    21. // Now we are going to check if todays file exists and if it doesn't we create it.  
    22. if (!appBlob.Exists())  
    23. {  
    24.     appBlob.CreateOrReplace();  
    25. }  
    26.   
    27. // Add the entry to file.  
    28.   
    29. appBlob.AppendText  
    30. (  
    31.     string.Format(  
    32.         "{0} | Message for blob!!!\r\n",  
    33.         dateLogEntry.ToString()));  
    34.   
    35. // Now lets pull down our file and see what it looks like.  
    36. Console.WriteLine(appBlob.DownloadText());  
    37.   
    38. Console.WriteLine("Press any key to continue...");  
    39. Console.ReadKey();  

Note

You cannot edit/modify the existing blocks of the blob. You can only append to the end of the blob.