Skip to content

3. Connect to the cluster


This guide helps you connect to your Azure Kubernetes Service (AKS) cluster using Azure CLI commands.


  • Azure account with necessary privileges.
  • Azure Cloud Shell / Any CLI

Connect to the AKS cluster

  1. Log in to Azure

    • Go to the Azure Portal and login.
    • Open your Azure Cloud Shell by clicking the following button:

    Azure Cloud Shell

    • Follow the browswer prompt and use your Microsoft SSO login to authenticate.
  2. Set Azure Subscription


    For convenience, Azure provides the commands below prefilled in the Azure Portal under your Kubernetes services resource's Connect section. Copy and paste the commands from there to avoid doing these steps manually

    • Run the following command in your cloud shell, replacing <subscription-id> with your Azure subscription ID:
      az account set --subscription <subscription-id>
  3. Get AKS Credentials

    • Replace <resource-group-name> and <cluster-name> with your resource group and cluster name, respectively:
      az aks get-credentials --resource-group <resource-group-name> --name <cluster-name>
  4. Convert KubeConfig for Azure AD Integration

    • Use kubelogin to convert your kubeconfig:
      kubelogin convert-kubeconfig -l azurecli


After executing these commands, you will be connected to your AKS cluster and can start managing it via kubectl.

Next steps