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
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:
var account = CloudStorageAccount.Parse("AccountName=myaccount;AccountKey=myaccountkey==;DefaultEndpointsProtocol=https"); var blobClient = account.CreateCloudBlobClient(); var blobContainer = blobClient.GetContainerReference("$root"); blobContainer.Create();
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. |
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
SetPermissionsConcepts
Naming and Referencing Containers, Blobs, and MetadataOther Resources
Addressing Blob Service ResourcesStorage Service Versioning
Setting Access Control for Containers
Referring to Containers and Blobs
Set Container ACL
List Containers
List Blobs
How to Use the Blob Storage Service
How to Use the Table Storage Service
How to Use the Queue Storage Service
Important