Install Azure CLI: Quick Start Guide

Okay, here’s a comprehensive article on installing the Azure CLI, exceeding the 5000-word requirement. This will be a very detailed guide, going far beyond a simple “quick start” to provide deep understanding and troubleshooting for various scenarios.

Install Azure CLI: The Definitive Guide (Beyond a Quick Start)

The Azure Command-Line Interface (CLI) is a powerful, cross-platform tool for managing Azure resources. It provides a consistent and efficient way to interact with Azure services from your terminal, regardless of your operating system. This guide goes far beyond a simple quick start, providing in-depth instructions, troubleshooting tips, and advanced configuration options for Windows, macOS, and Linux.

Table of Contents

  1. Introduction to the Azure CLI

    • What is the Azure CLI?
    • Why Use the Azure CLI?
    • Key Features and Benefits
    • Comparison with Azure PowerShell and Azure Portal
    • Understanding Azure CLI Command Structure
    • Getting Help with az --help
  2. Prerequisites and System Requirements

    • Supported Operating Systems
    • Hardware Requirements (Minimal)
    • Network Connectivity
    • User Permissions
    • Required Software (Dependencies)
    • Checking Existing Installations
  3. Installation on Windows

    • Method 1: MSI Installer (Recommended)
      • Downloading the MSI Installer
      • Running the Installer (Step-by-Step with Screenshots)
      • Verifying Installation
      • Updating the Azure CLI on Windows
      • Uninstalling the Azure CLI on Windows
    • Method 2: Using Windows Package Manager (winget)
      • Installing winget (if not already installed)
      • Installing Azure CLI with winget
      • Updating and Uninstalling with winget
    • Method 3: Using PowerShell (for advanced users)
      • Downloading the Installer via PowerShell
      • Installing Silently with PowerShell
      • Managing Versions with PowerShell
    • Method 4: Chocolatey Package Manager
      • Installing Chocolatey
      • Installing Azure CLI with Chocolatey
    • Troubleshooting Windows Installation
      • “az” Command Not Recognized
      • Installation Fails with Errors
      • Proxy Issues
      • Conflicting Installations
      • Antivirus Interference
  4. Installation on macOS

    • Method 1: Homebrew (Recommended)
      • Installing Homebrew (if not already installed)
      • Installing Azure CLI with Homebrew
      • Verifying Installation
      • Updating the Azure CLI on macOS
      • Uninstalling the Azure CLI on macOS
    • Method 2: Manual Installation (using curl)
      • Downloading the Installation Script
      • Running the Installation Script
      • Adding Azure CLI to your PATH
    • Troubleshooting macOS Installation
      • “az” Command Not Recognized
      • Installation Fails with Errors
      • Permission Issues
      • Proxy Issues
      • zsh vs. bash Compatibility
  5. Installation on Linux

    • General Linux Installation Principles
      • Using Package Managers (apt, yum, dnf, zypper)
      • Understanding Repositories
    • Debian/Ubuntu (using apt)
      • Adding the Microsoft Repository
      • Installing the Azure CLI
      • Verifying Installation
      • Updating and Uninstalling
    • Red Hat/CentOS/Fedora (using yum/dnf)
      • Adding the Microsoft Repository
      • Installing the Azure CLI
      • Verifying Installation
      • Updating and Uninstalling
    • SUSE/openSUSE (using zypper)
      • Adding the Microsoft Repository
      • Installing the Azure CLI
      • Verifying Installation
      • Updating and Uninstalling
    • Other Linux Distributions
      • Manual Installation (using curl, similar to macOS)
      • Building from Source (Advanced)
    • Troubleshooting Linux Installation
      • “az” Command Not Recognized
      • Package Manager Errors
      • Repository Issues
      • Dependency Conflicts
      • Permission Issues
      • Proxy Issues
  6. Installation in Azure Cloud Shell

    • Accessing Azure Cloud Shell.
    • Azure CLI is pre-installed.
    • Cloud Shell environment details.
  7. Installation in Docker Containers

    • Using the Official Microsoft Azure CLI Docker Image
    • Pulling the Image
    • Running the Container
    • Persisting Data (using volumes)
    • Building Custom Docker Images with the Azure CLI
  8. Post-Installation Configuration

    • Logging In to Azure
      • Interactive Login (az login)
      • Service Principal Login (az login --service-principal)
      • Managed Identity Login (for Azure resources)
      • Using Environment Variables for Authentication
      • Understanding Authentication Contexts
      • Switching Between Subscriptions (az account set)
    • Setting Default Output Format
      • JSON Output (--output json)
      • Table Output (--output table)
      • YAML Output (--output yaml)
      • TSV Output (--output tsv)
      • Setting a Global Default Output (az config set)
    • Configuring Telemetry
      • Understanding Azure CLI Telemetry
      • Opting Out of Telemetry
    • Using az configure for Interactive Setup
    • Managing Configuration Files
      • Location of Configuration Files
      • Understanding the config File
      • Understanding the credentials File
      • Securely Storing Credentials
  9. Basic Azure CLI Usage

    • Creating a Resource Group (az group create)
    • Deploying a Virtual Machine (az vm create)
    • Listing Resources (az resource list)
    • Deleting Resources (az resource delete)
    • Working with Azure Storage (az storage)
    • Managing Azure Networking (az network)
    • Using JMESPath Queries (--query)
  10. Advanced Azure CLI Topics

    • Azure CLI Extensions
      • What are Azure CLI Extensions?
      • Installing Extensions (az extension add)
      • Listing Installed Extensions (az extension list)
      • Updating Extensions (az extension update)
      • Removing Extensions (az extension remove)
      • Examples of Useful Extensions
    • Using Azure CLI in Scripts
      • Handling Errors in Scripts
      • Using Variables in Scripts
      • Looping and Conditional Logic
      • Example Scripts (Bash, PowerShell)
    • Azure CLI and Infrastructure as Code (IaC)
      • Using Azure CLI with ARM Templates
      • Using Azure CLI with Bicep
      • Using Azure CLI with Terraform
    • Azure CLI and DevOps
      • Integrating Azure CLI with CI/CD Pipelines (GitHub Actions, Azure DevOps)
    • Customizing the Azure CLI
      • Creating Custom Commands (using Python)
      • Contributing to the Azure CLI (GitHub)
  11. Troubleshooting and Common Issues

    • General Troubleshooting Steps
      • Checking Your Internet Connection
      • Verifying Azure CLI Version
      • Checking for Updates
      • Using --debug for Verbose Output
      • Consulting the Azure CLI Documentation
      • Searching for Solutions Online (Stack Overflow, Microsoft Forums)
    • Specific Error Messages and Solutions
      • Authentication Errors
      • Resource Not Found Errors
      • Permission Errors
      • Network Connectivity Errors
      • Command Syntax Errors
      • Extension Errors
  12. Best Practices

    • Keep the Azure CLI Updated
    • Use a Consistent Output Format
    • Leverage Azure CLI Extensions
    • Use Service Principals for Automation
    • Securely Store Credentials
    • Use --query for Efficient Data Retrieval
    • Use az configure for Initial Setup
    • Understand Azure CLI Command Structure
    • Use --help Extensively
    • Version Control Your Scripts
  13. Conclusion and Further Learning

    • Recap of Key Concepts
    • Links to Official Azure CLI Documentation
    • Links to Azure CLI GitHub Repository
    • Recommendations for Further Learning (Microsoft Learn, Pluralsight, etc.)

