Console App to Interact with Azure Blobs

Leave a comment

Azure blobs can be interacted with through Visual Studio. Here we will go through an example of interacting with a blob in a C# console app.

First, create a new console app:

This will create:

We will add 2 NuGet packages:

  • WindowsAzure.Storage
  • Microsoft.WindowsAzure.Configuration Manager


In the app.settings, add the key below, with the value of your storage account:

   <add key="StorageConnectionString" value="yourconnection" /> 

To get the value, go to your storage account in Azure and add the connection string information, for example:

Now in the code, add the directives:

using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;

And add the code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;

namespace Carl.AzureBlob
    class Program
        static void Main(string[] args)
                CloudStorageAccount storageAccount = CloudStorageAccount.Parse(

                CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
                CloudBlobContainer container = blobClient.GetContainerReference("newcontainerthroughcode");

                Console.WriteLine("Creating new container");
            catch (Exception ex)

This produces:

And the container is created in the portal:

From here, you can perform several different blob operations, including:

  • Upload a blob to a container
  • Listing blobs in containers
  • Downloading blobs
  • Deleting blobs
  • Write to an append blob such as a log



Carl de Souza is a developer and architect focusing on Microsoft Dynamics 365, Power BI, Azure, and AI.

carldesouza.comLinkedIn Twitter | YouTube


See more articles on: Azure

Leave a Reply

Your email address will not be published. Required fields are marked *