SALES: 1-800-867-1380

Working with the Root Container

Updated: May 23, 2014

A root container serves as a default container for your storage account. A storage account may have one root container. The root container must be explicitly created and must be named $root.

A blob stored in the root container may be addressed without referencing the root container name, so that a blob can be addressed at the top level of the storage account hierarchy. For example, you can now reference a blob that resides in the root container in the following manner:

https://myaccount.blob.core.windows.net/mywebpage.html

To use the root container with your storage account, create a new container named $root. The following sample request shows how to create the root container and upload a blob to it:

CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));

CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer blobContainer = blobClient.GetContainerReference("$root");
blobContainer.Create();

CloudBlockBlob blob = blobContainer.GetBlockBlobReference("BlobInRoot.txt");
blob.UploadText("This is a blob in the root container.");

Like other containers, the root container can be made available for anonymous public access. If the root container is present, it will appear when you list containers in the storage account. When you list blobs in the root container, the root container does not appear in the resource URLs for the blobs returned. You can also delete the root container if you no longer need it.

ImportantImportant
A blob in the root container cannot include a forward slash (/) in its name, and be careful to avoid including a trailing forward slash (/) when referencing a blob under the root container. For example, using this URI results in an error:

https://myaccount.blob.core.windows.net/myblob/

In the above example, the Blob service reads the container name as myblob and expects to see a blob name after the trailing slash. The request is malformed due to the missing blob name.

To construct a URI for a blob named myphoto that resides in the root container:

https://myaccount.blob.core.windows.net/myphoto

You can also explicitly reference the root container:

https://myaccount.blob.core.windows.net/$root/myphoto

See Also

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft