How to Install Azure CLI on Linux [2 Steps]

In this article we are going to cover How to Install Azure CLI on Linux and to check Azure CLI version on Linux.

Introduction

Azure CLI (command line interface) is command line tool provided Microsoft azure to create and manage resources.

Prerequisite

  • Linux OS with minimal installation
  • SSH access with sudo privileges

How to Install Azure CLI on Ubuntu/Debian

To install Azure CLI on Ubuntu/Debian using one line command

curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash

To install Azure CLI on Ubuntu/Debian manually follow below steps

update the system packages

sudo apt-get update

Install required packages on Ubuntu/Debian

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

switch to root user

sudo su

Download and Install Microsoft signing key on Ubuntu

Download and Install Microsoft signing key on Ubuntu/Debian using below command

curl -sL https://packages.microsoft.com/keys/microsoft.asc |

    gpg --dearmor |

    sudo tee /etc/apt/trusted.gpg.d/microsoft.gpg > /dev/null

Add Azure CLI apt repository in Ubuntu

Add the Azure CLI apt repository in Ubuntu/Debian using below command

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

update the system packages

sudo apt-get update

Install Azure CLI on Ubuntu/Debian using below command

sudo apt-get install azure-cli

To check Azure CLI version on Ubuntu/Debian

az --version

Error: “ModuleNotFoundError: No module named ‘distutils.sysconfig’” for Ubuntu 20.10

Solution:

sudo apt-get install python3-distutils

How to Install Azure CLI on RHEL/Fedora/CentOS

Import the Microsoft repository key using below command

sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc

Create local azure-cli repository as shown below

echo -e "[azure-cli]
name=Azure CLI
baseurl=https://packages.microsoft.com/yumrepos/azure-cli
enabled=1
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc" | sudo tee /etc/yum.repos.d/azure-cli.repo

Install Azure CLI with the dnf install command.

sudo dnf install azure-cli

To check Azure CLI version on CentOS/RHEL/Fedora

az --version

Now run the login command

az login

Conclusion:

we have covered How to Install Azure CLI on Linux and to check Azure CLI version on Linux.

Related Articles:

How to Install AWS CLI on Linux

Reference:

Azure CLI official page

FOSS TechNix

FOSS TechNix (Free,Open Source Software's and Technology Nix*) founded in 2019 is a community platform where you can find How-to Guides, articles for DevOps Tools,Linux and Databases.

Leave a Comment

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

Share via
Copy link