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:
- Organize blobs logically.
- Manage access policies at the container level.
- Set default access tiers for blobs.
Container Naming Rules
Container names must adhere to the following rules:
- Container names must start with a letter or number.
- Container names can contain only letters, numbers, and the hyphen (-) character.
- Every hyphen (-) must be immediately preceded and followed by a letter or number. Hyphens cannot be at the beginning or end of the name.
- Container names must be from 3 through 63 characters long.
- Container names must be case-insensitive.
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:
- Private: Access to blobs within the container requires authorization. This is the default setting.
- Blob: Blobs within the container can be accessed anonymously, but container metadata is not accessible anonymously.
- Container: Blobs and container metadata can be accessed anonymously.
Creating a Container
You can create containers using various tools and SDKs:
Azure Portal
- Navigate to your storage account in the Azure portal.
- In the left-hand menu, under "Data storage", select "Containers".
- Click the "+ Container" button.
- Enter a name for your container.
- Select the desired public access level.
- 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 in a storage account.
- Retrieving container properties.
- Setting container access policies.
- Deleting containers.
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
Next Steps
Now that you understand containers, you can proceed to learn about uploading and retrieving blobs.