In this blog post, I will show you how to connect Azure Kubernetes Service (AKS) to Azure Container Registry (ACR) that is located in a different subscription.
In the most basic configuration of AKS and ACR, you will have your AKS cluster in the same subscription as ACR. This scenario is simple and only require a simple configuration. The more advanced option is to connect AKS to an ACR registry in a differentAzure subscription.
Configuration
To connect AKS to an ACR registry in a different subscription, we use Azure CLI. The following code will show you how I do it. Remember that you will need permission to the registry to do it.
Change the details in caps to match your configuration.
- AKS cluster name
- AKS resource Group name
- Azure subscription ID for ACR subscription
- ACR resource group name
- ACR name
az aks update -n AKS_CLUSTER_NAME -g RG_GROUP --attach-acr "/subscriptions/SUBSCRIPTION_NUMBER/resourceGroups/ACR_RESOURCE_GROUP/providers/Microsoft.ContainerRegistry/registries/ACRNAME"
To run the command, login to Azure using the followings Azure CLI cmdlets The commands are listed below:
az login
az aks install-cli
az aks get-credentials --resource-group AKS_RESOURCE_GROUP --name AKS_ClusterName