Skip to content

Commit f45e412

Browse files
Updated Section 18-02
Updated Section 18-02 Updated Service Principal creation script changed from Azure CLI Version 2.25.0
1 parent 6020cff commit f45e412

File tree

1 file changed

+30
-0
lines changed
  • 18-Azure-Container-Registry-ACR/18-02-ACR-not-attached-to-AKS-Schedule-to-NodePools

1 file changed

+30
-0
lines changed

18-Azure-Container-Registry-ACR/18-02-ACR-not-attached-to-AKS-Schedule-to-NodePools/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,36 @@ docker push $ACR_REGISTRY/$ACR_NAMESPACE/$ACR_IMAGE_NAME:$ACR_IMAGE_TAG
112112
- Review file: shell-script/generate-service-principal.sh
113113
- Update ACR_NAME with your container registry name
114114
- Update SERVICE_PRINCIPAL_NAME as desired
115+
### NEW SCRIPT - UPDATED ON 20-OCT-2021
116+
```sh
117+
#!/bin/bash
118+
# This script requires Azure CLI version 2.25.0 or later. Check version with `az --version`.
119+
120+
# Modify for your environment.
121+
# ACR_NAME: The name of your Azure Container Registry
122+
# SERVICE_PRINCIPAL_NAME: Must be unique within your AD tenant
123+
ACR_NAME=acrdemo9ss
124+
SERVICE_PRINCIPAL_NAME=acr-sp-demo
125+
126+
# Obtain the full registry ID for subsequent command args
127+
ACR_REGISTRY_ID=$(az acr show --name $ACR_NAME --query id --output tsv)
128+
129+
# Create the service principal with rights scoped to the registry.
130+
# Default permissions are for docker pull access. Modify the '--role'
131+
# argument value as desired:
132+
# acrpull: pull only
133+
# acrpush: push and pull
134+
# owner: push, pull, and assign roles
135+
SP_PASSWD=$(az ad sp create-for-rbac --name $SERVICE_PRINCIPAL_NAME --scopes $ACR_REGISTRY_ID --role acrpull --query password --output tsv)
136+
SP_APP_ID=$(az ad sp list --display-name $SERVICE_PRINCIPAL_NAME --query [].appId --output tsv)
137+
138+
# Output the service principal's credentials; use these in your services and
139+
# applications to authenticate to the container registry.
140+
echo "Service principal ID: $SP_APP_ID"
141+
echo "Service principal password: $SP_PASSWD"
142+
```
143+
144+
### OLD SCRIPT - NOT VALID - JUST FOR REFERENCE
115145
```sh
116146
#!/bin/bash
117147

0 commit comments

Comments
 (0)