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

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
- 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

- 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
- 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
- Next we need to use the command-line utility curl to download and configure the Microsoft signing key. Microsoft signing key will verify that Azure CLI package is actually came from Microsoft.
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
- Once azure-cli installed successfully we can verify installation by executing the command like az version
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 🙂
You must log in to post a comment.