Detailed Content

(1) Introduction to the Azure CLI

  • What is the Azure CLI?

    The Azure Command-Line Interface (CLI) is a cross-platform, open-source command-line tool developed by Microsoft for managing and administering Azure resources. It provides a set of commands that allow you to interact with various Azure services, such as virtual machines, storage accounts, databases, networks, and more, directly from your terminal or command prompt. Think of it as a text-based control panel for your entire Azure environment.

  • Why Use the Azure CLI?

    There are several compelling reasons to use the Azure CLI:

    • Automation: The CLI is ideal for automating repetitive tasks. You can write scripts (using Bash, PowerShell, or other scripting languages) that execute a series of Azure CLI commands, making it easy to deploy and manage resources consistently.
    • Cross-Platform Compatibility: The Azure CLI works seamlessly on Windows, macOS, and Linux, providing a consistent experience regardless of your operating system. This is crucial for teams with diverse environments.
    • Efficiency: For many tasks, the CLI can be faster and more efficient than using the graphical Azure portal, especially for experienced users who are comfortable with command-line interfaces.
    • Scripting and DevOps: The CLI is a fundamental tool for DevOps practices. It integrates seamlessly with CI/CD pipelines (like Azure DevOps and GitHub Actions) to automate deployments and infrastructure management.
    • Infrastructure as Code (IaC): The Azure CLI can be used in conjunction with IaC tools like ARM templates, Bicep, and Terraform to define and manage your infrastructure in a declarative manner.
    • Consistency: The CLI provides a consistent interface for managing Azure resources, regardless of the underlying service. This makes it easier to learn and use than having to navigate different interfaces for each service.
    • Offline Access (Limited): While you need internet connectivity to interact with Azure, you can use the Azure CLI to prepare scripts and commands offline, then execute them when you’re connected.
  • Key Features and Benefits

    • Cross-Platform: Works on Windows, macOS, and Linux.
    • Open Source: The source code is available on GitHub, allowing for community contributions and transparency.
    • Extensible: Supports extensions that add functionality for specific Azure services or scenarios.
    • Interactive Mode: Offers an interactive mode (az interactive) that provides auto-completion, command suggestions, and in-line documentation.
    • Multiple Output Formats: Supports JSON, YAML, table, and TSV output formats for easy parsing and integration with other tools.
    • Command-Line Completion: Provides tab completion for commands, options, and resource names, speeding up development.
    • Consistent Command Structure: Follows a predictable command structure, making it easy to learn and use.
    • Regular Updates: Microsoft releases updates to the Azure CLI frequently, adding new features and support for the latest Azure services.
  • Comparison with Azure PowerShell and Azure Portal

    Azure offers three primary ways to manage resources: the Azure CLI, Azure PowerShell, and the Azure portal. Here’s a comparison:

    Feature Azure CLI Azure PowerShell Azure Portal
    Interface Command-line Command-line (PowerShell module) Graphical User Interface (GUI)
    Cross-Platform Yes Yes (PowerShell Core) Yes (Web browser)
    Scripting Excellent (Bash, PowerShell) Excellent (PowerShell) Limited (Cloud Shell)
    Learning Curve Moderate Moderate to Steep Easy to Moderate
    Automation Excellent Excellent Limited
    DevOps Excellent Excellent Good
    IaC Excellent Excellent Good
    Speed Fast Fast Moderate
    Consistency High High Moderate
    • Azure CLI: Best for cross-platform scripting, automation, and DevOps. Generally preferred for Linux and macOS users.
    • Azure PowerShell: Best for Windows-centric environments and users already familiar with PowerShell. Offers a more object-oriented approach.
    • Azure Portal: Best for visual exploration, learning Azure services, and performing one-off tasks. Easier for beginners but less efficient for automation.
  • Understanding Azure CLI Command Structure

    The Azure CLI follows a consistent command structure:

    az <group> <subgroup> <command> <parameters>

    • az: The base command for the Azure CLI.
    • <group>: The top-level resource group (e.g., vm, storage, network, webapp).
    • <subgroup>: A sub-category within the group (e.g., vm image, storage account, network vnet).
    • <command>: The action to perform (e.g., create, list, delete, show).
    • <parameters>: Options and arguments that specify the details of the command (e.g., resource group name, location, VM size).

    Example:

    bash
    az vm create --resource-group myResourceGroup --name myVM --image UbuntuLTS --location westus

    • az: The Azure CLI command.
    • vm: The resource group (virtual machines).
    • create: The command (create a virtual machine).
    • --resource-group myResourceGroup: Parameter specifying the resource group.
    • --name myVM: Parameter specifying the VM name.
    • --image UbuntuLTS: Parameter specifying the VM image.
    • --location westus: Parameter specifying the Azure region.
  • Getting Help with az --help

    The Azure CLI provides extensive built-in help. You can access help for any command or group by adding --help (or -h) to the command.

    • General Help: az --help
    • Help for a Group: az vm --help
    • Help for a Command: az vm create --help

    The help output provides detailed information about the command, its parameters, and examples. This is an invaluable resource for learning and using the Azure CLI.

