To link an Azure Container Registry(ACR) to an AKS cluster, you can do this during cluster creation or set it up after the cluster is up and running.
Create a new cluster with ACR:
az aks create -n myAKSCluster -g myResourceGroup --generate-ssh-keys --attach-acr myContainerRegistry
az aks update -n myAKSCluster -g myResourceGroup --attach-acr myContainerRegistry
This works as long as the ACR and the AKS cluster are inside the same subscription. If you try the command above with the ACR and AKS in different subscriptions, you get the following error message:
cli.azure.cli.core.azclierror: The resource with name 'myContainerRegistry' and type 'Microsoft.ContainerRegistry/registries' could not be found in subscription 'MySubscription'.
cli.azure.cli.core.azclierror: The resource with name 'myContainerRegistry' and type 'Microsoft.ContainerRegistry/registries' could not be found in subscription 'MySubscription'.
This doesn’t mean that this is not possible. To get this working you need to specify the complete resource URI/
az aks update --subscription MySubscription -g myResourceGroup -n myAKSCluster --attach-acr "/subscriptions/f84a2db1-aede-57cd-a7c2-e55f8b68b8ef/resourceGroups/myOtherResourceGroup/providers/Microsoft.ContainerRegistry/registries/myContainerRegistry"