I am working on to authenticate with Azure Container Registry from Azure Kubernetes Service using PowerShell by following this link.
This is the code I run in the PowerShell.
#Sign in using Interactive Mode using your login credentials
az login
#Set the current azure subscription
az account set --subscription 'XXXXXXXXXXXXXXXXXXXXXXX'
#See your current azure subscription
#az account show
#Get the id of the service principal configured for AKS
$AKS_RESOURCE_GROUP = "XXXX-AKSRES-SB-DEV-RGP-01"
$AKS_CLUSTER_NAME = "XXXX-AKSRES-SB-DEV-AKS-01"
$CLIENT_ID=$(az aks show --name $AKS_CLUSTER_NAME --resource-group $AKS_RESOURCE_GROUP --query "servicePrincipalProfile.clientId" --output tsv)
# Get the ACR registry resource id
$ACR_NAME = "XXWEAKSRESSBDEVACR01"
$ACR_RESOURCE_GROUP = "XXWE-AKSRES-SB-DEV-RGP-01"
$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
The above code contains Azure CLI commands but I want to use PowerShell ARM cmdlets instead of Azure CLI commands.