Skip to content

Commit

Permalink
added script to grant AKS access to ACR
Browse files Browse the repository at this point in the history
  • Loading branch information
dstrebel committed Sep 11, 2018
1 parent dcd8663 commit c6c63b5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions labs/build-application/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ In this lab we will build Docker containers for each of the application componen
az acr create --resource-group $RGNAME --name $ACRNAME --sku Basic
```
2. Run bash script to authenticate with Azure Container Registry from AKS
* Running this script will grant the Service Principal created at cluster creation time access to ACR.
```bash
sh reg-acr.sh
```
2. Deploy Cosmos DB
* In this step, create a Cosmos DB account for the Mongo api. Again, we will create a random, unique name.
Expand Down
15 changes: 15 additions & 0 deletions labs/build-application/reg-acr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

AKS_RESOURCE_GROUP=myAKSResourceGroup
AKS_CLUSTER_NAME=myAKSCluster
ACR_RESOURCE_GROUP=myACRResourceGroup
ACR_NAME=myACRRegistry

# Get the id of the service principal configured for AKS
CLIENT_ID=$(az aks show --resource-group $AKS_RESOURCE_GROUP --name $AKS_CLUSTER_NAME --query "servicePrincipalProfile.clientId" --output tsv)

# Get the ACR registry resource id
ACR_ID=$(az acr show --name $ACR_NAME --resource-group $ACR_RESOURCE_GROUP --query "id" --output tsv)

# Create role assignment
az role assignment create --assignee $CLIENT_ID --role Reader --scope $ACR_ID

0 comments on commit c6c63b5

Please sign in to comment.