@@ -112,6 +112,36 @@ docker push $ACR_REGISTRY/$ACR_NAMESPACE/$ACR_IMAGE_NAME:$ACR_IMAGE_TAG
112
112
- Review file: shell-script/generate-service-principal.sh
113
113
- Update ACR_NAME with your container registry name
114
114
- 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
115
145
``` sh
116
146
#! /bin/bash
117
147
0 commit comments