How to create a sub-container in Azure

0 votes
How to create a sub-container in Azure Storage location?
Jun 28, 2019 in Azure by sabby
• 4,370 points
1,957 views

1 answer to this question.

0 votes

You can create a container named "content" and create blobs with the following names in that container:

content/blue/images/logo.jpg
content/blue/images/icon-start.jpg
content/blue/images/icon-stop.jpg

content/red/images/logo.jpg
content/red/images/icon-start.jpg
content/red/images/icon-stop.jpg

These blobs are a flat list against your "content" container. That said, using the "/" as a conventional delimiter, provides you with the functionality to traverse these in a heirarchical fashion.

protected IEnumerable<IListBlobItem> 
          GetDirectoryList(string directoryName, string subDirectoryName)
{
    CloudStorageAccount account =
        CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
    CloudBlobClient client = 
        account.CreateCloudBlobClient();
    CloudBlobDirectory directory = 
        client.GetBlobDirectoryReference(directoryName); 
    CloudBlobDirectory subDirectory = 
        directory.GetSubdirectory(subDirectoryName); 

    return subDirectory.ListBlobs();
}

You can then call this as follows:

GetDirectoryList("content/blue", "images")

Note the use of GetBlobDirectoryReference and GetSubDirectory methods and the CloudBlobDirectory type instead of CloudBlobContainer. These provide the traversal functionality you are likely looking for.

Hope this helps!

To know more about Azure, It's recommended to join Azure Training in Chennai today.

answered Jun 28, 2019 by Perry
• 17,100 points

edited Oct 7, 2021 by Sarfaraz

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
1,032 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,460 points

edited Jun 27, 2023 by Khan Sarfaraz 695 views
0 votes
1 answer

How to create a managed container registry in Azure?

Hi@akhtar, To run a container, you need an ...READ MORE

answered Nov 13, 2020 in Azure by MD
• 95,460 points
521 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
21,815 views
0 votes
1 answer

How to install Windows Azure Storage Emulator?

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

answered Mar 7, 2019 in Azure by Prerna
• 1,960 points
2,794 views
0 votes
1 answer

Azure Storage Emulator shows error.

Check if you are running BitTorrent/uTorrent or similar ...READ MORE

answered Mar 16, 2019 in Azure by Prerna
• 1,960 points
1,712 views
0 votes
1 answer

Friendly filename when downloading Azure blob.

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

answered Mar 16, 2019 in Azure by Prerna
• 1,960 points
3,771 views
0 votes
1 answer

How to create a sub directory in a blob container?

There are two ways:  using the GetDirectoryReference looping through a containers ...READ MORE

answered Mar 26, 2019 in Azure by Prerna
• 1,960 points
12,578 views
0 votes
1 answer

How to Schedule a task in Azure Worker role?

You can simply have a message on ...READ MORE

answered Jul 1, 2019 in Azure by Perry
• 17,100 points
1,432 views
0 votes
1 answer

How do I upload a picture to Windows Azure Website?

Check out this example: @model List<string> ...READ MORE

answered Jun 28, 2019 in Azure by Perry
• 17,100 points
1,654 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP