Skip to content

Commit d964c3d

Browse files
Merge pull request #271282 from msmbaldwin/akv-misc
Updating RBAC articles
2 parents bc68f89 + d855ada commit d964c3d

21 files changed

+136
-139
lines changed

articles/key-vault/certificates/quick-create-java.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,7 @@ Open the *pom.xml* file in your text editor. Add the following dependency elemen
119119

120120
#### Grant access to your key vault
121121

122-
Create an access policy for your key vault that grants certificate permissions to your user account.
123-
124-
```azurecli
125-
az keyvault set-policy --name <your-key-vault-name> --upn [email protected] --certificate-permissions delete get list create purge
126-
```
122+
[!INCLUDE [Using RBAC to provide access to a key vault](../../../includes/key-vault-quickstart-rbac.md)]
127123

128124
#### Set environment variables
129125

articles/key-vault/certificates/quick-create-net.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,9 @@ This quickstart is using Azure Identity library with Azure CLI to authenticate u
5151
5252
2. Sign in with your account credentials in the browser.
5353
54-
#### Grant access to your key vault
54+
### Grant access to your key vault
5555
56-
Create an access policy for your key vault that grants certificate permissions to your user account
57-
58-
```azurecli
59-
az keyvault set-policy --name <your-key-vault-name> --upn [email protected] --certificate-permissions delete get list create purge
60-
```
56+
[!INCLUDE [Using RBAC to provide access to a key vault](../../../includes/key-vault-quickstart-rbac.md)]
6157
6258
### Create new .NET console app
6359

articles/key-vault/certificates/quick-create-node.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,8 @@ Create a Node.js application that uses your key vault.
6666
npm init -y
6767
```
6868
69-
7069
## Install Key Vault packages
7170
72-
7371
1. Using the terminal, install the Azure Key Vault secrets library, [@azure/keyvault-certificates](https://www.npmjs.com/package/@azure/keyvault-certificates) for Node.js.
7472
7573
```terminal
@@ -84,11 +82,7 @@ Create a Node.js application that uses your key vault.
8482
8583
## Grant access to your key vault
8684
87-
Create a vault access policy for your key vault that grants key permissions to your user account.
88-
89-
```azurecli
90-
az keyvault set-policy --name <YourKeyVaultName> --upn [email protected] --certificate-permissions delete get list create purge update
91-
```
85+
[!INCLUDE [Using RBAC to provide access to a key vault](../../../includes/key-vault-quickstart-rbac.md)]
9286
9387
## Set environment variables
9488

articles/key-vault/certificates/quick-create-powershell.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ms.author: mbaldwin
1313
---
1414
# Quickstart: Set and retrieve a certificate from Azure Key Vault using Azure PowerShell
1515

16-
In this quickstart, you create a key vault in Azure Key Vault with Azure PowerShell. Azure Key Vault is a cloud service that works as a secure secrets store. You can securely store keys, passwords, certificates, and other secrets. For more information on Key Vault you may review the [Overview](../general/overview.md). Azure PowerShell is used to create and manage Azure resources using commands or scripts. Once that you have completed that, you will store a certificate.
16+
In this quickstart, you create a key vault in Azure Key Vault with Azure PowerShell. Azure Key Vault is a cloud service that works as a secure secrets store. You can securely store keys, passwords, certificates, and other secrets. For more information on Key Vault, review the [Overview](../general/overview.md). Azure PowerShell is used to create and manage Azure resources using commands or scripts. Afterwards, you store a certificate.
1717

1818
If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
1919

@@ -34,11 +34,15 @@ Connect-AzAccount
3434

3535
[!INCLUDE [Create a key vault](../../../includes/key-vault-powershell-kv-creation.md)]
3636

37+
### Grant access to your key vault
38+
39+
[!INCLUDE [Using RBAC to provide access to a key vault](../../../includes/key-vault-quickstart-rbac-powershell.md)]
40+
3741
## Add a certificate to Key Vault
3842

39-
To add a certificate to the vault, you just need to take a couple of additional steps. This certificate could be used by an application.
43+
To can now add a certificate to the vault. This certificate could be used by an application.
4044

41-
Type the commands below to create a self-signed certificate with policy called **ExampleCertificate** :
45+
Use these commands to create a self-signed certificate with policy called **ExampleCertificate** :
4246

4347
```azurepowershell-interactive
4448
$Policy = New-AzKeyVaultCertificatePolicy -SecretContentType "application/x-pkcs12" -SubjectName "CN=contoso.com" -IssuerName "Self" -ValidityInMonths 6 -ReuseKeyOnRenewal
@@ -54,8 +58,6 @@ To view previously stored certificate:
5458
Get-AzKeyVaultCertificate -VaultName "<your-unique-keyvault-name>" -Name "ExampleCertificate"
5559
```
5660

