Skip to content

Commit 08968e8

Browse files
authored
Merge pull request #84568 from tamram/tamram-0806
customer-provided keys on Blob operations
2 parents c93177c + 9b3ed96 commit 08968e8

File tree

5 files changed

+155
-18
lines changed

5 files changed

+155
-18
lines changed

articles/storage/blobs/TOC.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
items:
102102
- name: Security overview
103103
href: ../common/storage-security-guide.md?toc=%2fazure%2fstorage%2fblobs%2ftoc.json
104-
- name: Storage service encryption
104+
- name: Azure Storage encryption
105105
href: ../common/storage-service-encryption.md?toc=%2fazure%2fstorage%2fblobs%2ftoc.json
106106
- name: Authorization
107107
href: ../common/storage-auth.md?toc=%2fazure%2fstorage%2fblobs%2ftoc.json
@@ -334,7 +334,7 @@
334334
href: ../common/storage-account-sas-create-dotnet.md?toc=%2fazure%2fstorage%2fblobs%2ftoc.json
335335
- name: Define a stored access policy
336336
href: ../common/storage-stored-access-policy-define-dotnet.md?toc=%2fazure%2fstorage%2fblobs%2ftoc.json
337-
- name: Use customer-managed keys for service encryption
337+
- name: Use customer-managed keys for encryption
338338
items:
339339
- name: Portal
340340
href: ../common/storage-encryption-keys-portal.md?toc=%2fazure%2fstorage%2fblobs%2ftoc.json
24.2 KB
Loading
Lines changed: 150 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
22
title: Azure Storage encryption for data at rest | Microsoft Docs
3-
description: Azure Storage protects your data by automatically encrypting it before persisting it to the cloud. All data in an Azure Storage is encrypted and decrypted transparently using 256-bit AES encryption and is FIPS 140-2 compliant.
3+
description: Azure Storage protects your data by automatically encrypting it before persisting it to the cloud. You can rely on Microsoft-managed keys for the encryption of your storage account, or you can manage encryption with your own keys.
44
services: storage
55
author: tamram
66

77
ms.service: storage
8+
ms.date: 10/02/2019
89
ms.topic: conceptual
9-
ms.date: 05/15/2019
1010
ms.author: tamram
1111
ms.reviewer: cbrooks
1212
ms.subservice: common
@@ -16,31 +16,61 @@ ms.subservice: common
1616

1717
Azure Storage automatically encrypts your data when persisting it to the cloud. Encryption protects your data and to help you to meet your organizational security and compliance commitments. Data in Azure Storage is encrypted and decrypted transparently using 256-bit [AES encryption](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard), one of the strongest block ciphers available, and is FIPS 140-2 compliant. Azure Storage encryption is similar to BitLocker encryption on Windows.
1818

19-
Azure Storage encryption is enabled for all new and existing storage accounts and cannot be disabled. Because your data is secured by default, you don't need to modify your code or applications to take advantage of Azure Storage encryption.
19+
Azure Storage encryption is enabled for all new and existing storage accounts and cannot be disabled. Because your data is secured by default, you don't need to modify your code or applications to take advantage of Azure Storage encryption.
2020

2121
Storage accounts are encrypted regardless of their performance tier (standard or premium) or deployment model (Azure Resource Manager or classic). All Azure Storage redundancy options support encryption, and all copies of a storage account are encrypted. All Azure Storage resources are encrypted, including blobs, disks, files, queues, and tables. All object metadata is also encrypted.
2222

2323
Encryption does not affect Azure Storage performance. There is no additional cost for Azure Storage encryption.
2424

