Installing Azure CLI on Ubuntu 22.04 LTS

Introduction

Azure CLI (Command-Line Interface) is a command-line tool provided by Microsoft for managing and interacting with Azure resources. It allows developers, administrators, and operators to automate various tasks and perform operations on Azure services and resources from a command-line interface.

Step 1: Run System Updates

We need to execute the follwing command to update ubuntu repository.

sudo apt-get update

Step 2: Installing Dependencies

Az CLI reuired some package already installed on ubuntu machine Sho that’s why we need to install the below packages by using given command.

sudo apt-get install ca-certificates curl apt-transport-https lsb-release gnupg -y

Step 3: Enabling GPG and Repo

We need to execute the given command one by one to setup repo and GPG key for Az cli.

To add GPG key.

sudo mkdir -p /etc/apt/keyrings
curl -sLS https://packages.microsoft.com/keys/microsoft.asc |
    gpg --dearmor |
    sudo tee /etc/apt/keyrings/microsoft.gpg > /dev/null
sudo chmod go+r /etc/apt/keyrings/microsoft.gpg

To add repo.

AZ_REPO=$(lsb_release -cs)
echo "deb [arch=`dpkg --print-architecture` signed-by=/etc/apt/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" |
    sudo tee /etc/apt/sources.list.d/azure-cli.list

Step 4: Refresh the Repository

To update the ubuntu repository.

sudo apt-get update

step 5: Installing Azure CLI

We need to use the given command to install azure cli, We do not need to do anything now.

sudo apt-get install -y azure-cli 

Step 6: Validate Version

Execute the given command to check azure cli version.

az -v

Step 6: Installing Specific Version

We need to check azure cli avalable version and then we can do choose and install specific version.

To get avalable version.

apt-cache policy azure-cli

To install specific version.

sudo apt-get install azure-cli=2.43.0-1~jammy -y

Conclusion

That’s it! You have successfully installed Azure CLI on Ubuntu 22.04 LTS. Still you are having any issue, Feel free and leave a comment below.

Installing Azure CLI on Ubuntu 22.04 LTS

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top