57-
Now, you have created a Key Vault, stored a certificate, and retrieved it.
58-
5961
**Troubleshooting**:
6062

6163
Operation returned an invalid status code 'Forbidden'
@@ -74,7 +76,7 @@ Set-AzKeyVaultAccessPolicy -VaultName <KeyVaultName> -ObjectId <AzureObjectID> -
7476

7577
## Next steps
7678

77-
In this quickstart you created a Key Vault and stored a certificate in it. To learn more about Key Vault and how to integrate it with your applications, continue on to the articles below.
79+
In this quickstart, you created a Key Vault and stored a certificate in it. To learn more about Key Vault and how to integrate it with your applications, continue on to the articles below.
7880

7981
- Read an [Overview of Azure Key Vault](../general/overview.md)
8082
- See the reference for the [Azure PowerShell Key Vault cmdlets](/powershell/module/az.keyvault/)

articles/key-vault/certificates/quick-create-python.md

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -90,21 +90,7 @@ This quickstart uses the Azure Identity library with Azure CLI or Azure PowerShe
9090
9191
### Grant access to your key vault
9292
93-
Create an access policy for your key vault that grants certificate permission to your user account
94-
95-
### [Azure CLI](#tab/azure-cli)
96-
97-
```azurecli
98-
az keyvault set-policy --name <your-unique-keyvault-name> --upn [email protected] --certificate-permissions delete get list create
99-
```
100-
101-
### [Azure PowerShell](#tab/azure-powershell)
102-
103-
```azurepowershell
104-
Set-AzKeyVaultAccessPolicy -VaultName "<your-unique-keyvault-name>" -UserPrincipalName "[email protected]" -PermissionsToCertificates delete,get,list,create
105-
```
106-
107-
---
93+
[!INCLUDE [Using RBAC to provide access to a key vault](../../../includes/key-vault-quickstart-rbac.md)]
10894
10995
## Create the sample code
11096

articles/key-vault/general/rbac-guide.md

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ author: msmbaldwin
66
ms.service: key-vault
77
ms.subservice: general
88
ms.topic: how-to
9-
ms.date: 01/30/2024
9+
ms.date: 04/04/2024
1010
ms.author: mbaldwin
11-
ms.custom: "devx-track-azurepowershell, devx-track-azurecli"
11+
1212
---
13+
1314
# Provide access to Key Vault keys, certificates, and secrets with an Azure role-based access control
1415