2525
For more information about the cryptographic modules underlying Azure Storage encryption, see [Cryptography API: Next Generation](https://docs.microsoft.com/windows/desktop/seccng/cng-portal).
2626

27-
## Key management
27+
## About encryption key management
2828

29-
You can rely on Microsoft-managed keys for the encryption of your storage account, or you can manage encryption with your own keys, together with Azure Key Vault.
29+
You can rely on Microsoft-managed keys for the encryption of your storage account, or you can manage encryption with your own keys. If you choose to manage encryption with your own keys, you have two options:
3030

31-
### Microsoft-managed keys
31+
- You can specify a *customer-managed key* to use for encrypting and decrypting all data in the storage account. A customer-managed key is used to encrypt all data in all services in your storage account.
32+
- You can specify a *customer-provided key* on Blob storage operations. A client making a read or write request against Blob storage can include an encryption key on the request for granular control over how blob data is encrypted and decrypted.
33+
34+
The following table compares key management options for Azure Storage encryption.
35+
36+
| | Microsoft-managed keys | Customer-managed keys | Customer-provided keys |
37+
|----------------------------------------|-------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------|
38+
| Encryption/decryption operations | Azure | Azure | Azure |
39+
| Azure Storage services supported | All | Blob storage, Azure Files | Blob storage |
40+
| Key storage | Microsoft key store | Azure Key Vault | Azure Key Vault or any other key store |
41+
| Key rotation responsibility | Microsoft | Customer | Customer |
42+
| Key usage | Microsoft | Azure portal, Storage Resource Provider REST API, Azure Storage management libraries, PowerShell, CLI | Azure Storage REST API (Blob storage), Azure Storage client libraries |
43+
| Key access | Microsoft only | Microsoft, Customer | Customer only |
44+
45+
The following sections describe each of the options for key management in greater detail.
46+
47+
## Microsoft-managed keys
3248

3349
By default, your storage account uses Microsoft-managed encryption keys. You can see the encryption settings for your storage account in the **Encryption** section of the [Azure portal](https://portal.azure.com), as shown in the following image.
3450

3551
![View account encrypted with Microsoft-managed keys](media/storage-service-encryption/encryption-microsoft-managed-keys.png)
3652

37-
### Customer-managed keys
53+
## Customer-managed keys
54+
55+
You can choose to manage Azure Storage encryption at the level of the storage account with your own keys. When you specify a customer-managed key at the level of the storage account, that key is used to encrypt and decrypt all data in the storage account, including blob, queue, file, and table data. Customer-managed keys offer greater flexibility to create, rotate, disable, and revoke access controls. You can also audit the encryption keys used to protect your data.
56+
57+
You must use Azure Key Vault to store your customer-managed keys. You can either create your own keys and store them in a key vault, or you can use the Azure Key Vault APIs to generate keys. The storage account and the key vault must be in the same region, but they can be in different subscriptions. For more information about Azure Key Vault, see [What is Azure Key Vault?](../../key-vault/key-vault-overview.md).
58+
59+
This diagram shows how Azure Storage uses Azure Active Directory and Azure Key Vault to make requests using the customer-managed key:
60+
61+
![Diagram showing how customer-managed keys work in Azure Storage](media/storage-service-encryption/encryption-customer-managed-keys-diagram.png)
3862

39-
You can manage Azure Storage encryption with customer-managed keys. Customer-managed keys give you more flexibility to create, rotate, disable, and revoke access controls. You can also audit the encryption keys used to protect your data.
63+
The following list explains the numbered steps in the diagram:
4064

41-
Use Azure Key Vault to manage your keys and audit your key usage. You can either create your own keys and store them in a key vault, or you can use the Azure Key Vault APIs to generate keys. The storage account and the key vault must be in the same region, but they can be in different subscriptions. For more information about Azure Key Vault, see [What is Azure Key Vault?](../../key-vault/key-vault-overview.md).
65+
1. An Azure Key Vault admin grants permissions to encryption keys to the managed identity that's associated with the storage account.
66+
2. An Azure Storage admin configures encryption with a customer-managed key for the storage account.
67+
3. Azure Storage uses the managed identity that's associated with the storage account to authenticate access to Azure Key Vault via Azure Active Directory.
68+
4. Azure Storage wraps the account encryption key with the customer key in Azure Key Vault.
69+
5. For read/write operations, Azure Storage sends requests to Azure Key Vault to wrap and unwrap the account encryption key to perform encryption and decryption operations.
4270

43-
To revoke access to customer-managed keys, see [Azure Key Vault PowerShell](https://docs.microsoft.com/powershell/module/azurerm.keyvault/) and [Azure Key Vault CLI](https://docs.microsoft.com/cli/azure/keyvault). Revoking access effectively blocks access to all data in the storage account, as the encryption key is inaccessible by Azure Storage.
71+
To revoke access to customer-managed keys on the storage account, see [Azure Key Vault PowerShell](https://docs.microsoft.com/powershell/module/azurerm.keyvault/) and [Azure Key Vault CLI](https://docs.microsoft.com/cli/azure/keyvault). Revoking access effectively blocks access to all data in the storage account, as the encryption key is inaccessible by Azure Storage.
72+
73+
Customer-managed keys are not supported for [Azure managed disks](../../virtual-machines/windows/managed-disks-overview.md).
4474

4575
To learn how to use customer-managed keys with Azure Storage, see one of these articles:
4676

@@ -49,10 +79,114 @@ To learn how to use customer-managed keys with Azure Storage, see one of these a
4979
- [Use customer-managed keys with Azure Storage encryption from Azure CLI](storage-encryption-keys-cli.md)
5080

5181
> [!IMPORTANT]
52-
> Customer-managed keys rely on managed identities for Azure resources, a feature of Azure Active Directory (Azure AD). When you transfer a subscription from one Azure AD directory to another, managed identities are not updated and customer-managed keys may no longer work. For more information, see **Transferring a subscription between Azure AD directories** in [FAQs and known issues with managed identities for Azure resources](../../active-directory/managed-identities-azure-resources/known-issues.md#transferring-a-subscription-between-azure-ad-directories).
82+
> Customer-managed keys rely on managed identities for Azure resources, a feature of Azure Active Directory (Azure AD). When you configure customer-managed keys in the Azure portal, a managed identity is automatically assigned to your storage account under the covers. If you subsequently move the subscription, resource group, or storage account from one Azure AD directory to another, the managed identity associated with the storage account is not transferred to the new tenant, so customer-managed keys may no longer work. For more information, see **Transferring a subscription between Azure AD directories** in [FAQs and known issues with managed identities for Azure resources](../../active-directory/managed-identities-azure-resources/known-issues.md#transferring-a-subscription-between-azure-ad-directories).
83+
84+
## Customer-provided keys (preview)
85+
86+
Clients making requests against Azure Blob storage have the option to provide an encryption key on an individual request. Including the encryption key on the request provides granular control over encryption settings for Blob storage operations. Customer-provided keys (preview) can be stored in Azure Key Vault or in another key store.
87+
88+
### Encrypting read and write operations
89+
90+
When a client application provides an encryption key on the request, Azure Storage performs encryption and decryption transparently while reading and writing blob data. A SHA-256 hash of the encryption key is written alongside a blob's contents and is used to verify that all subsequent operations against the blob use the same encryption key. Azure Storage does not store or manage the encryption key that the client sends with the request. The key is securely discarded as soon as the encryption or decryption process is complete.
91+
92+
When a client creates or updates a blob using a customer-provided key, then subsequent read and write requests for that blob must also provide the key. If the key is not provided on a request for a blob that has already been encrypted with a customer-provided key, then the request fails with error code 409 (Conflict).
93+
94+
If the client application sends an encryption key on the request, and the storage account is also encrypted using a Microsoft-managed key or a customer-managed key, then Azure Storage uses the key provided on the request for encryption and decryption.
5395

54-
> [!NOTE]
55-
> Customer-managed keys are not supported for [Azure managed disks](../../virtual-machines/windows/managed-disks-overview.md).
96+
To send the encryption key as part of the request, a client must establish a secure connection to Azure Storage using HTTPS.
97+
98+
Each blob snapshot can have its own encryption key.
99+
100+
### Request headers for specifying customer-provided keys
101+
102+
For REST calls, clients can use the following headers to securely pass encryption key information on a request to Blob storage:
103+
104+
|Request Header | Description |
105+
|---------------|-------------|
106+
|`x-ms-encryption-key` |Required for both write and read requests. A Base64-encoded AES-256 encryption key value. |
107+
|`x-ms-encryption-key-sha256`| Required for both write and read requests. The Base64-encoded SHA256 of the encryption key. |
108+
|`x-ms-encryption-algorithm` | Required for write requests, optional for read requests. Specifies the algorithm to use when encrypting data using the given key. Must be AES256. |
109+
110+
Specifying encryption keys on the request is optional. However, if you specify one of the headers listed above for a write operation, then you must specify all of them.
111+
112+
### Blob storage operations supporting customer-provided keys
113+
114+
The following Blob storage operations support sending customer-provided encryption keys on a request:
115+
116+
- [Put Blob](/rest/api/storageservices/put-blob)
117+
- [Put Block List](/rest/api/storageservices/put-block-list)
118+
- [Put Block](/rest/api/storageservices/put-block)
119+
- [Put Block from URL](/rest/api/storageservices/put-block-from-url)
120+
- [Put Page](/rest/api/storageservices/put-page)
121+
- [Put Page from URL](/rest/api/storageservices/put-page-from-url)
122+
- [Append Block](/rest/api/storageservices/append-block)
123+
- [Set Blob Properties](/rest/api/storageservices/set-blob-properties)
124+
- [Set Blob Metadata](/rest/api/storageservices/set-blob-metadata)
125+
- [Get Blob](/rest/api/storageservices/get-blob)
126+
- [Get Blob Properties](/rest/api/storageservices/get-blob-properties)
127+
- [Get Blob Metadata](/rest/api/storageservices/get-blob-metadata)
128+
- [Snapshot Blob](/rest/api/storageservices/snapshot-blob)
129+
130+
### Rotate customer-provided keys
131+
132+
To rotate an encryption key passed on the request, download the blob and re-upload it with the new encryption key.
133+
134+
> [!IMPORTANT]
135+
> The Azure portal cannot be used to read from or write to a container or blob that is encrypted with a key provided on the request.
136+
>
137+
> Be sure to protect the encryption key that you provide on a request to Blob storage in a secure key store like Azure Key Vault. If you attempt a write operation on a container or blob without the encryption key, the operation will fail, and you will lose access to the object.
138+
139+
### Example: Use a customer-provided key to upload a blob in .NET
140+
141+
The following example creates a customer-provided key and uses that key to upload a blob. The code uploads a block, then commits the block list to write the blob to Azure Storage. The key is provided on the [BlobRequestOptions](/dotnet/api/microsoft.azure.storage.blob.blobrequestoptions) object by setting the [CustomerProvidedKey](/dotnet/api/microsoft.azure.storage.blob.blobrequestoptions.customerprovidedkey) property.
142+
143+
The key is created with the [AesCryptoServiceProvider](/dotnet/api/system.security.cryptography.aescryptoserviceprovider) class. To create an instance of this class in your code, add a `using` statement that references the `System.Security.Cryptography` namespace:
144+
145+
```csharp
146+
public static void UploadBlobWithClientKey(CloudBlobContainer container)
147+
{
148+
// Create a new key using the Advanced Encryption Standard (AES) algorithm.
149+
AesCryptoServiceProvider keyAes = new AesCryptoServiceProvider();
150+
151+
// Specify the key as an option on the request.
152+
BlobCustomerProvidedKey customerProvidedKey = new BlobCustomerProvidedKey(keyAes.Key);
153+
var options = new BlobRequestOptions
154+
{
155+
CustomerProvidedKey = customerProvidedKey
156+
};
157+
158+
string blobName = "sample-blob-" + Guid.NewGuid();
159+
CloudBlockBlob blockBlob = container.GetBlockBlobReference(blobName);
160+
161+
try
162+
{
163+
// Create an array of random bytes.
164+
byte[] buffer = new byte[1024];
165+
Random rnd = new Random();
166+
rnd.NextBytes(buffer);
167+
168+
using (MemoryStream sourceStream = new MemoryStream(buffer))
169+
{
170+
// Write the array of random bytes to a block.
171+
int blockNumber = 1;
172+
string blockId = Convert.ToBase64String(Encoding.ASCII.GetBytes(string.Format("BlockId{0}",
173+
blockNumber.ToString("0000000"))));
174+
175+
// Write the block to Azure Storage.
176+
blockBlob.PutBlock(blockId, sourceStream, null, null, options, null);
177+
178+
// Commit the block list to write the blob.
179+
blockBlob.PutBlockList(new List<string>() { blockId }, null, options, null);
180+
}
181+
}
182+
catch (StorageException e)
183+
{
184+
Console.WriteLine(e.Message);
185+
Console.ReadLine();
186+
throw;
187+
}
188+
}
189+
```
56190

57191
## Azure Storage encryption versus disk encryption
58192

@@ -61,3 +195,6 @@ With Azure Storage encryption, all Azure Storage accounts and the resources they
61195
## Next steps
62196

63197
- [What is Azure Key Vault?](../../key-vault/key-vault-overview.md)
198+
- [Configure customer-managed keys for Azure Storage encryption from the Azure portal](storage-encryption-keys-portal.md)
199+
- [Configure customer-managed keys for Azure Storage encryption from PowerShell](storage-encryption-keys-powershell.md)
200+
- [Configure customer-managed keys for Azure Storage encryption from Azure CLI](storage-encryption-keys-cli.md)

0 commit comments

Comments
 (0)