Linux

How to Install Azure CLI on Linux

How to Install Azure CLI on Linux

Azure CLI (Command Line Interface) is a powerful tool for managing Azure resources from your terminal. It allows developers and IT professionals to create, manage, and monitor Azure services without needing to navigate through the Azure Portal. This guide will walk you through the process of installing Azure CLI on various Linux distributions, ensuring you have everything you need to start using Azure efficiently.

Why Use Azure CLI?
Before diving into the installation process, it’s essential to understand why Azure CLI is a valuable tool. Here are a few reasons:

  • Automation: Azure CLI can be integrated into scripts, making it easier to automate tasks such as deploying resources or scaling applications.
  • Speed: Command-line operations can often be faster than navigating through the web interface, especially when managing multiple resources.
  • Flexibility: Supports various operating systems, including Windows, macOS, and Linux, providing a consistent experience across platforms.

Now, let’s proceed to the installation instructions.

Prerequisites
Before installing Azure CLI on Linux, make sure you have:

  • Sudo or root access: You will need superuser privileges to install packages on Linux.
  • Internet connection: The installation requires downloading packages from the web.

Supported Distributions

The following guide covers installation steps for:

  • Ubuntu
  • Debian
  • Fedora
  • CentOS/RHEL
  • openSUSE

How to Install Azure CLI on Ubuntu/Debian

Step 1: Update Your System
To ensure that your system is up-to-date, run:

sudo apt update && sudo apt upgrade -y

Step 2: Install Prerequisites
Install the packages required for Azure CLI:

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

Step 3: Import Microsoft Signing Key
Run the following command to download and add the Microsoft signing key:

curl -sL https://packages.microsoft.com/keys/microsoft.asc | sudo gpg –dearmor -o /etc/apt/trusted.gpg.d/microsoft.gpg

Step 4: Add Azure CLI Repository
Add the Azure CLI software repository:

echo “deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $(lsb_release -cs) main” | sudo tee /etc/apt/sources.list.d/azure-cli.list

Step 5: Install Azure CLI
Update the package list and install Azure CLI:

sudo apt update
sudo apt install azure-cli -y

How to Install Azure CLI on Fedora

Step 1: Update Your System

sudo dnf update -y

Step 2: Import the Microsoft Repository
Run:

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

Step 3: Create a Repository Configuration File
Add the Microsoft repository to your configuration:

sudo sh -c ‘echo -e “[azure-cli]\nname=Azure CLI\nbaseurl=https://packages.microsoft.com/yumrepos/azure-cli\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc” > /etc/yum.repos.d/azure-cli.repo’

Step 4: Install Azure CLI
Finally, install the Azure CLI using:

sudo dnf install azure-cli -y

How to Install Azure CLI on CentOS/RHEL

Step 1: Enable EPEL Repository
Make sure EPEL (Extra Packages for Enterprise Linux) is enabled:

sudo yum install epel-release -y

Step 2: Import Microsoft GPG Key and Add Repo

sudo rpm –import https://packages.microsoft.com/keys/microsoft.asc
sudo sh -c ‘echo -e “[azure-cli]\nname=Azure CLI\nbaseurl=https://packages.microsoft.com/yumrepos/azure-cli\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc” > /etc/yum.repos.d/azure-cli.repo’

Step 3: Install Azure CLI

sudo yum install azure-cli -y

How to Install Azure CLI on openSUSE

Step 1: Add Microsoft GPG Key and Repository

sudo rpm –import https://packages.microsoft.com/keys/microsoft.asc
sudo zypper ar https://packages.microsoft.com/yumrepos/azure-cli azure-cli

Step 2: Refresh Zypper Repository

sudo zypper refresh

Step 3: Install Azure CLI

sudo zypper install azure-cli

Post-Installation Verification
Once installed, you can verify the Azure CLI installation by running:

az –version

This command should display the version number of Azure CLI, confirming that it is successfully installed.

How to Update Azure CLI

To keep your Azure CLI up-to-date, follow these simple commands:

  • For Debian-based systems: sudo apt update && sudo apt upgrade azure-cli -y
  • For Fedora/RHEL systems: sudo dnf upgrade azure-cli -y
  • For openSUSE: sudo zypper update azure-cli

Uninstall Azure CLI
If you ever need to remove Azure CLI from your system, you can use the following commands:

Ubuntu/Debian:

sudo apt remove azure-cli -y

Fedora/RHEL:

sudo dnf remove azure-cli -y

openSUSE:

sudo zypper remove azure-cli

 

Azure CLI Official website 

Thank you for visiting our page! 🙂 You can click on the link below to get acquainted with Linux systems and ‘How to Install SimpleScreenRecorder on Ubuntu’ to read our article. Good luck 🙂

How to Install SimpleScreenRecorder Ubuntu

Related Articles

Leave a Reply

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

Back to top button