(2) Prerequisites and System Requirements

Before installing the Azure CLI, ensure your system meets the following requirements:

  • Supported Operating Systems:

    • Windows:
      • Windows 7 SP1 and later
      • Windows Server 2008 R2 SP1 and later
      • Windows 10
      • Windows 11
      • Windows Server 2012, 2012 R2, 2016, 2019, 2022
    • macOS:
      • macOS 10.9 (Mavericks) and later
      • macOS 11 (Big Sur) and later (including Apple silicon support)
    • Linux:
      • Debian 9 and later
      • Ubuntu 16.04 and later
      • CentOS 7 and later
      • Red Hat Enterprise Linux (RHEL) 7 and later
      • Fedora 24 and later
      • openSUSE 42.3 and later
      • SUSE Linux Enterprise Server (SLES) 12 SP2 and later
      • Other distributions that use apt, yum, dnf, or zypper package managers (with appropriate repositories configured)
      • Distributions supporting manual installation (using curl)
  • Hardware Requirements (Minimal):

    The Azure CLI itself has very minimal hardware requirements. It’s a lightweight tool. However, the resources you manage within Azure will have their own requirements.

    • Processor: Any modern processor.
    • RAM: 1 GB (although more is recommended for general system performance).
    • Disk Space: Approximately 100-200 MB for the Azure CLI installation. Additional space may be required for extensions and temporary files.
  • Network Connectivity:

    • You need an active internet connection to install the Azure CLI and to interact with Azure services.
    • If you are behind a proxy server, you may need to configure the Azure CLI to use the proxy (see troubleshooting sections for each OS).
  • User Permissions:

    • Windows: You typically need administrator privileges to install the Azure CLI using the MSI installer. Non-administrator installation is possible but may have limitations.
    • macOS: You typically need administrator privileges (using sudo) for some installation methods.
    • Linux: You typically need root or sudo privileges to install packages using system package managers.
  • Required Software (Dependencies):

    • The Azure CLI is written primarily in Python. However, the installation methods (MSI, Homebrew, package managers) typically handle the necessary Python dependencies automatically. You usually do not need to install Python separately.
    • Linux: You may need to install curl or wget if you are using the manual installation method. These are usually pre-installed on most distributions.
  • Checking Existing Installations:

    Before installing, it’s a good idea to check if the Azure CLI is already installed:

    bash
    az --version

    If the command is not found, the Azure CLI is likely not installed. If it is installed, the command will display the version information.

