Container Access in Azure Blob Storage

Managing access to your Azure Blob Storage containers is crucial for security and data governance. Azure provides several mechanisms to control who can access your data and what actions they can perform.

On this page:

Container Access Levels

Each blob container can be configured with one of three public access levels:

Important: Public access should be used with caution. Ensure you understand the security implications before enabling it.

You can set the container access level through the Azure portal, Azure CLI, PowerShell, or client libraries.

Setting Access Levels with Azure CLI


# Set to private
az storage container set-permission --account-name <storage-account-name> --name <container-name> --public-access off

# Set to blob access
az storage container set-permission --account-name <storage-account-name> --name <container-name> --public-access blob

# Set to container access
az storage container set-permission --account-name <storage-account-name> --name <container-name> --public-access container
        

Role-Based Access Control (RBAC)

Azure RBAC provides fine-grained access management to Azure resources, including storage accounts and containers. You can assign roles to users, groups, or service principals to grant them specific permissions.

Common roles for Blob Storage include:

RBAC is the recommended approach for managing access for authenticated users and applications within your Azure environment.

Shared Access Signatures (SAS)

Shared Access Signatures (SAS) provide a way to delegate limited access to objects in your storage account. A SAS is a URI that contains a security token in its query parameters. This token allows a client to access specific storage resources for a limited period of time, with specific permissions.

SAS tokens can be:

Security Note: Always generate SAS tokens with the minimum necessary permissions and the shortest possible expiry duration.

Generating a SAS with Azure CLI

This example generates a SAS for a blob with read and write permissions, valid for 1 hour:


az storage blob generate-sas \
    --account-name <storage-account-name> \
    --container-name <container-name> \
    --name <blob-name> \
    --permissions rwc \
    --expiry 2024-12-31T12:00:00Z \
    --output tsv
        

The output will be a string containing the SAS token. You append this token to the blob's URI.

Access Control Lists (ACLs) for File Shares

While this document focuses on Blob Storage, it's worth noting that Azure Files (often managed alongside Blob Storage) uses Access Control Lists (ACLs) to manage file and directory permissions, similar to POSIX systems.

Best Practices for Container Access