Azure Storage offers robust mechanisms to secure your data, ensuring that only authorized users and applications can access your blobs, files, queues, and tables. This document details the primary access control models available for Azure Storage.
Shared Access Signatures (SAS)
Shared Access Signatures provide a secure way to delegate access to resources in your storage account. A SAS token grants specific permissions for a limited period to a designated resource. This is ideal for scenarios where you need to provide limited access to clients without them needing full account credentials.
Types of SAS:
Service SAS: Delegated access to service-level resources (blobs, queues, tables, filesystem).
Account SAS: Delegated access to resources across one or more storage services.
Azure RBAC is the foundational access control system for Azure resources. It allows you to grant granular access to Azure Storage management operations and data operations by assigning roles to users, groups, service principals, or managed identities.
Built-in Roles: Azure provides several pre-defined roles for storage management, such as "Storage Blob Data Owner," "Storage Blob Data Reader," and "Storage Account Contributor."
Custom Roles: You can define your own custom roles if the built-in roles don't meet your specific needs.
Scope: RBAC can be applied at various scopes: management group, subscription, resource group, or individual storage account.
Learn more about Azure RBAC for Storage in the documentation.
Access Keys
Storage account access keys provide full administrative access to your storage account. They grant unrestricted read and write access to all data in the account. Access keys should be treated as highly sensitive credentials and rotated regularly.
Key Management: Access keys can be regenerated via the Azure portal or Azure CLI.
Security: Avoid embedding access keys directly in application code. Use managed identities or SAS tokens for programmatic access where possible.
Best Practice: For most application scenarios, using Azure RBAC with Azure Active Directory (Azure AD) and Shared Access Signatures (SAS) is the recommended approach for secure and granular access control. Reserve the use of storage account access keys for management tasks or scenarios where other authentication methods are not feasible, and ensure they are securely stored and rotated.
Example: Granting Read Access to Blobs using RBAC
To grant a user read-only access to blob data in a specific storage account:
Navigate to the storage account in the Azure portal.
Select "Access control (IAM)" from the left-hand menu.
Click "+ Add" and then "Add role assignment."
Select the "Storage Blob Data Reader" role.
Choose the members (users, groups, service principals) you want to assign the role to.
Review and assign the role.
Example: Creating a SAS Token for a Blob
You can generate a SAS token for a specific blob using the Azure portal, Azure CLI, Azure PowerShell, or SDKs. For example, using Azure CLI: