Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
57 lines (41 sloc) 2.71 KB
type title excerpt tags date
Tip 79 - Creating an Azure Blob Hierarchy
Learn how to creating an Azure blob hierarchy
2018-01-15 09:00:00 -0800

::: tip 💡 Learn more : Azure storage account overview. :::

Creating an Azure Blob Hierarchy

We've reviewed the following options with Azure Storage so far:

Today, we are going to look at creating an Azure blob hierarchy via C#. Go ahead and open the Azure Portal and open the C# app that we worked with earlier. If you want to start from this post, then use the code located here.

The goal of this exercise is to create a blob hierarchy or folder structure inside of our container. So for example, we'd like to place a file in a structure such as such as backup/images-backup.png.

If you look below, you will notice that there is no way to create a folder structure from inside the portal.

But we can easily do this with code by adding the folder structure we want into the code as shown below.

static void Main(string[] args)
 var storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnection"));
 var myClient = storageAccount.CreateCloudBlobClient();
 var container = myClient.GetContainerReference("images-backup");

// line modified
 var blockBlob = container.GetBlockBlobReference("backup/mikepic.png");
 using (var fileStream = System.IO.File.OpenRead(@"c:\mikepic.png"))
 // line modified


If we run the application and switch over to our Storage Account and navigate inside the container, we'll see our container now has a folder:

You can’t perform that action at this time.