How to create a sub directory in a blob container

0 votes
Mar 26, 2019 in Azure by sabby
• 4,370 points
6,749 views

1 answer to this question.

0 votes

There are two ways: 

  • using the GetDirectoryReference
  • looping through a containers blobs and checking the type

The code below is in C#

CloudBlobContainer container = blobClient.GetContainerReference("photos");

//Method 1. grab a folder reference directly from the container
CloudBlobDirectory folder = container.GetDirectoryReference("directoryName");

//Method 2. Loop over container and grab folders.
foreach (IListBlobItem item in container.ListBlobs(null, false))
{
    if (item.GetType() == typeof(CloudBlobDirectory))
    {
        // we know this is a sub directory now
        CloudBlobDirectory subFolder = (CloudBlobDirectory)item;

        Console.WriteLine("Directory: {0}", subFolder.Uri);
    }
}

answered Mar 26, 2019 by p
• 1,960 points

Related Questions In Azure

0 votes
0 answers

How to create a sub-container in Azure?

How to create a sub-container in Azure ...READ MORE

Jun 28, 2019 in Azure by sabby
• 4,370 points
386 views
0 votes
1 answer

How to create a sub-container in Azure?

You can create a container named "content" and ...READ MORE

answered Jun 28, 2019 in Azure by Perry
• 17,100 points
617 views
0 votes
1 answer

How to get the list of names of Azure blob files in a container?

We can get some additional info like Size, ...READ MORE

answered Jun 27, 2018 in Azure by club_seesharp
• 3,450 points
9,474 views
0 votes
1 answer

How to create a container in Azure Cloud?

Hi@akhtar, You can launch a container on any ...READ MORE

answered Nov 13, 2020 in Azure by MD
• 95,060 points
34 views
0 votes
1 answer

How to install Windows Azure Storage Emulator?

There may be an issue with the ...READ MORE

answered Mar 6, 2019 in Azure by p
• 1,960 points
1,102 views
0 votes
1 answer

Azure Storage Emulator shows error.

This blog might help with your query: http://blog.smarx.com/posts/windows-azure-storage-emulator-the-process-cannot-access-the-file-because-it-is-being-used-by-another-process Also, ...READ MORE

answered Mar 15, 2019 in Azure by p
• 1,960 points
570 views
0 votes
1 answer

Friendly filename when downloading Azure blob.

Azure blobs can be downloaded in four ...READ MORE

answered Mar 15, 2019 in Azure by p
• 1,960 points
890 views
0 votes
1 answer

How to debug Azure 500 internal server error?

You can simply turn off custom error in ...READ MORE

answered Mar 29, 2019 in Azure by p
• 1,960 points
2,855 views
0 votes
1 answer

How to check if multiple files exist in Azure container?

foreach loop is the most efficient way though. ...READ MORE

answered Mar 4, 2019 in Azure by p
• 1,960 points
1,485 views
0 votes
1 answer

How to download a file from Blob Storage to the browser?

If you use ASP.NET (core), you can ...READ MORE

answered Mar 25, 2019 in Azure by p
• 1,960 points
3,971 views