Manage Azure Storage Containers
This document provides detailed guidance on how to manage containers within your Azure Storage account. Containers are fundamental to organizing and accessing your blob data.
Creating a Container
You can create a container using the Azure portal, Azure CLI, PowerShell, or client libraries. When creating a container, you specify a name and an access policy. Container names must be globally unique within the storage account.
- Naming Rules: Container names must start with a letter or number, can contain only letters, numbers, and hyphens. Hyphens cannot be consecutive or at the beginning or end of the name.
- Access Policies: Define the level of public access allowed for blobs within the container. Options include:
Private (no anonymous access): The default. Blobs are only accessible with authorization.Blob (anonymous read access for blobs): Blobs can be read anonymously, but container metadata is not accessible.Container (anonymous read access for containers and blobs): Both the container and its blobs can be accessed anonymously.
Example using Azure CLI:
az storage container create --name mycontainer --account-name mystorageaccount --auth-mode login
Listing Containers
To view all containers within a storage account, you can use various tools. This is useful for auditing and managing your storage resources.
Example using Azure CLI:
az storage container list --account-name mystorageaccount --auth-mode login
Managing Container Properties
Once a container is created, you can modify its properties, such as its access policy. You can also set various metadata and configurations.
Setting Access Policy:
You can update the public access level of a container after it has been created.
Example using Azure CLI to set container access to blob level:
az storage container set-permission --name mycontainer --public-access blob --account-name mystorageaccount --auth-mode login
Deleting a Container
Containers can be deleted. Be cautious, as this action is irreversible and all data within the container will be permanently lost.
Example using Azure CLI:
az storage container delete --name mycontainer --account-name mystorageaccount --auth-mode login
Container Properties Overview
| Property | Description |
|---|---|
| Name | The unique identifier for the container. |
| Public Access Level | Controls anonymous access to blobs and containers. |
| Last Modified | Timestamp of the last modification. |
| ETag | Entity tag used for concurrency control. |
| Lease Status | Indicates if the container is leased. |