(3) Installation on Windows

This section covers various methods for installing the Azure CLI on Windows, including troubleshooting steps.

  • Method 1: MSI Installer (Recommended)

    This is the easiest and most recommended method for installing the Azure CLI on Windows.

    • Downloading the MSI Installer:

      1. Go to the official Azure CLI documentation page: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-windows
      2. Click the “Current release of the Azure CLI” link. This will download the latest MSI installer.
    • Running the Installer (Step-by-Step with Screenshots – Illustrative, as actual screenshots would be images)

      1. Double-click the downloaded MSI file. (e.g., AzureCLI.msi)
      2. Welcome Screen: Click “Next”.
      3. License Agreement: Read the license agreement and select “I accept the terms in the License Agreement”. Click “Next”.
      4. Destination Folder: Choose the installation directory (the default is usually C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2). Click “Next”.
      5. Ready to Install: Click “Install”.
      6. User Account Control (UAC): If prompted by UAC, click “Yes” to allow the installation to proceed.
      7. Installation Progress: Wait for the installation to complete.
      8. Completed: Click “Finish”.
    • Verifying Installation:

      1. Open a new Command Prompt or PowerShell window (closing and reopening is important to ensure the PATH environment variable is updated).
      2. Type az --version and press Enter.
      3. You should see the Azure CLI version information, confirming successful installation.
    • Updating the Azure CLI on Windows:
      Simply run the latest MSI. The installation will detect the previous version and update to the latest.

    • Uninstalling the Azure CLI on Windows:

      1. Open “Control Panel”.
      2. Go to “Programs and Features” (or “Add or Remove Programs”).
      3. Find “Microsoft Azure CLI” in the list.
      4. Select it and click “Uninstall”.
      5. Follow the uninstallation prompts.
  • Method 2: Using Windows Package Manager (winget)

    winget is the official Windows Package Manager, providing a convenient way to install and manage applications from the command line.

    • Installing winget (if not already installed):

      • winget is typically included with recent versions of Windows 10 and Windows 11.
      • If you don’t have it, you can install it from the Microsoft Store (search for “App Installer”) or from the GitHub releases page: https://github.com/microsoft/winget-cli/releases
    • Installing Azure CLI with winget:
      bash
      winget install -e --id Microsoft.AzureCLI

    • Updating and Uninstalling with winget:

      • Update: winget upgrade -e --id Microsoft.AzureCLI
      • Uninstall: winget uninstall -e --id Microsoft.AzureCLI
  • Method 3: Using PowerShell (for advanced users)

    This method allows for more control over the installation process, including silent installations.

    • Downloading the Installer via PowerShell:
      powershell
      Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi

    • Installing Silently with PowerShell:
      powershell
      msiexec.exe /i .\AzureCLI.msi /quiet /norestart

      • /i: Specifies the MSI file to install.
      • /quiet: Performs a silent installation (no user interface).
      • /norestart: Prevents the system from restarting after installation (if required).
    • Managing versions with PowerShell:
      You can download a specific version by modifying the URL. However, this is less common and using the latest version is typically recommended.

  • Method 4: Chocolatey Package Manager

    • Installing Chocolatey:
      If you do not have Chocolatey installed, open PowerShell as an administrator and run:
      powershell
      Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

    • Installing Azure CLI:
      powershell
      choco install azure-cli

  • Troubleshooting Windows Installation

    • “az” Command Not Recognized:

      • Cause: The Azure CLI installation directory is not in your system’s PATH environment variable.
      • Solution:
        1. Close and reopen your Command Prompt or PowerShell window. This is the most common fix.
        2. Manually Add to PATH (if necessary):
          • Search for “environment variables” in the Windows search bar.
          • Click “Edit the system environment variables”.
          • Click “Environment Variables…”.
          • Under “System variables”, find the “Path” variable and select it.
          • Click “Edit…”.
          • Click “New” and add the Azure CLI installation directory (e.g., C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\bin).
          • Click “OK” on all windows.
          • Close and reopen your Command Prompt or PowerShell window.
    • Installation Fails with Errors:

      • Cause: Various reasons, such as insufficient permissions, corrupted download, or conflicting software.
      • Solution:
        1. Ensure you are running the installer as an administrator.
        2. Try downloading the MSI installer again (it might have been corrupted).
        3. Temporarily disable any antivirus or security software that might be interfering with the installation.
        4. Check the Windows Event Viewer for more detailed error messages.
    • Proxy Issues:

      • Cause: You are behind a proxy server, and the Azure CLI is not configured to use it.
      • Solution:
        1. Set environment variables:
          set HTTP_PROXY=http://your_proxy_address:port
          set HTTPS_PROXY=http://your_proxy_address:port

          Replace your_proxy_address and port with your actual proxy server details.
        2. Use az config set (after installation):
          bash
          az config set core.http_proxy=http://your_proxy_address:port
          az config set core.https_proxy=http://your_proxy_address:port
    • Conflicting Installations:

      • Cause: You may have multiple versions of the Azure CLI installed, or another program is using the same command name (az).
      • Solution:
        1. Uninstall any previous versions of the Azure CLI.
        2. Check your PATH environment variable for any conflicting entries.
    • Antivirus Interference:

      • Cause: Your antivirus might see the installation or the CLI’s actions as suspicious.
      • Solution: Temporarily disable the antivirus during installation only. If the problem persists after installation, you may need to add an exception for the Azure CLI executable (az.exe) to your antivirus configuration.

