Azure Storage Documentation

Manage Blob Containers

Managing Blob Containers

This document provides comprehensive guidance on managing blob containers within Azure Storage. Containers are fundamental organizational units for storing blobs.

What is a Blob Container?

A blob container is a logical grouping of blobs. Think of it as a folder in a file system. You can upload, download, and manage data within a container.

Key Operations for Container Management

Managing blob containers involves several common operations:

Creating a Container

You can create a container using the Azure portal, Azure CLI, Azure PowerShell, or client libraries.

Using Azure CLI

The following command creates a new container:

az storage container create --name mycontainer --account-name mystorageaccount --public-access off

Replace mycontainer with your desired container name and mystorageaccount with your storage account name.

Using Azure PowerShell

New-AzStorageContainer -Name "mycontainer" -Context $ctx

Ensure you have a storage account context ($ctx) defined.

Listing Containers

To view all containers in your storage account:

Using Azure CLI

az storage container list --account-name mystorageaccount --output table

Using Azure PowerShell

Get-AzStorageContainer -Context $ctx

Container Access Levels

Containers can have different access levels, affecting how blobs within them can be accessed anonymously:

You can set the access level during creation or update an existing container's access level.

Setting Access Level with Azure CLI

az storage container set-permission --name mycontainer --account-name mystorageaccount --public-access blob

Deleting a Container

Deleting a container is a destructive operation and will remove the container and all its contents.

Using Azure CLI

az storage container delete --name mycontainer --account-name mystorageaccount

Using Azure PowerShell

Remove-AzStorageContainer -Name "mycontainer" -Context $ctx

Container Properties

You can retrieve various properties of a container, such as its ETag, Last-Modified date, and Lease Status.

Getting Container Properties with Azure CLI

az storage container show --name mycontainer --account-name mystorageaccount

Best Practices

Important Note

Always exercise caution when performing delete operations. Ensure you have backups or understand the implications before proceeding.

« Previous: Uploading Blobs Next: Deleting Blobs »