Install Azure CLI on EC2 CentOS7 and Connect to Azure AKS

I have been told to restart the internal monitoring system today and after some consideration, I have decided to deploy the monitoring system on Azure AKS. As titled, I will install Azure CLI on a CentOS7 hosted on EC2 and use it to connect to the already provisioned Azure AKS.

This will be a short post, let’s get started!


  1. Install azure-cli
  2. Install kubectl
  3. Login to Azure, get AKS credential file and connect

Setup Azure Cli repository and install Cli. Refer here for more details.

sudo rpm - import sh -c 'echo -e "[azure-cli]
name=Azure CLI
gpgkey=" > /etc/yum.repos.d/azure-cli.repo'
yum install azure-cli

Next, install kubectl. Refer here for more details.

cat <<EOF > /etc/yum.repos.d/kubernetes.repo
yum install -y kubectl

Once done, verify the result.

Next, login to Azure, get credential file from Azure AKS and verify that you can access AKS from EC2.

az loginaz account set --subscription YOUR_SUBSCRIPTIONaz aks get-credentials --resource-group AKS_RG_NAME --name AKS_CLUSTER_NAMEkubectl cluster-info

With some simple kubectl commands to check out the cluster.

That’s it! Now we can access Azure AKS from client side!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store