+1 vote
1 view
in Azure by (8.4k points)

How to create a sub-container in the Azure storage location.

Please let me know.

1 Answer

+1 vote
by (16.8k points)
edited by

There is no concept for hierarchical containers in the Azure but traverse hierarchy by convention and API. All the containers present will be stored at the same level. 

For instance, you may 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

Looking for Azure material from basics! Refer to this video on Azure provided by Intellipaat:

Note that 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 hierarchical 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.

I hope it helps!

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...