Azure Documentation

Azure Storage Blobs: Access Permissions

This tutorial demonstrates how to manage access permissions for blobs in Azure Storage. Securely controlling access to your data is crucial for maintaining the integrity and privacy of your applications.

Understanding Access Control in Azure Blob Storage

Azure Blob Storage offers several mechanisms to control who can access your blob data. The primary methods include:

Creating and Managing Shared Access Signatures (SAS)

SAS tokens are a powerful way to delegate access without sharing your account keys. You can generate SAS tokens for service, container, or blob levels.

Generating a Blob SAS Token using Azure CLI

Here's an example of how to generate a blob SAS token with read permissions for 1 hour using the Azure CLI:


az storage blob generate-sas \
  --account-name mystorageaccount \
  --container-name mycontainer \
  --name myblob.txt \
  --permissions r \
  --expiry 2024-12-31T10:00:00Z \
  --output tsv
        

The output will be a SAS token that you can append to the blob's URL.

Generating a Container SAS Token

Similarly, you can generate a SAS token for an entire container:


az storage container generate-sas \
  --account-name mystorageaccount \
  --name mycontainer \
  --permissions r \
  --expiry 2024-12-31T10:00:00Z \
  --output tsv
        
Tip: Always generate SAS tokens with the minimum necessary permissions and for the shortest possible duration to enhance security.

Using Azure RBAC for Storage Access

RBAC allows you to grant broad permissions to individuals or services. Common roles for storage include:

Assigning a Role using Azure Portal

  1. Navigate to your storage account in the Azure portal.
  2. Under Access control (IAM), select Add > Add role assignment.
  3. Choose the desired role (e.g., Storage Blob Data Reader).
  4. Select the members (users, groups, or service principals) to assign the role to.
  5. Click Save.
Important: RBAC roles are assigned at the subscription, resource group, or resource level. Ensure you assign roles at the most specific level required.

Container Access Levels

Azure Blob Storage supports different public access levels for containers:

Setting Container Access Level using Azure Portal

  1. Navigate to your storage account in the Azure portal.
  2. Under Data storage, select Containers.
  3. Click on the container you want to configure.
  4. In the container's overview page, click Change access level.
  5. Select the desired public access level and click OK.
Note: Setting a container to public access can expose your data. Use this setting with caution and only when necessary.

Best Practices for Blob Access Permissions

Success: By implementing these access control strategies, you can significantly enhance the security posture of your Azure Blob Storage data.