Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest Fabric, Power BI, and SQL learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register todayThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Blobs in Azure Storage are organized into containers. Before you can upload a blob, you must first create a container. This article shows how to create containers with the Azure Storage client library for JavaScript.
A container name must be a valid DNS name, as it forms part of the unique URI used to address the container or its blobs. Follow these rules when naming a container:
The URI for a container resource is formatted as follows:
https://my-account-name.blob.core.windows.net/my-container-name
To create a container, call the following method from the BlobServiceClient class:
You can also create a container using either of the following methods from the ContainerClient class:
Containers are created immediately beneath the storage account. It's not possible to nest one container beneath another. An exception is thrown if a container with the same name already exists.
The following example creates a container asynchronously from a BlobServiceClient
object:
async function createContainer(blobServiceClient, containerName){
const containerClient = await blobServiceClient.createContainer(containerName);
return containerClient;
}
A root container serves as a default container for your storage account. Each storage account can have one root container, which must be named $root. The root container must be explicitly created or deleted.
You can reference a blob stored in the root container without including the root container name. The root container enables you to reference a blob at the top level of the storage account hierarchy. For example, you can reference a blob in the root container as follows:
https://accountname.blob.core.windows.net/default.html
To create the root container, call any create method and specify the container name as $root.
To learn more about creating a container using the Azure Blob Storage client library for JavaScript, see the following resources.
The Azure SDK for JavaScript contains libraries that build on top of the Azure REST API, allowing you to interact with REST API operations through familiar JavaScript paradigms. The client library methods for creating a container use the following REST API operation:
Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest Fabric, Power BI, and SQL learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register todayTraining
Module
Work with Azure Blob storage - Training
Learn how to use the Azure Blob storage client library to create and update Blob storage resources.
Documentation
List blob containers with JavaScript or TypeScript - Azure Storage
Learn how to list blob containers in your Azure Storage account using the JavaScript client library.
Get started with Azure Blob Storage and JavaScript or TypeScript - Azure Storage
Get started developing a JavaScript or TypeScript application that works with Azure Blob Storage. This article helps you set up a project and authorizes access to an Azure Blob Storage endpoint.
Azure Storage Blob client library for JavaScript