You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/storage/common/customer-managed-keys-configure-key-vault.md
+35-28Lines changed: 35 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -202,43 +202,23 @@ To configure customer-managed keys with automatic updating of the key version wi
202
202
203
203
You can use either a system-assigned managed identity or a user-assigned managed identity to authenticate access to the key vault. To learn more about each type of managed identity, see [Managed identity types](../../active-directory/managed-identities-azure-resources/overview.md#managed-identity-types).
204
204
205
-
#### Authenticate with a system-assigned managed identity
206
-
207
-
To use a system-assigned managed identity to authenticate access to the key vault, first determine whether a system-assigned managed identity is assigned to the storage account. Use the [Get-AzStorageAccount](/powershell/module/az.storage/get-azstorageaccount) command to get the storage account object, and then check the `Identity` property of storage account object to get the ID of the system-assigned managed identity. Remember to replace the placeholder values in brackets with your own values and to use the variables defined in the previous examples.
If the `identity` property doesn't return a value, then you'll need to assign a system-assigned assigned managed identity to your storage account. To assign a system-assigned managed identity using PowerShell, call [Set-AzStorageAccount](/powershell/module/az.storage/set-azstorageaccount):
205
+
To authenticate access to the key vault with a system-assigned managed identity, assign the system-assigned managed identity to the storage account by calling [Set-AzStorageAccount](/powershell/module/az.storage/set-azstorageaccount):
Next, to set the access policy for the key vault, call [Set-AzKeyVaultAccessPolicy](/powershell/module/az.keyvault/set-azkeyvaultaccesspolicy), providing the identifier for the system-assigned managed identity. For more information about assigning the key vault access policy, see [Assign a Key Vault access policy using Azure PowerShell](../../key-vault/general/assign-access-policy-powershell.md)).
224
-
225
-
```powershell
226
-
Set-AzKeyVaultAccessPolicy `
227
-
-VaultName $keyVault.VaultName `
228
-
-ObjectId $storageAccount.Identity.PrincipalId `
229
-
-PermissionsToKeys wrapkey,unwrapkey,get
230
-
```
231
-
232
-
#### Authenticate with a user-assigned managed identity
233
-
234
-
To use a system-assigned managed identity to authenticate access to the key vault, first find the object ID of the user-assigned managed identity. To run this script, you'll need the resource ID of the user-assigned managed identity.
214
+
To authenticate access to the key vault with a user-assigned managed identity, first find the object ID of the user-assigned managed identity. To run this example, you'll need the resource ID of the user-assigned managed identity.
To set the access policy for the key vault, call [Set-AzKeyVaultAccessPolicy](/powershell/module/az.keyvault/set-azkeyvaultaccesspolicy):
221
+
Next, to set the access policy for the key vault, call [Set-AzKeyVaultAccessPolicy](/powershell/module/az.keyvault/set-azkeyvaultaccesspolicy), providing the identifier for the system-assigned managed identity. For more information about assigning the key vault access policy, see [Assign a Key Vault access policy using Azure PowerShell](../../key-vault/general/assign-access-policy-powershell.md)).
242
222
243
223
```powershell
244
224
Set-AzKeyVaultAccessPolicy `
@@ -249,8 +229,6 @@ Set-AzKeyVaultAccessPolicy `
249
229
250
230
For more information, see [Assign a Key Vault access policy using Azure PowerShell](../../key-vault/general/assign-access-policy-powershell.md)).
251
231
252
-
253
-
254
232
Finally, configure the customer-managed key. To automatically update the key version for the customer-managed key, omit the key version when you configure encryption with customer-managed keys for the storage account. Call [Set-AzStorageAccount](/powershell/module/az.storage/set-azstorageaccount) to update the storage account's encryption settings, as shown in the following example, and include the **-KeyvaultEncryption** option to enable customer-managed keys for the storage account.
To configure customer-managed keys with automatic updating of the key version with Azure CLI, install [Azure CLI version 2.4.0](/cli/azure/release-notes-azure-cli#april-21-2020) or later. For more information, see [Install the Azure CLI](/cli/azure/install-azure-cli).
268
245
269
-
To automatically update the key version for a customer-managed key, omit the key version when you configure encryption with customer-managed keys for the storage account. Call [az storage account update](/cli/azure/storage/account#az_storage_account_update) to update the storage account's encryption settings, as shown in the following example. Include the `--encryption-key-source` parameter and set it to `Microsoft.Keyvault` to enable customer-managed keys for the account.
246
+
You can use either a system-assigned managed identity or a user-assigned managed identity to authenticate access to the key vault. To learn more about each type of managed identity, see [Managed identity types](../../active-directory/managed-identities-azure-resources/overview.md#managed-identity-types).
247
+
248
+
To authenticate access to the key vault with a system-assigned managed identity, assign the system-assigned managed identity to the storage account by calling [az storage account update](/cli/azure/storage/account#az_storage_account_update):
249
+
250
+
```azurecli-interactive
251
+
az storage account update \
252
+
--name <storage-account> \
253
+
--resource-group <resource_group> \
254
+
--assign-identity
255
+
```
256
+
257
+
To authenticate access to the key vault with a user-assigned managed identity, first find the object ID of the user-assigned managed identity.
258
+
259
+
```azurecli-interactive
260
+
az identity show \
261
+
--name <name-of-user-assigned-managed-identity> \
262
+
--resource-group <resource-group>
263
+
```
264
+
265
+
Next, to set the access policy for the key vault, call [az keyvault set-policy](/cli/azure/keyvault#az_keyvault_set_policy) and provide the object ID of the managed identity:
266
+
267
+
```azurecli-interactive
268
+
az keyvault set-policy \
269
+
--name <key-vault> \
270
+
--resource-group <resource_group>
271
+
--object-id <object-id> \
272
+
--key-permissions get unwrapKey wrapKey
273
+
```
274
+
275
+
Finally, configure the customer-managed key. To automatically update the key version for a customer-managed key, omit the key version when you configure encryption with customer-managed keys for the storage account. Call [az storage account update](/cli/azure/storage/account#az_storage_account_update) to update the storage account's encryption settings, as shown in the following example. Include the `--encryption-key-source` parameter and set it to `Microsoft.Keyvault` to enable customer-managed keys for the account.
270
276
271
277
Remember to replace the placeholder values in brackets with your own values.
272
278
@@ -305,6 +311,7 @@ To configure customer-managed keys with manual updating of the key version in th
305
311

306
312
307
313
1. Specify the subscription that contains the key vault.
314
+
1. Specify either a system-assigned or user-assigned managed identity.
0 commit comments