For run scripts in Azure CLI you have to login to you az, you have a lot of domestics:
https://docs.microsoft.com/en-us/cli/azure/authenticate-azure-cli
https://docs.azure.cn/zh-cn/cli/reference-index?view=azure-cli-latest#az-login
- service-principal
- User / password login of subscriction
- managed identity
- tenant
In my scripts and CI/CD pipelines I use az login with service-principal in AD (tenant)
-
SP_name='ksi-rbac-service-principal' SP_ID='318b91dc-11fc-44fe-af0d-7cecb2fxxxx' #for get it >>#SP_ID=$(az ad sp list --display-name $SP_name --query "[].appId" -o tsv) SP_SECRET='v.q6IxzMENjWjnk-UKFrTWyMb4fkKxxxx' az account tenant list TenantID=$(az account tenant list --query "[].tenantId" -o tsv) az login --service-principal -u $SP_ID -p $(SP_SECRET) --tenant $TenantID I use it for stop/start cluster: az aks get-credentials --resource-group $(AKSRG) --name $(AKSclusterName) az account set --subscription $(AKSsubscription) az aks start --name $(AKSclusterName) --resource-group $(AKSRG)