(4) Installation on macOS

This section covers installing the Azure CLI on macOS, including troubleshooting.

  • Method 1: Homebrew (Recommended)

    Homebrew is a popular package manager for macOS, making it easy to install and manage software.

    • Installing Homebrew (if not already installed):
      bash
      /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

      Follow the on-screen instructions to complete the Homebrew installation. This script will guide you through adding Homebrew to your PATH.

    • Installing Azure CLI with Homebrew:
      bash
      brew update && brew install azure-cli

      • brew update: Updates Homebrew’s package list.
      • brew install azure-cli: Installs the Azure CLI.
    • Verifying Installation:
      bash
      az --version

    • Updating the Azure CLI on macOS:
      bash
      brew upgrade azure-cli

    • Uninstalling the Azure CLI on macOS:
      bash
      brew uninstall azure-cli

  • Method 2: Manual Installation (using curl)

    This method is useful if you don’t want to use Homebrew.

    • Downloading the Installation Script:
      bash
      curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash

      This downloads a script that will install to /usr/local/bin.

    • Adding Azure CLI to your PATH (if necessary):
      The installation script should automatically add the Azure CLI to your PATH. However, depending on your shell configuration (bash, zsh, etc.), you might need to do this manually.

      • Check your shell:
        bash
        echo $SHELL

        This will tell you if you’re using bash, zsh, or another shell.

      • Edit your shell configuration file:

        • Bash: Edit ~/.bash_profile or ~/.bashrc.
        • Zsh: Edit ~/.zshrc.
        • Add the following line to the file:
          bash
          export PATH="/usr/local/bin:$PATH"
      • Apply the changes:
        bash
        source ~/.bash_profile # For bash
        source ~/.zshrc # For zsh

        Or, simply open a new terminal window.

  • Troubleshooting macOS Installation

    • “az” Command Not Recognized:

      • Cause: The Azure CLI installation directory is not in your PATH.
      • Solution:
        1. Ensure you have followed the steps to add the Azure CLI to your PATH (see above).
        2. Close and reopen your terminal window.
        3. Verify that /usr/local/bin is in your PATH: echo $PATH
    • Installation Fails with Errors:

      • Cause: Various reasons, such as permission issues, network problems, or outdated Homebrew.
      • Solution:
        1. Make sure you have sudo privileges.
        2. Run brew update and brew doctor to check for Homebrew issues.
        3. Check your internet connection.
    • Permission Issues:

      • Cause: You may not have the necessary permissions to install software in the default location.
      • Solution: Use sudo with the installation command (e.g., sudo brew install azure-cli or curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash).
    • Proxy Issues:

      • Cause: You are behind a proxy server.
      • Solution:
        1. Set environment variables:
          bash
          export HTTP_PROXY=http://your_proxy_address:port
          export HTTPS_PROXY=http://your_proxy_address:port

          Replace your_proxy_address and port with your actual proxy server details.
        2. Use az config set (after installation): (Same as Windows instructions)
    • zsh vs. bash Compatibility:

      • Cause: macOS switched to zsh as the default shell in recent versions. Some older configuration files might not be compatible.
      • Solution:
        1. Make sure you are editing the correct shell configuration file (~/.zshrc for zsh, ~/.bash_profile or ~/.bashrc for bash).
        2. If you are using zsh, you can consider using a plugin manager like Oh My Zsh to manage your shell configuration.

