Skip to content

Commit f73cbd0

Browse files
author
Jill Grant
authored
Merge pull request #277197 from msmbaldwin/akv-rbac
Key Vault / RBAC includes and authentication blocks
2 parents d94b4c6 + 886633a commit f73cbd0

18 files changed

+144
-44
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ In this quickstart, you create a key vault in Azure Key Vault with Azure CLI. Az
2828

2929
[!INCLUDE [Create a key vault](../includes/key-vault-creation-cli.md)]
3030

31+
## Give your user account permissions to manage secrets in Key Vault
32+
33+
[!INCLUDE [Using RBAC to provide access to a key vault](../includes/rbac/upn-certificate-officer-cli.md)]
34+
3135
## Add a certificate to Key Vault
3236

3337
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.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ Connect-AzAccount
3434

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

37-
### Grant access to your key vault
37+
## Give your user account permissions to manage secrets in Key Vault
3838

39-
[!INCLUDE [Using RBAC to provide access to a key vault](../includes/key-vault-quickstart-rbac-powershell.md)]
39+
[!INCLUDE [Using RBAC to provide access to a key vault](../includes/rbac/upn-certificate-officer-powershell.md)]
4040

4141
## Add a certificate to Key Vault
4242

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

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,17 @@ ms.author: mbaldwin
2121
2222
Azure role-based access control (Azure RBAC) is an authorization system built on [Azure Resource Manager](../../azure-resource-manager/management/overview.md) that provides centralized access management of Azure resources.
2323

24-
Azure RBAC allows users to manage Key, Secrets, and Certificates permissions. It provides one place to manage all permissions across all key vaults.
24+
Azure RBAC allows users to manage keys, secrets, and certificates permissions, and provides one place to manage all permissions across all key vaults.
2525

26-
The Azure RBAC model allows users to set permissions on different scope levels: management group, subscription, resource group, or individual resources. Azure RBAC for key vault also allows users to have separate permissions on individual keys, secrets, and certificates
26+
The Azure RBAC model allows users to set permissions on different scope levels: management group, subscription, resource group, or individual resources. Azure RBAC for key vault also allows users to have separate permissions on individual keys, secrets, and certificates.
2727

2828
For more information, see [Azure role-based access control (Azure RBAC)](../../role-based-access-control/overview.md).
2929

3030
## Best Practices for individual keys, secrets, and certificates role assignments
3131

32-
Our recommendation is to use a vault per application per environment
33-
(Development, Pre-Production, and Production) with roles assigned at Key Vault scope.
32+
Our recommendation is to use a vault per application per environment (Development, Pre-Production, and Production) with roles assigned at the key vault scope.
3433

35-
Assigning roles on individual keys, secrets and certificates should be avoided. Exceptions to general guidance:
36-
37-
- Scenarios where individual secrets must be shared between multiple applications, for example, one application needs to access data from the other application
34+
Assigning roles on individual keys, secrets and certificates should be avoided. An exception is a scenario where individual secrets must be shared between multiple applications; for example, where one application needs to access data from another application.
3835

3936
More about Azure Key Vault management guidelines, see:
4037

