3.1.1.7. Configure Storage Account Encryption
3.1.1.7. Configure Storage Account Encryption
💡 First Principle: Azure Storage always encrypts data at rest, so the administrator's real decisions are about the key: who holds it, who rotates it, how wide a boundary it protects, and whether one layer of encryption is enough. Choosing the key model is choosing who can switch the data off.
Scenario: A healthcare company keeps patient documents in a general-purpose v2 storage account. Auditors require that the company, not Microsoft, controls and rotates the encryption key, that rotation happens without an administrator editing the storage account each year, and that one partner's container is encrypted with a key of its own. A separate compliance rule asks for data to be encrypted twice.
What It Is: Azure Storage encryption for data at rest (service-side encryption, SSE) encrypts every storage account with 256-bit AES. It covers blobs, files, queues, tables and disks in every performance tier, access tier and redundancy option, including the secondary region of a geo-redundant account. You can't disable it, it costs nothing extra, and applications need no code changes. What you configure is the key management around it.
Key Management Options:
| Microsoft-managed keys | Customer-managed keys | Customer-provided keys | |
|---|---|---|---|
| Where the key lives | Microsoft key store | Azure Key Vault or Key Vault Managed HSM | The client's own key store |
| Who rotates it | Microsoft | You | You |
| Services | All | Blob Storage and Azure Files (queues and tables only if enabled when the account is created) | Blob Storage only |
| Scope | Account, container or blob | Account, container or blob | Each request |
Customer-managed keys (CMK), step by step:
- Prepare the vault. The key vault or managed HSM must have soft delete and purge protection enabled, and the key must be an RSA or RSA-HSM key of 2048, 3072 or 4096 bits. The vault can be in a different region, subscription, or even Microsoft Entra tenant from the storage account.
- Give the account an identity. Azure Storage reaches the vault through a managed identity that holds the Key Vault Crypto Service Encryption User role on the vault (wrap key, unwrap key and get). When you configure CMK while creating the account, the identity must be user-assigned; an existing account can use a system-assigned or user-assigned identity.
- Point the account at the key. Azure Storage then wraps the account's root encryption key with your key. The data is never re-encrypted in bulk and stays encrypted throughout, so there's no downtime. You can switch back to Microsoft-managed keys at any time.
- Choose how key versions update. Rotation itself happens in Key Vault (manually or with a Key Vault rotation policy); Azure Storage never rotates your key. If you omit the key version, Azure Storage checks the vault once a day and starts using the newest version automatically, so wait 24 hours before disabling an old version. If you specify a version, the account stays on it until you update it yourself.
- Revoke when you must. Disabling the key in the vault makes read and write operations fail with 403 (Forbidden) for every caller. The data is still there and still encrypted, and access returns when you re-enable the key.
Infrastructure Encryption (Double Encryption): Infrastructure encryption adds a second 256-bit AES layer at the storage infrastructure level, with a different algorithm and a separate key. The service-level layer can use Microsoft-managed or customer-managed keys, while the infrastructure layer always uses Microsoft-managed keys. It is supported on general-purpose v2, premium block blob and premium page blob accounts, and it must be chosen when the account is created: you can't enable or disable it afterward. Microsoft recommends it only when a compliance requirement demands double encryption.
Encryption Scopes: An encryption scope lets you encrypt a container or an individual blob with its own key (Microsoft-managed or customer-managed), which creates secure boundaries between different customers' data in one account. You set a default scope when you create a container and decide whether blobs may override it. An encryption scope can't be deleted, only disabled, and it is billed for at least 30 days once enabled, so disable scopes you no longer need. A blob that uses an encryption scope can't be moved to the archive tier.
Customer-Provided Keys: A client can send an AES-256 key on each Blob Storage request. Azure Storage uses it, stores only a SHA-256 hash of it, and discards the key. Every later read or write of that blob must supply the same key over HTTPS, and the Azure portal can't read such blobs.
Practical Implementation: Customer-Managed Keys and an Encryption Scope with Azure CLI
# Give an existing account a system-assigned identity
az storage account update --name contosodocs --resource-group rg-docs --assign-identity
# Use the key with automatic key-version updates (empty key version)
az storage account update \
--name contosodocs \
--resource-group rg-docs \
--encryption-key-source Microsoft.Keyvault \
--encryption-key-vault https://kv-docs.vault.azure.net \
--encryption-key-name docs-cmk \
--encryption-key-version ""
# Create an encryption scope, then a container that forces it on every blob
az storage account encryption-scope create \
--resource-group rg-docs \
--account-name contosodocs \
--name partner-a-scope \
--key-source Microsoft.Storage
az storage container create \
--account-name contosodocs \
--name partner-a \
--default-encryption-scope partner-a-scope \
--prevent-encryption-scope-override true \
--auth-mode login
# Double encryption is a create-time choice on a new account
az storage account create --name contosodbl --resource-group rg-docs \
--location eastus --sku Standard_GRS --kind StorageV2 \
--require-infrastructure-encryption
Before the second command, assign the account's identity the Key Vault Crypto Service Encryption User role on the vault. In the portal, these settings are under the storage account's Security + networking > Encryption, which also has an Encryption scopes tab.
Visual: Who Holds Which Key
⚠️ Common Pitfall: Disabling the old key version on the day a new version is created. With automatic version updates, the account may still be using the old version for up to a day, so blob reads and writes start failing with 403.
⚠️ Exam Trap: "Turn on encryption" is never the answer, because encryption is already on and can't be turned off. Read for the real requirement: control and rotation points to customer-managed keys in Key Vault, double encryption points to infrastructure encryption chosen at account creation, and a different key per container or tenant points to encryption scopes.
Key Trade-Offs:
- Control vs. Operational Risk: Customer-managed keys give you rotation and revocation, but a deleted or disabled key, or a missing role assignment, makes your own data unreadable.
- Assurance vs. Flexibility: Infrastructure encryption adds a second layer at no extra key-management work, but it is fixed at creation and can't be added to an existing account.
Reflection Question: If your security team needs to cut off all access to a storage account during an incident without deleting anything, which encryption design makes that possible, and what has to be true of the key vault beforehand?