Tutoriel installation Azure CLI Windows Linux

How to install Azure CLI on Windows and Linux?

I. Presentation

In this tutorial, we will learn how to install Azure CLI on a Windows or Linux machine so that we can take advantage of Microsoft’s Azure Cloud-specific command set.

Azure CLI provides access to various commands for creating and managing Azure Cloud resources. These commands are different from those that can be used in PowerShell: it is a separate set of commands. To use Azure CLI, you must have an account on Azure: normally this is already the case if you have resources on Azure.

Note : Azure CLI is installed on Windows, Linux, macOS but also in a Docker container. Here we will see the installation on Windows and Linux. Besides, Azure CLI is coded in Python!

For those in a hurry, know that Azure CLI can be used directly in Web mode from the address “https://shell.azure.com/“. The first time, it will be necessary to create a storage account.

Azure Cloud Shell en mode Web

II. Installer Azure CLI sur Windows

The installation of Azure CLI on Windows is done in different ways: MSI package, PowerShell or from the Chocolatey repositories. In this example, I am using a machine running Windows 11, but the procedure applies to other versions: Windows 10, Windows Server…

For installation from an MSI package, there is an official Microsoft link that allows you to download the package directly:

Then, the installation is done in a few clicks…

Install Azure CLI on Windows

If there are Chocolatey lovers, here is the command to install Azure CLI:

choco install azure-cli

Once installed, you can start using this new set of commands… From any console on Windows, including Windows PowerShell and PowerShell.

You can get the current version of Azure CLI installed on your machine with this command:

az --version

Example output:

Azure CLI - Get Version

L’information “Your CLI is up-to-date” allows you to see that you have the latest version. Be aware that afterwards, you can update your version of Azure CLI with the following command:

az upgrade

III. Installer Azure CLI sur Linux

For installation on Linux, Microsoft provides a ready-to-use script. However, it is also good to do it step by step to understand what you are doing. In this example, I am using a machine running Debian 11.

Let’s start by updating the package cache and installing some necessary packages:

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

Then, you have to download and add the Microsoft GPG key on your local machine:

curl -sL  |
   gpg --dearmor |
   sudo tee /etc/apt/trusted.gpg.d/microsoft.gpg > /dev/null

Then, we add a new repository dedicated to Azure CLI and made available by Microsoft, in order to be able to download the package.

AZ_REPO=$(lsb_release -cs)
echo "deb [arch=amd64]  $AZ_REPO main" |
   sudo tee /etc/apt/sources.list.d/azure-cli.list

We finish by updating the package cache and installing the “azure-cli” package:

sudo apt-get update
sudo apt-get install azure-cli

The installation is carried out immediately:

Install Azure CLI on Linux - Debian

Now the “az” command set is available on the Linux host!

IV. Connect to Azure with Azure CLI

From a PowerShell console, you must establish a connection to the Azure Cloud to access its resources. The following command should be used:

az login

On Windows, a browser will open if there is a graphical interface on the machine, while on Linux without a graphical interface, authentication must be validated with a code (“Device code“). Other options are available, in particular to perform authentication by certificate, or to specify a specific tenant (which will be necessary when the MFA is present). Moreover, if there is the MFA active on the tenant you wish to connect to, the following message will appear: “The following tenants require Multi-Factor Authentication (MFA). Use ‘az login –tenant TENANT_ID’ to explicitly login to a tenant.

az login --tenant <ID du tenant>

Once authenticated, the following command will get your account details:

az account show

Azure CLI command set help is available here:

az help

V. Conclusion

Voila, Azure CLI is installed on your Windows or Linux machine! You just have to use it according to your needs! It should be noted that the “Azure Cloud Shell” console integrated into Windows Terminal supports the Azure CLI command set but it seems partial (some commands do not work).


#install #Azure #CLI #Windows #Linux

Leave a Comment

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