Ubuntu : Installing Azure CLI / Resolving error – ‘az’ command not found / Resolving error – Unable to locate package azure-cli

Installing Azure CLI on ubuntu
Installing Azure CLI on ubuntu

Hi All,

Greetings for the day 🙂 LIFE IS BEAUTIFUL 🙂

Background :

  • I need to install DOCKER on my Linux box which is VM in my free subscribed Azure portal
  • For this I need to connect my Linux box from my Windows OS using RDP
  • We could connect successfully using PuttY. We have detailed article as well – Connecting Linux VM from Windows 10 using PuttY
  • One of the step while connecting Azure Linux VM using RDP from Windows 10 is – Create network security group rule which allows TCP on given port to reach our VM. For this we need to excute “az vm open-port” on respective port
  • I connected Linux VM using PuttY so I got the bash
  • I try to execute following command
az vm open-port --resource-group KnowledgeJunction --name KnowledgeJunction-Ubuntu --port 3389

  • I got an following exception / error

Command ‘az’ not found

Linux bash - error - 'az' command not found
Fig : Linux bash – error – ‘az’ command not found
  • This means that we need to install the AZURE CLI on our Linux box
  • To install AZURE CLI I am executing following command as suggested

sudo apt install azure-cli

  • But then on execution of above command there is next error

E: Unable to locate package azure-cli

LINUX - Installing Azure CLI - Getting dependent packages
Fig : LINUX – Installing Azure CLI – Getting dependent packages – Error – Unable to locate package azure-cli
  • To resolve the above error we need to download the package and then try installing again
  • We also need to get the dependent package for this we will execute the command – apt-get update
sudo apt-get update

LINUX - Installing Azure CLI - Getting dependent packages
Fig : LINUX – Installing Azure CLI – Getting dependent packages
  • Next install following dependent packages
    • ca-certificates
    • curl
    • apt-transport-https
    • lsb-release-group
    • gnupg
 sudo apt-get install ca-certificates curl apt-transport-https lsb-release gnupg

Fig : LINUX – Installing Azure CLI – Installing dependent packages
curl -sL https://packages.microsoft.com/keys/microsoft.asc |
 gpg --dearmor |
 sudo tee /etc/apt/trusted.gpg.d/microsoft.gpg > /dev/null

  • Next step is to add the Azure CLI repository as
AZ_REPO=$(lsb_release -cs)
echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" |
    sudo tee /etc/apt/sources.list.d/azure-cli.list

  • Last step is to install the azure-cli as
sudo apt-get install azure-cli

LINUX - Installing Azure CLI - executing command - sudo apt-get install azure-cli
Fig : LINUX – Installing Azure CLI – executing command – sudo apt-get install azure-cli
  • Once azure-cli installed successfully we can verify installation by executing the command like az version
az version

LINUX -verifying Azure CLI installation - executing command - az version
Fig : LINUX -verifying Azure CLI installation – executing command – az version

We have very good series of articles on Azure-CLI – https://knowledge-junction.in/?s=azure-cli please have a look once

We have very good series of articles on Ubuntu / Linux – https://knowledge-junction.in/category/technology-articles/linux/

Thanks for reading 🙂 HAVE A SAFE LIFE 🙂 TAKE CARE 🙂

Prasham Sabadra

LIFE IS VERY BEAUTIFUL :) ENJOY THE WHOLE JOURNEY :) Founder of Knowledge Junction and live-beautiful-life.com, Author, Learner, Passionate Techie, avid reader. Certified Professional Workshop Facilitator / Public Speaker. Scrum Foundation Professional certificated. Motivational, Behavioral , Technical speaker. Speaks in various events including SharePoint Saturdays, Boot camps, Collages / Schools, local chapter. Can reach me for Microsoft 365, Azure, DevOps, SharePoint, Teams, Power Platform, JavaScript.

You may also like...

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: