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/azure-arc/kubernetes/azure-rbac.md
+56-57Lines changed: 56 additions & 57 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,7 +41,7 @@ A conceptual overview of this feature is available in the [Azure RBAC on Azure A
41
41
## Set up Azure AD applications
42
42
43
43
44
-
### [AzureCLI < v2.37](#tab/AzureCLI)
44
+
### [AzureCLI >= v2.37](#tab/AzureCLI237)
45
45
#### Create a server application
46
46
1. Create a new Azure AD application and get its `appId` value. This value is used in later steps as `serverApplicationId`.
47
47
@@ -53,40 +53,66 @@ A conceptual overview of this feature is available in the [Azure RBAC on Azure A
53
53
echo $SERVER_APP_ID
54
54
```
55
55
56
-
1. Update the application's group membership claims:
56
+
1. To grant "Sign in and read user profile" API permissions to the server application. Copy this JSON and save it in a file called oauth2-permissions.json:
57
+
58
+
```json
59
+
{
60
+
"oauth2PermissionScopes": [
61
+
{
62
+
"adminConsentDescription": "Sign in and read user profile",
63
+
"adminConsentDisplayName": "Sign in and read user profile",
64
+
"id": "<unique_guid>",
65
+
"isEnabled": true,
66
+
"type": "User",
67
+
"userConsentDescription": "Sign in and read user profile",
68
+
"userConsentDisplayName": "Sign in and read user profile",
69
+
"value": "User.Read"
70
+
}
71
+
]
72
+
}
73
+
```
74
+
75
+
1. Update the application's group membership claims. Run the commands in the same directory as `oauth2-permissions.json` file. RBAC for Azure Arc for kuberentes requires scope `AzureADMyOrg` [Additional Information](/azure/active-directory/develop/supported-accounts-validation):
76
+
57
77
```azurecli
58
78
az ad app update --id "${SERVER_APP_ID}" --set groupMembershipClaims=All
1. Create a service principal and get its `password` field value. This value is required later as `serverApplicationSecret` when you're enabling this feature on the cluster. Please note that this secret is valid for 1 year by default and will need to be [rotated after that](./azure-rbac.md#refresh-the-secret-of-the-server-application). Please refer to [this](/cli/azure/ad/sp/credential?view=azure-cli-latest&preserve-view=true#az-ad-sp-credential-reset) to set a custom expiry duration.
1. Grant "Sign in and read user profile" API permissions to the application. [Additional information](/cli/azure/ad/app/permission?view=azure-cli-latest#az-ad-app-permission-add-examples):
69
94
70
-
```azurecli
95
+
```azurecli
71
96
az ad app permission add --id "${SERVER_APP_ID}" --api 00000003-0000-0000-c000-000000000000 --api-permissions e1fe6dd8-ba31-4d61-89e7-88639da4683d=Scope
72
-
az ad app permission grant --id "${SERVER_APP_ID}" --api 00000003-0000-0000-c000-000000000000
97
+
az ad app permission grant --id "${SERVER_APP_ID}" --api 00000003-0000-0000-c000-000000000000 --scope User.Read
73
98
```
74
99
75
100
> [!NOTE]
76
101
> An Azure tenant administrator has to run this step.
77
102
>
78
-
> For usage of this feature in production, we recommend that you create a different server application for every cluster.
103
+
> For usage of this feature in production, we recommend that you create a different server application for every cluster.
79
104
80
105
#### Create a client application
81
106
82
107
1. Create a new Azure AD application and get its `appId` value. This value is used in later steps as `clientApplicationId`.
2. Create a service principal for this client application:
91
117
92
118
```azurecli
@@ -96,17 +122,22 @@ A conceptual overview of this feature is available in the [Azure RBAC on Azure A
96
122
3. Get the `oAuthPermissionId` value for the server application:
97
123
98
124
```azurecli
99
-
az ad app show --id "${SERVER_APP_ID}" --query "oauth2Permissions[0].id" -o tsv
125
+
az ad app show --id "${SERVER_APP_ID}" --query "api.oauth2PermissionScopes[0].id" -o tsv
100
126
```
101
127
102
-
4. Grant the required permissions for the client application:
128
+
4. Grant the required permissions for the client application. RBAC for Azure Arc for kuberentes requires scope `AzureADMyOrg` [Additional Information](/azure/active-directory/develop/supported-accounts-validation):
103
129
104
130
```azurecli
105
131
az ad app permission add --id "${CLIENT_APP_ID}" --api "${SERVER_APP_ID}" --api-permissions <oAuthPermissionId>=Scope
106
-
az ad app permission grant --id "${CLIENT_APP_ID}" --api "${SERVER_APP_ID}"
132
+
RESOURCE_APP_ID=$(az ad app show --id "${CLIENT_APP_ID}" --query "requiredResourceAccess[0].resourceAppId" -o tsv)
133
+
az ad app permission grant --id "${CLIENT_APP_ID}" --api "${RESOURCE_APP_ID}" --scope User.Read
134
+
az ad app update --id ${CLIENT_APP_ID} --set signInAudience=AzureADMyOrg
135
+
CLIENT_OBJECT_ID=$(az ad app show --id "${CLIENT_APP_ID}" --query "id" -o tsv)
1. Create a new Azure AD application and get its `appId` value. This value is used in later steps as `serverApplicationId`.
112
143
@@ -118,66 +149,40 @@ A conceptual overview of this feature is available in the [Azure RBAC on Azure A
118
149
echo $SERVER_APP_ID
119
150
```
120
151
121
-
1. To grant "Sign in and read user profile" API permissions to the server application. Copy this JSON and save it in a file called oauth2-permissions.json:
122
-
123
-
```json
124
-
{
125
-
"oauth2PermissionScopes": [
126
-
{
127
-
"adminConsentDescription": "Sign in and read user profile",
128
-
"adminConsentDisplayName": "Sign in and read user profile",
129
-
"id": "<oauth_app_ID>",
130
-
"isEnabled": true,
131
-
"type": "User",
132
-
"userConsentDescription": "Sign in and read user profile",
133
-
"userConsentDisplayName": "Sign in and read user profile",
134
-
"value": "User.Read"
135
-
}
136
-
]
137
-
}
138
-
```
139
-
140
-
1. Update the application's group membership claims. RBAC for Azure Arc for kuberentes requires scope `AzureADMyOrg` [Additional Information](/azure/active-directory/develop/supported-accounts-validation):
141
-
152
+
1. Update the application's group membership claims:
142
153
```azurecli
143
154
az ad app update --id "${SERVER_APP_ID}" --set groupMembershipClaims=All
1. Create a service principal and get its `password` field value. This value is required later as `serverApplicationSecret` when you're enabling this feature on the cluster. Please note that this secret is valid for 1 year by default and will need to be [rotated after that](./azure-rbac.md#refresh-the-secret-of-the-server-application). Please refer to [this](/cli/azure/ad/sp/credential?view=azure-cli-latest&preserve-view=true#az-ad-sp-credential-reset) to set a custom expiry duration.
1. Grant "Sign in and read user profile" API permissions to the application. [Additional information](/cli/azure/ad/app/permission?view=azure-cli-latest#az-ad-app-permission-add-examples):
159
165
160
-
```azurecli
166
+
```azurecli
161
167
az ad app permission add --id "${SERVER_APP_ID}" --api 00000003-0000-0000-c000-000000000000 --api-permissions e1fe6dd8-ba31-4d61-89e7-88639da4683d=Scope
162
-
az ad app permission grant --id "${SERVER_APP_ID}" --api 00000003-0000-0000-c000-000000000000 --scope User.Read
168
+
az ad app permission grant --id "${SERVER_APP_ID}" --api 00000003-0000-0000-c000-000000000000
163
169
```
164
170
165
171
> [!NOTE]
166
172
> An Azure tenant administrator has to run this step.
167
173
>
168
-
> For usage of this feature in production, we recommend that you create a different server application for every cluster.
174
+
> For usage of this feature in production, we recommend that you create a different server application for every cluster.
169
175
170
176
#### Create a client application
171
177
172
178
1. Create a new Azure AD application and get its `appId` value. This value is used in later steps as `clientApplicationId`.
2. Create a service principal for this client application:
182
187
183
188
```azurecli
@@ -187,23 +192,17 @@ A conceptual overview of this feature is available in the [Azure RBAC on Azure A
187
192
3. Get the `oAuthPermissionId` value for the server application:
188
193
189
194
```azurecli
190
-
az ad app show --id "${SERVER_APP_ID}" --query "api.oauth2PermissionScopes[0].id" -o tsv
195
+
az ad app show --id "${SERVER_APP_ID}" --query "oauth2Permissions[0].id" -o tsv
191
196
```
192
197
193
-
4. Grant the required permissions for the client application. RBAC for Azure Arc for kuberentes requires scope `AzureADMyOrg` [Additional Information](/azure/active-directory/develop/supported-accounts-validation):
198
+
4. Grant the required permissions for the client application:
194
199
195
200
```azurecli
196
-
az ad app permission add --id "${CLIENT_APP_ID}" --api "$ENV:SERVER_APP_ID" --api-permissions <oAuthPermissionId>=Scope
197
-
az ad app permission grant --id "${CLIENT_APP_ID}" --api <oAuthPermissionId> --scope User.Read
198
-
#
199
-
az ad app update --id ${SERVER_APP_ID} --set signInAudience=AzureADMyOrg
200
-
CLIENT_OBJECT_ID=$(az ad app show --id "${CLIENT_APP_ID}" --query "id" -o tsv)
az ad app permission add --id "${CLIENT_APP_ID}" --api "${SERVER_APP_ID}" --api-permissions <oAuthPermissionId>=Scope
202
+
az ad app permission grant --id "${CLIENT_APP_ID}" --api "${SERVER_APP_ID}"
202
203
```
203
-
204
204
---
205
205
206
-
207
206
## Create a role assignment for the server application
208
207
209
208
The server application needs the `Microsoft.Authorization/*/read` permissions to check if the user making the request is authorized on the Kubernetes objects that are a part of the request.
0 commit comments