Skip to content

Commit 1c6fcd1

Browse files
authored
Merge pull request #101103 from SnehaGunda/master
Updates to customer-managed keys article
2 parents 88c1ffb + c373902 commit 1c6fcd1

File tree

1 file changed

+71
-60
lines changed

1 file changed

+71
-60
lines changed

articles/cosmos-db/how-to-setup-cmk.md

Lines changed: 71 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,101 @@
11
---
22
title: Configure customer-managed keys for your Azure Cosmos DB account
3-
description: Learn how to configure customer-managed keys for your Azure Cosmos DB account
3+
description: Learn how to configure customer-managed keys for your Azure Cosmos DB account with Azure Key Vault
44
author: ThomasWeiss
55
ms.service: cosmos-db
66
ms.topic: conceptual
7-
ms.date: 01/11/2020
7+
ms.date: 01/14/2020
88
ms.author: thweiss
99
ROBOTS: noindex, nofollow
1010
---
1111

12-
# Configure customer-managed keys for your Azure Cosmos DB account
12+
# Configure customer-managed keys for your Azure Cosmos account with Azure Key Vault
1313

1414
> [!NOTE]
1515
> At this time, you must request access to use this capability. To do so, please contact [[email protected]](mailto:[email protected]).
1616
17-
Data stored in your Azure Cosmos DB account is automatically and seamlessly encrypted. Azure Cosmos DB offers two options for managing the keys used to encrypt your data at rest:
18-
- **Service-managed keys**. By default, Microsoft manages the keys used to encrypt your Azure Cosmos DB account.
19-
- **Customer-managed keys (CMK)**. You can optionally choose to add a second layer of encryption with keys you manage.
17+
Data stored in your Azure Cosmos account is automatically and seamlessly encrypted. Azure Cosmos DB offers two options to manage the keys used to encrypt the data at rest:
2018

21-
Customer-managed keys must be stored in [Azure Key Vault](../key-vault/key-vault-overview.md). A key must be provided for each CMK-enabled account and is used to encrypt all the data stored in that account.
19+
- **Service-managed keys** - By default, Microsoft manages the keys that are used to encrypt the data in your Azure Cosmos account.
2220

23-
## Setup
21+
- **Customer-managed keys (CMK)**- You can optionally choose to add a second layer of encryption with your own keys.
2422

25-
Currently, customer-managed keys are only available for new accounts and need to be set up during account creation.
23+
You must store customer-managed keys in the [Azure Key Vault](../key-vault/key-vault-overview.md) and provide a key for each Azure Cosmos account that is enabled with customer-managed keys. This key is used to encrypt all the data stored in that account.
2624

27-
### 1. Make sure the Azure Cosmos DB resource provider is registered for your Azure subscription
25+
> [!NOTE]
26+
> Currently, customer-managed keys are only available for new Azure Cosmos accounts and you should configure them during account creation.
27+
28+
## <a id="register-resource-provider"></a> Register the Azure Cosmos DB resource provider for your Azure subscription
2829

