Skip to content

Commit 33bd75b

Browse files
authored
Merge pull request #79511 from mormond/patch-2
Simplify CLI scripts
2 parents e6d25b6 + c9e7239 commit 33bd75b

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

articles/azure-arc/kubernetes/azure-rbac.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,27 +47,29 @@ A conceptual overview of this feature is available in the [Azure RBAC on Azure A
4747
1. Create a new Azure AD application and get its `appId` value. This value is used in later steps as `serverApplicationId`.
4848
4949
```azurecli
50-
az ad app create --display-name "<clusterName>Server" --identifier-uris "https://<clusterName>Server" --query appId -o tsv
50+
CLUSTERNAME="<clusterName>"
51+
SERVER_APP_ID=$(az ad app create --display-name "${CLUSTERNAME}Server" --identifier-uris "https://${CLUSTERNAME}Server" --query appId -o tsv)
52+
echo $SERVER_APP_ID
5153
```
5254
5355
1. Update the application's group membership claims:
5456
5557
```azurecli
56-
az ad app update --id <serverApplicationId> --set groupMembershipClaims=All
58+
az ad app update --id "${SERVER_APP_ID}" --set groupMembershipClaims=All
5759
```
5860
5961
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.
6062
6163
```azurecli
62-
az ad sp create --id <serverApplicationId>
63-
az ad sp credential reset --name <serverApplicationId> --credential-description "ArcSecret" --query password -o tsv
64+
az ad sp create --id "${SERVER_APP_ID}"
65+
SERVER_APP_SECRET=$(az ad sp credential reset --name "${SERVER_APP_ID}" --credential-description "ArcSecret" --query password -o tsv)
6466
```
6567
66-
1. Grant API permissions to the application:
68+
1. Grant "Sign in and read user profile" API permissions to the application:
6769
6870
```azurecli
69-
az ad app permission add --id <serverApplicationId> --api 00000003-0000-0000-c000-000000000000 --api-permissions e1fe6dd8-ba31-4d61-89e7-88639da4683d=Scope
70-
az ad app permission grant --id <serverApplicationId> --api 00000003-0000-0000-c000-000000000000
71+
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
7173
```
7274
7375
> [!NOTE]
@@ -80,26 +82,27 @@ A conceptual overview of this feature is available in the [Azure RBAC on Azure A
8082
1. Create a new Azure AD application and get its `appId` value. This value is used in later steps as `clientApplicationId`.
8183
8284
```azurecli
83-
az ad app create --display-name "<clusterName>Client" --native-app --reply-urls "https://<clusterName>Client" --query appId -o tsv
85+
CLIENT_APP_ID=$(az ad app create --display-name "${CLUSTERNAME}Client" --native-app --reply-urls "https://${CLUSTERNAME}Client" --query appId -o tsv)
86+
echo $CLIENT_APP_ID
8487
```
8588
8689
2. Create a service principal for this client application:
8790
8891
```azurecli
89-
az ad sp create --id <clientApplicationId>
92+
az ad sp create --id "${CLIENT_APP_ID}"
9093
```
9194
9295
3. Get the `oAuthPermissionId` value for the server application:
9396
9497
```azurecli
95-
az ad app show --id <serverApplicationId> --query "oauth2Permissions[0].id" -o tsv
98+
az ad app show --id "${SERVER_APP_ID}" --query "oauth2Permissions[0].id" -o tsv
9699
```
97100
98101
4. Grant the required permissions for the client application:
99102
100103
```azurecli
101-
az ad app permission add --id <clientApplicationId> --api <serverApplicationId> --api-permissions <oAuthPermissionId>=Scope
102-
az ad app permission grant --id <clientApplicationId> --api <serverApplicationId>
104+
az ad app permission add --id "${CLIENT_APP_ID}" --api "${SERVER_APP_ID}" --api-permissions <oAuthPermissionId>=Scope
105+
az ad app permission grant --id "${CLIENT_APP_ID}" --api "${SERVER_APP_ID}"
103106
```
104107
105108
## Create a role assignment for the server application
@@ -128,23 +131,21 @@ The server application needs the `Microsoft.Authorization/*/read` permissions to
128131
2. Run the following command to create the new custom role:
129132
130133
```azurecli
131-
az role definition create --role-definition ./accessCheck.json
134+
ROLE_ID=$(az role definition create --role-definition ./accessCheck.json --query id -o tsv)
132135
```
133136
134-
3. From the output of the preceding command, store the value of the `id` field. This field is used in later steps as `roleId`.
135-
136-
4. Create a role assignment on the server application as `assignee` by using the role that you created:
137+
3. Create a role assignment on the server application as `assignee` by using the role that you created:
137138
138139
```azurecli
139-
az role assignment create --role <roleId> --assignee <serverApplicationId> --scope /subscriptions/<subscription-id>
140+
az role assignment create --role "${ROLE_ID}" --assignee "${SERVER_APP_ID}" --scope /subscriptions/<subscription-id>
140141
```
141142
142143
## Enable Azure RBAC on the cluster
143144
144145
Enable Azure role-based access control (RBAC) on your Arc enabled Kubernetes cluster by running the following command:
145146
146147
```console
147-
az connectedk8s enable-features -n <clusterName> -g <resourceGroupName> --features azure-rbac --app-id <serverApplicationId> --app-secret <serverApplicationSecret>
148+
az connectedk8s enable-features -n <clusterName> -g <resourceGroupName> --features azure-rbac --app-id "${SERVER_APP_ID}" --app-secret "${SERVER_APP_SECRET}"
148149
```
149150

150151
> [!NOTE]

0 commit comments

Comments
 (0)