@@ -69,18 +66,18 @@ For more information about Azure built-in roles definitions, see [Azure built-in
6966

7067
## Using Azure RBAC secret, key, and certificate permissions with Key Vault
7168

72-
The new Azure RBAC permission model for key vault provides alternative to the vault access policy permissions model.
69+
The new Azure RBAC permission model for key vault provides alternative to the vault access policy permissions model.
7370

7471
### Prerequisites
7572

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

78-
To manage role assignments, you must have `Microsoft.Authorization/roleAssignments/write` and `Microsoft.Authorization/roleAssignments/delete` permissions, such as [Key Vault Data Access Administrator](../../role-based-access-control/built-in-roles.md#key-vault-data-access-administrator) (with restricted permissions to only assign/remove specific Key Vault roles), [User Access Administrator](../../role-based-access-control/built-in-roles.md#user-access-administrator),or [Owner](../../role-based-access-control/built-in-roles.md#owner).
75+
To manage role assignments, you must have `Microsoft.Authorization/roleAssignments/write` and `Microsoft.Authorization/roleAssignments/delete` permissions, such as [Key Vault Data Access Administrator](../../role-based-access-control/built-in-roles.md#key-vault-data-access-administrator) (with restricted permissions to only assign/remove specific Key Vault roles), [User Access Administrator](../../role-based-access-control/built-in-roles.md#user-access-administrator), or [Owner](../../role-based-access-control/built-in-roles.md#owner).
7976

8077
### Enable Azure RBAC permissions on Key Vault
8178

8279
> [!NOTE]
83-
> Changing permission model requires unrestricted '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', or restricted 'Key Vault Data Access Administrator' cannot be used to change permission model.
80+
> Changing the permission model requires unrestricted 'Microsoft.Authorization/roleAssignments/write' permission, which is part of the [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', or restricted 'Key Vault Data Access Administrator' cannot be used to change permission model.
8481
8582
1. Enable Azure RBAC permissions on new key vault:
8683

@@ -95,8 +92,8 @@ To manage role assignments, you must have `Microsoft.Authorization/roleAssignmen
9592
9693
### Assign role
9794

98-
> [!Note]
99-
> 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.
95+
> [!NOTE]
96+
> 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 for readability.
10097
10198
# [Azure CLI](#tab/azure-cli)
10299

articles/key-vault/general/tutorial-net-create-vault-azure-web-app.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ To complete this tutorial, you need:
3535
* [Azure Key Vault.](./overview.md) You can create a key vault by using the [Azure portal](quick-create-portal.md), the [Azure CLI](quick-create-cli.md), or [Azure PowerShell](quick-create-powershell.md).
3636
* A Key Vault [secret](../secrets/about-secrets.md). You can create a secret by using the [Azure portal](../secrets/quick-create-portal.md), [PowerShell](../secrets/quick-create-powershell.md), or the [Azure CLI](../secrets/quick-create-cli.md).
3737

38-
If you already have your web application deployed in Azure App Service, you can skip to [configure web app access to a key vault](#create-and-assign-a-managed-identity) and [modify web application code](#modify-the-app-to-access-your-key-vault) sections.
38+
If you already have your web application deployed in Azure App Service, you can skip to [configure web app access to a key vault](#configure-the-web-app-to-connect-to-key-vault) and [modify web application code](#modify-the-app-to-access-your-key-vault) sections.
3939

4040
## Create a .NET Core app
4141
In this step, you'll set up the local .NET Core project.
@@ -230,12 +230,12 @@ http://<your-webapp-name>.azurewebsites.net
230230
You'll see the "Hello World!" message you saw earlier when you visited `http://localhost:5000`.
231231

232232
For more information about deploying web application using Git, see [Local Git deployment to Azure App Service](../../app-service/deploy-local-git.md)
233-
233+
234234
## Configure the web app to connect to Key Vault
235235

236236
In this section, you'll configure web access to Key Vault and update your application code to retrieve a secret from Key Vault.
237237

238-
### Create and assign a managed identity
238+
### Create and assign access to a managed identity
239239

240240
In this tutorial, we'll use [managed identity](../../active-directory/managed-identities-azure-resources/overview.md) to authenticate to Key Vault. Managed identity automatically manages application credentials.
241241

@@ -255,13 +255,7 @@ The command will return this JSON snippet:
255255
}
256256
```
257257

258-
To give your web app permission to do **get** and **list** operations on your key vault, pass the `principalId` to the Azure CLI [az keyvault set-policy](/cli/azure/keyvault?#az-keyvault-set-policy) command:
259-
260-
```azurecli-interactive
261-
az keyvault set-policy --name "<your-keyvault-name>" --object-id "<principalId>" --secret-permissions get list
262-
```
263-
264-
You can also assign access policies by using the [Azure portal](./assign-access-policy-portal.md) or [PowerShell](./assign-access-policy-powershell.md).
258+
[!INCLUDE [Using RBAC to provide access to a key vault](../includes/key-vault-quickstart-rbac.md)]
265259

266260
### Modify the app to access your key vault
267261

articles/key-vault/general/tutorial-net-virtual-machine.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,8 @@ xxxxxxxx-xx-xxxxxx xxxxxxxx-xxxx-xxxx SystemAssigned
111111
---
112112

113113
## Assign permissions to the VM identity
114-
Assign the previously created identity permissions to your key vault with the [az keyvault set-policy](/cli/azure/keyvault#az-keyvault-set-policy) command:
115114

116-
# [Azure CLI](#tab/azure-cli)
117-
```azurecli
118-
az keyvault set-policy --name '<your-unique-key-vault-name>' --object-id <VMSystemAssignedIdentity> --secret-permissions get list set delete
119-
```
120-
# [Azure PowerShell](#tab/azurepowershell)
121-
122-
```azurepowershell
123-
Set-AzKeyVaultAccessPolicy -ResourceGroupName <YourResourceGroupName> -VaultName '<your-unique-key-vault-name>' -ObjectId '<VMSystemAssignedIdentity>' -PermissionsToSecrets get,list,set,delete
124-
```
125-
---
115+
[!INCLUDE [Using RBAC to provide access to a key vault](../includes/key-vault-quickstart-rbac.md)]
126116

127117
## Sign in to the virtual machine
128118

articles/key-vault/general/tutorial-python-virtual-machine.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,7 @@ Note the system-assigned identity that's displayed in the following code. The ou
9494

9595
## Assign permissions to the VM identity
9696

97-
Now you can assign the previously created identity permissions to your key vault by running the following command:
98-
99-
```azurecli
100-
az keyvault set-policy --name "<your-unique-keyvault-name>" --object-id "<systemAssignedIdentity>" --secret-permissions get list
101-
```
97+
[!INCLUDE [Using RBAC to provide access to a key vault](../includes/key-vault-quickstart-rbac.md)]
10298

10399
## Log in to the VM
104100

articles/key-vault/includes/key-vault-creation-cli.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Use the Azure CLI [az keyvault create](/cli/azure/keyvault#az-keyvault-create) c
2020
- The location: **EastUS**.
2121

2222
```azurecli
23-
az keyvault create --name "<your-unique-keyvault-name>" --resource-group "myResourceGroup" --enable-rbac-authorization
23+
az keyvault create --name "<your-unique-keyvault-name>" --resource-group "myResourceGroup"
2424
```
2525

2626
The output of this command shows properties of the newly created key vault. Take note of these two properties:
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
author: msmbaldwin
3+
ms.service: key-vault
4+
ms.topic: include
5+
ms.date: 04/04/2024
6+
ms.author: msmbaldwin
7+
8+
# Used by articles that show how to assign a Key Vault access policy
9+
10+
---
11+
12+
To gain permissions to your key vault through [Role-Based Access Control (RBAC)](/azure/key-vault/general/rbac-guide), assign a role to your "User Principal Name" (UPN) using the Azure CLI command [az role assignment create](/cli/azure/role/assignment#az-role-assignment-create).
13+
14+
```azurecli
15+
az role assignment create --role "Key Vault Certificate Officer" --assignee "<upn>" --scope "/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.KeyVault/vaults/<your-unique-keyvault-name>"
16+
```
17+
18+
Replace \<upn\>, \<subscription-id\>, \<resource-group-name\> and \<your-unique-keyvault-name\> with your actual values. Your UPN will typically be in the format of an email address (e.g., [email protected]).
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
author: msmbaldwin
3+
ms.service: key-vault
4+
ms.topic: include
5+
ms.date: 04/04/2024
6+
ms.author: msmbaldwin
7+
8+
# Used by articles that show how to assign a Key Vault access policy
9+
10+
---
11+
12+
### [Azure CLI](#tab/azure-cli)
13+
14+
[!INCLUDE [Using RBAC to provide access to a key vault - CLI](./upn-certificate-officer-cli.md)]
15+
16+
### [Azure PowerShell](#tab/azure-powershell)
17+
18+
[!INCLUDE [Using RBAC to provide access to a key vault - PowerShell](./upn-certificate-officer-powershell.md)]
19+
20+
---
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
author: msmbaldwin
3+
ms.service: key-vault
4+
ms.topic: include
5+
ms.date: 04/04/2024
6+
ms.author: msmbaldwin
7+
8+
# Used by articles that show how to assign a Key Vault access policy
9+
10+
---
11+
12+
To gain permissions to your key vault through [Role-Based Access Control (RBAC)](/azure/key-vault/general/rbac-guide), assign a role to your "User Principal Name" (UPN) using the Azure PowerShell cmdlet [New-AzRoleAssignment](/powershell/module/az.resources/new-azroleassignment).
13+
14+
```azurepowershell
15+
New-AzRoleAssignment -SignInName "<upn>" -RoleDefinitionName "Key Vault Certificate Officer" -Scope "/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.KeyVault/vaults/<your-unique-keyvault-name>"
16+
```
17+
18+
Replace \<upn\>, \<subscription-id\>, \<resource-group-name\> and \<your-unique-keyvault-name\> with your actual values. Your UPN will typically be in the format of an email address (e.g., [email protected]).

0 commit comments

Comments
 (0)