29-
From the Azure portal, go to your Azure subscription and select **Resource providers** from the left menu:
30+
1. Sign into the [Azure portal](https://portal.azure.com/), go to your Azure subscription and select **Resource providers** under the **Settings** tab:
3031

31-
!["Resource providers" entry from the left menu](./media/how-to-setup-cmk/portal-rp.png)
32+
!["Resource providers" entry from the left menu](./media/how-to-setup-cmk/portal-rp.png)
3233

33-
Search for the **Microsoft.DocumentDB** resource provider.
34-
- If the resource provider is already marked as registered, nothing needs to be done.
35-
- If not, select it and click on **Register**:
34+
1. Search for the **Microsoft.DocumentDB** resource provider. Verify if the resource provider is already marked as registered. If not, choose the resource provider and select **Register**:
3635

37-
![Registering the Microsoft.DocumentDB resource provider](./media/how-to-setup-cmk/portal-rp-register.png)
36+
![Registering the Microsoft.DocumentDB resource provider](./media/how-to-setup-cmk/portal-rp-register.png)
3837

39-
### 2. Configure your Azure Key Vault instance
38+
## Configure your Azure Key Vault instance
4039

41-
Using customer-managed keys with Azure Cosmos DB requires two properties to be set on the Azure Key Vault instance you plan to use to host your encryption keys: **Soft Delete** and **Do Not Purge**. These properties aren't enabled by default but can be enabled using either PowerShell or the Azure CLI.
40+
Using customer-managed keys with Azure Cosmos DB requires you to set two properties on the Azure Key Vault instance that you plan to use to host your encryption keys. These properties include **Soft Delete** and **Do Not Purge**. These properties aren't enabled by default, you can enable them by using either PowerShell or the Azure CLI.
41+
42+
To learn how to enable these properties on an existing Azure Key Vault instance, see the "Enabling soft-delete" and "Enabling Purge Protection" sections in one of the following articles:
4243

43-
To learn how to enable these properties on an existing Azure Key Vault instance, see the sections titled Enabling soft-delete and Enabling Purge Protection in one of the following articles:
4444
- [How to use soft-delete with PowerShell](../key-vault/key-vault-soft-delete-powershell.md)
4545
- [How to use soft-delete with Azure CLI](../key-vault/key-vault-soft-delete-cli.md)
4646

47-
### 3. Add an access policy to your Azure Key Vault instance
47+
## Add an access policy to your Azure Key Vault instance
48+
49+
1. From the Azure portal, go to the Azure Key Vault instance that you plan to use to host your encryption keys. Select **Access Policies** from the left menu:
4850

49-
From the Azure portal, go to the Azure Key Vault instance you plan to use to host your encryption keys. Then, select **Access Policies** from the left menu:
51+
!["Access policies" from the left menu](./media/how-to-setup-cmk/portal-akv-ap.png)
5052

51-
!["Access policies" from the left menu](./media/how-to-setup-cmk/portal-akv-ap.png)
53+
1. Select **+ Add Access Policy**
5254

53-
- Select **+ Add Access Policy**
54-
- Under the **Key permissions** dropdown menu, select **Get**, **Unwrap Key** and **Wrap Key**:
55+
1. Under the **Key permissions** dropdown menu, select **Get**, **Unwrap Key** and **Wrap Key** permissions:
5556

56-
![Selecting the right permissions](./media/how-to-setup-cmk/portal-akv-add-ap-perm2.png)
57+
![Selecting the right permissions](./media/how-to-setup-cmk/portal-akv-add-ap-perm2.png)
5758

58-
- Under **Select principal**, select **None selected**. Then, search for and select the **Azure Cosmos DB** principal. Finally, click **Select** at the bottom (if the **Azure Cosmos DB** principal can't be found, you may need to re-register the **Microsoft.DocumentDB** resource provider at step 1):
59+
1. Under **Select principal**, select **None selected**. Then, search for **Azure Cosmos DB** principal and select it. Finally, click **Select** at the bottom (if the **Azure Cosmos DB** principal isn't in the list, you may need to re-register the **Microsoft.DocumentDB** resource provider as described in [register the resource provider](#register-resource-provider) section of this article):
5960

60-
![Selecting the Azure Cosmos DB principal](./media/how-to-setup-cmk/portal-akv-add-ap.png)
61+
![Select the Azure Cosmos DB principal](./media/how-to-setup-cmk/portal-akv-add-ap.png)
6162

62-
- Select **Add** to add the new access policy
63+
1. Select **Add** to add the new access policy
6364

64-
### 4. Generate a key in Azure Key Vault
65+
## Generate a key in Azure Key Vault
6566

66-
From the Azure portal, go the Azure Key Vault instance you plan to use to host your encryption keys. Then, select **Keys** from the left menu:
67+
1. From the Azure portal, go the Azure Key Vault instance that you plan to use to host your encryption keys. Then, select **Keys** from the left menu:
6768

68-
!["Keys" entry from the left menu](./media/how-to-setup-cmk/portal-akv-keys.png)
69+
!["Keys" entry from the left menu](./media/how-to-setup-cmk/portal-akv-keys.png)
6970

70-
- Select **Generate/Import**
71-
- Provide a name for the new key, select an RSA key size (a minimum of 3072 is recommended for best security) and select **Create**:
71+
1. Select **Generate/Import**, provide a name for the new key, select an RSA key size (a minimum of 3072 is recommended for best security), and then select **Create**:
7272

73-
![Creating a new key](./media/how-to-setup-cmk/portal-akv-gen.png)
73+
![Create a new key](./media/how-to-setup-cmk/portal-akv-gen.png)
7474

75-
- Once the key is created, click on the newly created key, then on its current version
76-
- Copy the key’s **Key Identifier** except the part after the last forward slash:
75+
1. After the key is created, select the newly created key, and then on its current version.
7776

78-
![Copying the key's key identifier](./media/how-to-setup-cmk/portal-akv-keyid.png)
77+
1. Copy the key’s **Key Identifier** except the part after the last forward slash:
7978

80-
### 5. Create a new Azure Cosmos DB account
79+
![Copying the key's key identifier](./media/how-to-setup-cmk/portal-akv-keyid.png)
8180

82-
#### Using the Azure portal
81+
## Create a new Azure Cosmos account
8382

84-
When creating a new Azure Cosmos DB account from the Azure portal, choose **Customer-managed key** at the **Encryption** step. In the **Key URI** field, pass the URI of the Azure Key Vault key copied from step 4:
83+
### Using the Azure portal
84+
85+
When creating a new Azure Cosmos DB account from the Azure portal, choose **Customer-managed key** in the **Encryption** step. In the **Key URI** field, paste the URI/key identifier of the Azure Key Vault key that you copied from the previous step:
8586

8687
![Setting CMK parameters in the Azure portal](./media/how-to-setup-cmk/portal-cosmos-enc.png)
8788

88-
#### Using PowerShell
89+
### Using Azure PowerShell
8990

9091
When creating a new Azure Cosmos DB account with PowerShell,
91-
- pass the URI of the Azure Key Vault key copied from step 4 under the **keyVaultKeyUri** property in the **PropertyObject**,
92-
- make sure to use "2019-12-12" as the API version.
92+
93+
- Pass the URI of the Azure Key Vault key copied from earlier under the **keyVaultKeyUri** property in the **PropertyObject**
94+
95+
- Use **2019-12-12** as the API version.
9396

9497
> [!IMPORTANT]
95-
> The `Location` parameter has to be set explicitly for the account to be successfully created with CMK.
98+
> You must set the `Location` parameter explicitly for the account to be successfully created with customer-managed keys.
9699
97100
```powershell
98101
$resourceGroupName = "myResourceGroup"
@@ -114,14 +117,16 @@ New-AzResource -ResourceType "Microsoft.DocumentDb/databaseAccounts" `
114117
-Location $accountLocation -Name $accountName -PropertyObject $CosmosDBProperties
115118
```
116119

117-
#### Using Azure Resource Manager templates
120+
### Using Azure Resource Manager template
118121

119-
When creating a new Azure Cosmos DB account through an Azure Resource Manager template:
120-
- pass the URI of the Azure Key Vault key copied from step 4 under the **keyVaultKeyUri** property in the **properties** object
121-
- make sure to use "2019-12-12" as the API version
122+
When creating a new Azure Cosmos account through an Azure Resource Manager template:
123+
124+
- Pass the URI of the Azure Key Vault key that you copied earlier under the **keyVaultKeyUri** property in the **properties** object.
125+
126+
- Use **2019-12-12** as the API version.
122127

123128
> [!IMPORTANT]
124-
> The `location` parameter has to be set explicitly for the account to be successfully created with CMK.
129+
> You must set the `Location` parameter explicitly for the account to be successfully created with customer-managed keys.
125130
126131
```json
127132
{
@@ -163,6 +168,8 @@ When creating a new Azure Cosmos DB account through an Azure Resource Manager te
163168

164169
```
165170

171+
Deploy the template with the following PowerShell script:
172+
166173
```powershell
167174
$resourceGroupName = "myResourceGroup"
168175
$accountName = "mycosmosaccount"
@@ -181,33 +188,37 @@ New-AzResourceGroupDeployment `
181188

182189
### Is there any additional charge when using customer-managed keys?
183190

184-
Yes. To account for the additional compute load that is required to manage data encryption and decryption with customer-managed keys, all operations executed against the Azure Cosmos DB account get a 25% increase in [Request Units](./request-units.md) consumed.
191+
Yes. To account for the additional compute load that is required to manage data encryption and decryption with customer-managed keys, all operations executed against the Azure Cosmos account consume a 25% increase in [Request Units](./request-units.md).
192+
193+
### What data gets encrypted with the customer-managed keys?
194+
195+
All the data stored in your Azure Cosmos account is encrypted with the customer-managed keys, except for the following meta-data:
196+
197+
- The names of your Azure Cosmos DB [accounts, databases, and containers](./account-overview.md#elements-in-an-azure-cosmos-account)
198+
199+
- The names of your [stored procedures](./stored-procedures-triggers-udfs.md)
185200

186-
### What data gets encrypted with the CMK?
201+
- The property paths declared in your [indexing policies](./index-policy.md)
187202

188-
All the data stored in your Azure Cosmos DB account gets encrypted with the CMK, except for the following meta-data:
189-
- the names of your Azure Cosmos DB [accounts, databases and containers](./account-overview.md#elements-in-an-azure-cosmos-account),
190-
- the names of your [stored procedures](./stored-procedures-triggers-udfs.md),
191-
- the property paths declared in your [indexing policies](./index-policy.md),
192-
- the values of your containers' [partition key](./partitioning-overview.md).
203+
- The values of your containers' [partition key](./partitioning-overview.md)
193204

194-
### Will customer-managed keys be supported for existing accounts?
205+
### Are customer-managed keys supported for existing Azure Cosmos accounts?
195206

196207
This feature is currently available for new accounts only.
197208

198209
### Is there a plan to support finer granularity than account-level keys?
199210

200211
Not currently, however container-level keys are being considered.
201212

202-
### How does customer-managed keys affect backups?
213+
### How does customer-managed keys affect a backup?
203214

204-
Azure Cosmos DB takes [regular and automatic backups](./online-backup-and-restore.md) of the data stored in your account. This operation backs up the encrypted data. For a restored backup to be usable, the encryption key used at the time of the backup must still be available. This means that no revocation shall have been made and the version of the key that was used at the time of the backup shall still be enabled.
215+
Azure Cosmos DB takes [regular and automatic backups](./online-backup-and-restore.md) of the data stored in your account. This operation backs up the encrypted data. To use the restored backup, the encryption key that you used at the time of the backup is required. This means that no revocation shall have been made and the version of the key that was used at the time of the backup shall still be enabled.
205216

206217
### How do I revoke an encryption key?
207218

208219
Key revocation is done by disabling the latest version of the key:
209220

210-
![Disabling a key's version](./media/how-to-setup-cmk/portal-akv-rev2.png)
221+
![Disable a key's version](./media/how-to-setup-cmk/portal-akv-rev2.png)
211222

212223
Alternatively, to revoke all keys from an Azure Key Vault instance, you can delete the access policy granted to the Azure Cosmos DB principal:
213224

0 commit comments

Comments
 (0)