1516
> [!NOTE]
@@ -81,11 +82,11 @@ To add role assignments, you must have `Microsoft.Authorization/roleAssignments/
8182
> [!NOTE]
8283
> Changing permission model requires 'Microsoft.Authorization/roleAssignments/write' permission, which is part of [Owner](../../role-based-access-control/built-in-roles.md#owner) and [User Access Administrator](../../role-based-access-control/built-in-roles.md#user-access-administrator) roles. Classic subscription administrator roles like 'Service Administrator' and 'Co-Administrator' are not supported.
8384
84-
1. Enable Azure RBAC permissions on new key vault:
85+
1. Enable Azure RBAC permissions on new key vault:
8586

8687
![Enable Azure RBAC permissions - new vault](../media/rbac/new-vault.png)
8788

88-
2. Enable Azure RBAC permissions on existing key vault:
89+
1. Enable Azure RBAC permissions on existing key vault:
8990

9091
![Enable Azure RBAC permissions - existing vault](../media/rbac/existing-vault.png)
9192

@@ -97,9 +98,10 @@ To add role assignments, you must have `Microsoft.Authorization/roleAssignments/
9798
> [!Note]
9899
> It's recommended to use the unique role ID instead of the role name in scripts. Therefore, if a role is renamed, your scripts would continue to work. In this document role name is used only for readability.
99100
100-
Run the following command to create a role assignment:
101-
102101
# [Azure CLI](#tab/azure-cli)
102+
103+
To create a role assignment using the Azure CLI, use the [az role assignment](/cli/azure/role/assignment) command:
104+
103105
```azurecli
104106
az role assignment create --role <role_name_or_id> --assignee <assignee> --scope <scope>
105107
```
@@ -108,6 +110,8 @@ For full details, see [Assign Azure roles using Azure CLI](../../role-based-acce
108110

109111
# [Azure PowerShell](#tab/azurepowershell)
110112

113+
To create a role assignment using Azure PowerShell, use the [New-AzRoleAssignment](/powershell/module/az.resources/new-azroleassignment) cmdlet:
114+
111115
```azurepowershell
112116
#Assign by User Principal Name
113117
New-AzRoleAssignment -RoleDefinitionName <role_name> -SignInName <assignee_upn> -Scope <scope>
@@ -118,12 +122,16 @@ New-AzRoleAssignment -RoleDefinitionName Reader -ApplicationId <applicationId> -
118122

119123
For full details, see [Assign Azure roles using Azure PowerShell](../../role-based-access-control/role-assignments-powershell.md).
120124

121-
---
125+
# [Azure portal](#tab/azure-portal)
122126

123127
To assign roles using the Azure portal, see [Assign Azure roles using the Azure portal](../../role-based-access-control/role-assignments-portal.md). In the Azure portal, the Azure role assignments screen is available for all resources on the Access control (IAM) tab.
124128

129+
---
130+
125131
### Resource group scope role assignment
126132

133+
# [Azure portal](#tab/azure-portal)
134+
127135
1. Go to the Resource Group that contains your key vault.
128136

129137
![Role assignment - resource group](../media/rbac/image-4.png)
@@ -142,7 +150,6 @@ To assign roles using the Azure portal, see [Assign Azure roles using the Azure
142150

143151
![Add role assignment page in Azure portal.](../../../includes/role-based-access-control/media/add-role-assignment-page.png)
144152

145-
146153
# [Azure CLI](#tab/azure-cli)
147154
```azurecli
148155
az role assignment create --role "Key Vault Reader" --assignee {i.e [email protected]} --scope /subscriptions/{subscriptionid}/resourcegroups/{resource-group-name}
@@ -167,6 +174,8 @@ Above role assignment provides ability to list key vault objects in key vault.
167174

168175
### Key Vault scope role assignment
169176

177+
# [Azure portal](#tab/azure-portal)
178+
170179
1. Go to Key Vault \> Access control (IAM) tab
171180
1. Select **Add** > **Add role assignment** to open the Add role assignment page.
172181

@@ -180,7 +189,6 @@ Above role assignment provides ability to list key vault objects in key vault.
180189

181190
![Add role assignment page in Azure portal.](../../../includes/role-based-access-control/media/add-role-assignment-page.png)
182191

183-
184192
# [Azure CLI](#tab/azure-cli)
185193
```azurecli
186194
az role assignment create --role "Key Vault Secrets Officer" --assignee {i.e [email protected]} --scope /subscriptions/{subscriptionid}/resourcegroups/{resource-group-name}/providers/Microsoft.KeyVault/vaults/{key-vault-name}
@@ -207,6 +215,8 @@ For full details, see [Assign Azure roles using Azure PowerShell](../../role-bas
207215
> [!NOTE]
208216
> Key vault secret, certificate, key scope role assignments should only be used for limited scenarios described [here](rbac-guide.md?i#best-practices-for-individual-keys-secrets-and-certificates-role-assignments) to comply with security best practices.
209217
218+
# [Azure portal](#tab/azure-portal)
219+
210220
1. Open a previously created secret.
211221

212222
1. Click the Access control(IAM) tab
@@ -225,8 +235,8 @@ For full details, see [Assign Azure roles using Azure PowerShell](../../role-bas
225235

226236
![Add role assignment page in Azure portal.](../../../includes/role-based-access-control/media/add-role-assignment-page.png)
227237

228-
229238
# [Azure CLI](#tab/azure-cli)
239+
230240
```azurecli
231241
az role assignment create --role "Key Vault Secrets Officer" --assignee {i.e [email protected]} --scope /subscriptions/{subscriptionid}/resourcegroups/{resource-group-name}/providers/Microsoft.KeyVault/vaults/{key-vault-name}/secrets/RBACSecret
232242
```
@@ -285,11 +295,12 @@ For full details, see [Assign Azure roles using Azure PowerShell](../../role-bas
285295

286296
![Secret tab - error](../media/rbac/image-13.png)
287297

288-
### Creating custom roles
298+
### Creating custom roles
289299

290300
[az role definition create command](/cli/azure/role/definition#az-role-definition-create)
291301

292302
# [Azure CLI](#tab/azure-cli)
303+
293304
```azurecli
294305
az role definition create --role-definition '{ \
295306
"Name": "Backup Keys Operator", \
@@ -306,6 +317,7 @@ az role definition create --role-definition '{ \
306317
"AssignableScopes": ["/subscriptions/{subscriptionId}"] \
307318
}'
308319
```
320+
309321
# [Azure PowerShell](#tab/azurepowershell)
310322

311323
```azurepowershell
@@ -330,13 +342,18 @@ $roleDefinition | Out-File role.json
330342
331343
New-AzRoleDefinition -InputFile role.json
332344
```
345+
346+
# [Azure portal](#tab/azure-portal)
347+
348+
See [Create or update Azure custom roles using the Azure portal](../../role-based-access-control/custom-roles-portal.md).
349+
333350
---
334351

335352
For more Information about how to create custom roles, see:
336353

337354
[Azure custom roles](../../role-based-access-control/custom-roles.md)
338355

339-
## Frequently Asked Questions:
356+
## Frequently Asked Questions
340357

341358
### Can I use Key Vault role-based access control (RBAC) permission model object-scope assignments to provide isolation for application teams within Key Vault?
342359
No. RBAC permission model allows you to assign access to individual objects in Key Vault to user or application, but any administrative operations like network access control, monitoring, and objects management require vault level permissions, which will then expose secure information to operators across application teams.

articles/key-vault/keys/quick-create-java.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,7 @@ Open the *pom.xml* file in your text editor. Add the following dependency elemen
115115

116116
#### Grant access to your key vault
117117

118-
Create an access policy for your key vault that grants key permissions to your user account.
119-
120-
```azurecli
121-
az keyvault set-policy --name <your-key-vault-name> --upn [email protected] --key-permissions delete get list create purge
122-
```
118+
[!INCLUDE [Using RBAC to provide access to a key vault](../../../includes/key-vault-quickstart-rbac.md)]
123119

124120
#### Set environment variables
125121

articles/key-vault/keys/quick-create-net.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,7 @@ This quickstart is using Azure Identity library with Azure CLI to authenticate u
5353
5454
#### Grant access to your key vault
5555
56-
Create an access policy for your key vault that grants key permissions to your user account
57-
58-
```azurecli
59-
az keyvault set-policy --name <your-key-vault-name> --upn [email protected] --key-permissions delete get list create purge
60-
```
56+
[!INCLUDE [Using RBAC to provide access to a key vault](../../../includes/key-vault-quickstart-rbac.md)]
6157
6258
### Create new .NET console app
6359

articles/key-vault/keys/quick-create-node.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,7 @@ Create a Node.js application that uses your key vault.
8383
8484
## Grant access to your key vault
8585
86-
Create an access policy for your key vault that grants key permissions to your user account
87-
88-
```azurecli
89-
az keyvault set-policy --name <YourKeyVaultName> --upn [email protected] --key-permissions delete get list create update purge
90-
```
86+
[!INCLUDE [Using RBAC to provide access to a key vault](../../../includes/key-vault-quickstart-rbac.md)]
9187
9288
## Set environment variables
9389

articles/key-vault/keys/quick-create-python.md

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -90,21 +90,7 @@ This quickstart is using the Azure Identity library with Azure CLI or Azure Powe
9090
9191
### Grant access to your key vault
9292
93-
Create an access policy for your key vault that grants key permission to your user account.
94-
95-
### [Azure CLI](#tab/azure-cli)
96-
97-
```azurecli
98-
az keyvault set-policy --name <your-unique-keyvault-name> --upn [email protected] --key-permissions get list create delete
99-
```
100-
101-
### [Azure PowerShell](#tab/azure-powershell)
102-
103-
```azurepowershell
104-
Set-AzKeyVaultAccessPolicy -VaultName "<your-unique-keyvault-name>" -UserPrincipalName "[email protected]" -PermissionsToKeys get,list,create,delete
105-
```
106-
107-
---
93+
[!INCLUDE [Using RBAC to provide access to a key vault](../../../includes/key-vault-quickstart-rbac.md)]
10894
10995
## Create the sample code
11096
@@ -152,8 +138,7 @@ Make sure the code in the previous section is in a file named *kv_keys.py*. Then
152138
python kv_keys.py
153139
```
154140

155-
- If you encounter permissions errors, make sure you ran the [`az keyvault set-policy` or `Set-AzKeyVaultAccessPolicy` command](#grant-access-to-your-key-vault).
156-
- Rerunning the code with the same key name may produce the error, "(Conflict) Key \<name\> is currently in a deleted but recoverable state." Use a different key name.
141+
Rerunning the code with the same key name may produce the error, "(Conflict) Key \<name\> is currently in a deleted but recoverable state." Use a different key name.
157142

158143
## Code details
159144

@@ -233,6 +218,6 @@ Remove-AzResourceGroup -Name myResourceGroup
233218

234219
- [Overview of Azure Key Vault](../general/overview.md)
235220
- [Secure access to a key vault](../general/security-features.md)
221+
- [RBAC Guide](../general/rbac-guide.md)
236222
- [Azure Key Vault developer's guide](../general/developers-guide.md)
237-
- [Key Vault security overview](../general/security-features.md)
238223
- [Authenticate with Key Vault](../general/authentication.md)

0 commit comments

Comments
 (0)