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
-
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
-
Prerequisites and System Requirements
- Supported Operating Systems
- Hardware Requirements (Minimal)
- Network Connectivity
- User Permissions
- Required Software (Dependencies)
- Checking Existing Installations
-
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
- Method 1: MSI Installer (Recommended)
-
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
- Method 1: Homebrew (Recommended)
-
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
- General Linux Installation Principles
-
Installation in Azure Cloud Shell
- Accessing Azure Cloud Shell.
- Azure CLI is pre-installed.
- Cloud Shell environment details.
-
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
-
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
)
- Interactive Login (
- 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
)
- JSON Output (
- 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
- Logging In to Azure
-
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
)
- Creating a Resource Group (
-
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)
- Azure CLI Extensions
-
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
- General Troubleshooting Steps
-
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
-
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 westusaz
: 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.
- General Help:
(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
, orzypper
package managers (with appropriate repositories configured) - Distributions supporting manual installation (using
curl
)
- Windows:
-
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
orwget
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 --versionIf 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:
- Go to the official Azure CLI documentation page: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-windows
- 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)
- Double-click the downloaded MSI file. (e.g.,
AzureCLI.msi
) - Welcome Screen: Click “Next”.
- License Agreement: Read the license agreement and select “I accept the terms in the License Agreement”. Click “Next”.
- Destination Folder: Choose the installation directory (the default is usually
C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2
). Click “Next”. - Ready to Install: Click “Install”.
- User Account Control (UAC): If prompted by UAC, click “Yes” to allow the installation to proceed.
- Installation Progress: Wait for the installation to complete.
- Completed: Click “Finish”.
- Double-click the downloaded MSI file. (e.g.,
-
Verifying Installation:
- Open a new Command Prompt or PowerShell window (closing and reopening is important to ensure the PATH environment variable is updated).
- Type
az --version
and press Enter. - 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:
- Open “Control Panel”.
- Go to “Programs and Features” (or “Add or Remove Programs”).
- Find “Microsoft Azure CLI” in the list.
- Select it and click “Uninstall”.
- 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
- Update:
-
-
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:
- Close and reopen your Command Prompt or PowerShell window. This is the most common fix.
- 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:
- Ensure you are running the installer as an administrator.
- Try downloading the MSI installer again (it might have been corrupted).
- Temporarily disable any antivirus or security software that might be interfering with the installation.
- 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:
- Set environment variables:
set HTTP_PROXY=http://your_proxy_address:port
set HTTPS_PROXY=http://your_proxy_address:port
Replaceyour_proxy_address
andport
with your actual proxy server details. - 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
- Set environment variables:
-
Conflicting Installations:
- Cause: You may have multiple versions of the Azure CLI installed, or another program is using the same command name (
az
). - Solution:
- Uninstall any previous versions of the Azure CLI.
- Check your PATH environment variable for any conflicting entries.
- Cause: You may have multiple versions of the Azure CLI installed, or another program is using the same command name (
-
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-clibrew 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"
- Bash: Edit
-
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:
- Ensure you have followed the steps to add the Azure CLI to your PATH (see above).
- Close and reopen your terminal window.
- 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:
- Make sure you have
sudo
privileges. - Run
brew update
andbrew doctor
to check for Homebrew issues. - Check your internet connection.
- Make sure you have
-
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
orcurl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
).
-
Proxy Issues:
- Cause: You are behind a proxy server.
- Solution:
- Set environment variables:
bash
export HTTP_PROXY=http://your_proxy_address:port
export HTTPS_PROXY=http://your_proxy_address:port
Replaceyour_proxy_address
andport
with your actual proxy server details. - Use
az config set
(after installation): (Same as Windows instructions)
- Set environment variables:
-
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:
- Make sure you are editing the correct shell configuration file (
~/.zshrc
for zsh,~/.bash_profile
or~/.bashrc
for bash). - If you are using zsh, you can consider using a plugin manager like Oh My Zsh to manage your shell configuration.
- Make sure you are editing the correct shell configuration file (
-
(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:
- Install the
curl
andapt-transport-https
packages (if not already installed):
bash
sudo apt-get update && sudo apt-get install -y curl apt-transport-https -
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“`
- Install the
-
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
- Update:
-
-
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``
sudo yum install -y azure-cli
* **Installing the Azure CLI:**
* **yum (older systems):*** **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
- Update (yum):
- Adding the Microsoft Repository:
-
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-