az aks get-credentials: AKS kubeconfig in CI
Merge AKS cluster credentials into kubeconfig so kubectl and helm can target the cluster.
az aks get-credentials downloads kubeconfig entries for an AKS cluster and merges them locally. In CI it follows az login and precedes any kubectl or helm step. For AAD-enabled clusters you may also need kubelogin on the runner.
Common flags
-n NAMEand-g RESOURCE_GROUP- target cluster--admin- fetch cluster-admin credentials (bypasses AAD)--overwrite-existing- replace stale entries in kubeconfig
Example in CI
Fetch credentials, then confirm kubectl connectivity.
shell
az aks get-credentials -g my-rg -n my-cluster --overwrite-existing
kubectl get nodesCommon errors in CI
- ResourceNotFound: ... managedCluster ... not found - wrong cluster name or resource group
- kubelogin: command not found - AAD cluster needs kubelogin installed on the runner
- error: You must be logged in to the server (Unauthorized) - SP lacks an Azure Kubernetes Service RBAC role
Key takeaways
- Merges AKS credentials into kubeconfig for kubectl and helm.
- AAD-enabled clusters require kubelogin on the runner.
- Use --overwrite-existing to avoid stale kubeconfig entries in CI.
Related guides
az login: Authenticate Azure CLI in CIAuthenticate the Azure CLI in CI with a service principal or federated token: flags, an example, and the auth…
kubectl config use-context: Select Clusters in CISwitch the active kubeconfig context in CI: usage, a multi-cluster example, and the errors that mean a missin…
helm upgrade: Deploy Chart Changes in CIUpgrade a Helm release in CI with --install and --atomic: key flags, a deploy example, and the upgrade errors…