How can I create a sub container in the azure storage location?
It is my understanding that an Azure Storage account can have unlimited containers. On this page it specifies: For a storage account, the maximum number of containers with locked time-based immutable policies is 10,000.
CloudBlobContainer container = new CloudBlobContainer("https://mystore.blob.core.windows.net/" + subDomain); This just creates an instance of CloudBlobContainer object. To create a container in your storage account, you would need to call CreateIfNotExists or Create function on this object.
To create a container instance with the Azure CLI, provide a resource group name, container instance name, and Docker container image to the az container create command. In this quickstart, you use the public mcr.microsoft.com/azuredocs/aci-helloworld image.
Windows Azure doesn't provide the concept of heirarchical containers, but it does provide a mechanism to traverse heirarchy by convention and API. All containers are stored at the same level. You can gain simliar functionality by using naming conventions for your blob names.
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
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 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.
This should help you get started. Let me know if this doesn't answer your question:
[ Thanks to Neil Mackenzie for inspiration ]
Are you referring to blob storage? If so, the hierarchy is simply StorageAccount/Container/BlobName. There are no nested containers.
Having said that, you can use slashes in your blob name to simulate nested containers in the URI. See this article on MSDN for naming details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With