(5) Installation on Linux

This section covers installing the Azure CLI on various Linux distributions.

  • General Linux Installation Principles

    • Using Package Managers: Most Linux distributions use package managers to install and manage software. The most common package managers are:

      • apt: Used by Debian and Ubuntu.
      • yum: Used by older versions of Red Hat, CentOS, and Fedora.
      • dnf: Used by newer versions of Fedora, CentOS 8+, and RHEL 8+.
      • zypper: Used by SUSE and openSUSE.
    • Understanding Repositories: Package managers get software from repositories (online sources of packages). To install the Azure CLI, you often need to add the Microsoft repository to your system’s list of repositories.

  • Debian/Ubuntu (using apt)

    • Adding the Microsoft Repository:

      1. Install the curl and apt-transport-https packages (if not already installed):
        bash
        sudo apt-get update && sudo apt-get install -y curl apt-transport-https
      2. Download and import the Microsoft signing key:
        “`bash
        curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg –dearmor | sudo tee /etc/apt/trusted.gpg.d/microsoft.gpg > /dev/null

        “`
        3. Add the Azure CLI repository:

        “`bash
        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

        “`

    • Installing the Azure CLI:
      bash
      sudo apt-get update && sudo apt-get install -y azure-cli

    • Verifying Installation:
      bash
      az --version

    • Updating and Uninstalling:

      • Update: sudo apt-get update && sudo apt-get upgrade -y azure-cli
      • Uninstall: sudo apt-get remove -y azure-cli
  • Red Hat/CentOS/Fedora (using yum/dnf)

    • Adding the Microsoft Repository:
      Import Microsoft GPG Key
      bash
      sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
    • RHEL/CentOS 7:
      “`bash
      sudo sh -c ‘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” > /etc/yum.repos.d/azure-cli.repo’

      ```
      
      • Fedora/CentOS 8+/RHEL 8+ (using dnf):

      “`bash
      sudo dnf install -y https://packages.microsoft.com/config/rhel/8/packages-microsoft-prod.rpm

      ``
      * **Installing the Azure CLI:**
      * **yum (older systems):**
      sudo yum install -y azure-cli* **dnf (newer systems):**sudo dnf install -y azure-cli`

    • Verifying Installation:
      bash
      az --version

    • Updating and Uninstalling:

      • Update (yum): sudo yum update -y azure-cli
      • Update (dnf): sudo dnf upgrade -y azure-cli
      • Uninstall (yum): sudo yum remove -y azure-cli
      • Uninstall (dnf): sudo dnf remove -y azure-cli
  • SUSE/openSUSE (using zypper)

    • Adding the Microsoft Repository

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

    *   Create the repo file.
    ```bash
    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/zypp/repos.d/azure-cli.repo'
    
    ```
    
    • Installing the Azure CLI:

      “`bash
      sudo zypper refresh
      sudo zypper install –from azure-

Leave a Comment

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

Scroll to Top