Azure Storage Documentation

Delete a Container

This guide explains how to delete a blob container in Azure Storage. Deleting a container also deletes all the blobs contained within it. This operation is irreversible.

Warning: Deleting a container is a destructive operation. All data within the container, including all blobs, will be permanently lost. Ensure you have backups or have no further need for the container's data before proceeding.

Prerequisites

Methods to Delete a Container

You can delete a container using the Azure portal, Azure CLI, PowerShell, or the Azure Storage SDKs.

1

Azure CLI

Use the Azure CLI command az storage container delete to remove a container. Replace <container-name> with the name of your container and <storage-account-name> with your storage account name.

az storage container delete \
    --name <container-name> \
    --account-name <storage-account-name> \
    --auth-mode login

For accounts that require a connection string, use:

az storage container delete \
    --name <container-name> \
    --connection-string <your-connection-string>

You may be prompted to confirm the deletion.

2

Azure PowerShell

Use the Azure PowerShell cmdlet Remove-AzStorageContainer. Replace <container-name> with your container name and <storage-account-name> with your storage account name.

Remove-AzStorageContainer -Name <container-name> -Context (New-AzStorageContext -StorageAccountName <storage-account-name> -UseSubDomain)

Alternatively, using a connection string:

Remove-AzStorageContainer -Name <container-name> -ConnectionString <your-connection-string>
3

Azure Portal

  1. Navigate to your storage account in the Azure portal.
  2. In the left-hand menu, under Data storage, select Containers.
  3. Locate the container you wish to delete in the list.
  4. Click the ellipsis (...) to the right of the container name, and select Delete container.
  5. In the confirmation dialog, type the name of the container to confirm deletion and click Delete.
4

Azure Storage SDKs

You can also programmatically delete containers using the Azure Storage SDKs for various languages (e.g., .NET, Java, Python, Node.js).

For example, using the .NET SDK:

// Assuming you have a BlobServiceClient object configured
                await blobServiceClient.DeleteContainerAsync(containerName);

Refer to the official Azure documentation for detailed code examples in different languages.

Important Considerations

For more information on managing containers, see Create a container.