Working with the Root Container

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

Managing the Root Container

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.

Important

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.

Root Container Blob URI Syntax

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

Reference

Set Container ACL
List Containers
List Blobs
SetPermissions

Concepts

HTTP Operations on Blob Service Resources
Naming and Referencing Containers, Blobs, and Metadata
Versioning for the Azure Storage Services

Other Resources

Setting Access Control for Containers
Referring to Containers and Blobs
How to Use the Blob Storage Service
How to Use the Queue Storage Service