Containers in Azure Blob Storage

Containers are the primary organizational constructs within an Azure storage account. You can think of them as analogous to a root folder in a file system. All blobs in Blob Storage are contained within a container. A storage account can contain any number of containers, and a container can hold any number of blobs.

Container Basics

Every blob must reside within a container. Containers provide a way to:

Container Naming Rules

Container names must adhere to the following rules:

Container Access Levels

You can configure the access level for a container to control how blobs within that container can be accessed. There are three access levels:

Note: For security best practices, it's recommended to keep containers private unless anonymous read access is explicitly required.

Creating a Container

You can create containers using various tools and SDKs:

Azure Portal

  1. Navigate to your storage account in the Azure portal.
  2. In the left-hand menu, under "Data storage", select "Containers".
  3. Click the "+ Container" button.
  4. Enter a name for your container.
  5. Select the desired public access level.
  6. Click "Create".

Azure CLI

Use the az storage container create command:

az storage container create \
    --name mycontainer \
    --account-name mystorageaccount \
    --auth-mode login

Azure PowerShell

Use the New-AzRmStorageContainer cmdlet:

New-AzRmStorageContainer -ResourceGroupName "myresourcegroup" -StorageAccountName "mystorageaccount" -Name "mycontainer"

Managing Containers

Once created, containers can be managed through the Azure portal, CLI, PowerShell, or client libraries. Common management operations include:

Listing Containers

Using Azure CLI:

az storage container list \
    --account-name mystorageaccount \
    --auth-mode login

Deleting a Container

Using Azure CLI:

az storage container delete \
    --name mycontainer \
    --account-name mystorageaccount \
    --auth-mode login
Warning: Deleting a container also deletes all blobs within that container. This action cannot be undone.

Next Steps

Now that you understand containers, you can proceed to learn about uploading and retrieving blobs.