LinuxCommandLibrary

az-upgrade

Update the Azure CLI to the latest version

TLDR

Upgrade Azure CLI

$ az upgrade
copy

Upgrade Azure CLI and Extensions
$ az upgrade --all
copy

Upgrade Azure CLI and Extensions without prompting for confirmation
$ az upgrade --all [[-y|--yes]]
copy

SYNOPSIS

az upgrade [--yes | --no-prompt] [--debug] [--verbose] [--output {json,jsonc,none,table,tsv,yaml,yamlc}] [--query <JMESPath>] [--subscription <ID_or_name>] [--only-show-errors]

PARAMETERS

--yes, -y
    Do not prompt for confirmation. Automatically confirm the upgrade operation, proceeding with the update without user interaction.

--no-prompt
    Alias for --yes. Specifies to not prompt for confirmation and proceed with the upgrade automatically.

--debug
    Increase logging verbosity to show all debug logs. Useful for troubleshooting issues during the upgrade process.

--verbose
    Increase logging verbosity to show more information. Provides additional details about the upgrade steps.

--output {json,jsonc,none,table,tsv,yaml,yamlc}, -o {json,jsonc,none,table,tsv,yaml,yamlc}
    Output format. Specifies the format in which the command's results are presented (e.g., JSON, table). While less critical for az upgrade itself, it's a standard Azure CLI global argument.

--query <JMESPath>
    JMESPath query string. Allows for filtering and formatting the output based on a specified query. Another standard global argument for Azure CLI commands.

--subscription <ID_or_name>
    Name or ID of subscription. Specifies the active Azure subscription for the command. Although az upgrade itself doesn't directly interact with Azure resources, this is a standard global argument for context.

--only-show-errors
    Only show errors, suppressing warnings. Reduces output verbosity by only displaying critical error messages.

DESCRIPTION

The az upgrade command is an integral part of the Azure CLI (az) toolset, specifically designed to facilitate the self-update of the CLI itself to its newest available version. It provides a streamlined and user-friendly method for maintaining your Azure CLI installation. The command intelligently checks for a newer stable release of the Azure CLI on Microsoft's package repositories, downloads the necessary components, and then upgrades the existing installation by leveraging pip internally.
This command significantly simplifies the ongoing maintenance of the Azure CLI, ensuring users can effortlessly keep their command-line interface up-to-date with the latest features, critical bug fixes, and essential security improvements. It eliminates the need for manual intervention using underlying package managers like pip or system-level tools for updates. While primarily designed for pip-based installations, it may require elevated privileges (e.g., sudo on Linux/macOS or Administrator on Windows) depending on how the Azure CLI was originally installed on your system.

CAVEATS

Caveats and Limitations:
• Internet Connectivity: Requires an active internet connection to download the latest Azure CLI packages from Microsoft's repositories.
• Permissions: Depending on the initial installation method, running az upgrade may require elevated privileges (e.g., sudo on Linux/macOS, or Administrator on Windows). Failure to provide sufficient permissions will result in an error.
• Installation Method Specifics: This command is primarily effective for Azure CLI installations managed by pip or via the official Microsoft installer scripts. If the Azure CLI was installed via a system package manager (apt on Debian/Ubuntu, yum/dnf on RHEL/CentOS/Fedora), it is generally recommended to use the OS-specific update command instead (e.g., sudo apt update && sudo apt upgrade azure-cli). Using az upgrade on system package managed installations may lead to conflicts, an inconsistent state, or an incomplete upgrade.
• Dependency Management: While az upgrade attempts to manage its Python dependencies, issues can arise in complex Python environments, when using virtual environments, or if the underlying pip installation is corrupted.
• Beta/Preview Versions: By default, az upgrade targets the latest stable release of the Azure CLI. To install preview or beta versions, specific pip commands or alternative installation methods might be necessary.

UNDERLYING MECHANISM

The az upgrade command internally utilizes the pip package installer, the standard package management system used to install and manage software packages written in Python. When az upgrade is executed, it essentially translates to running commands similar to pip install --upgrade azure-cli and potentially performing similar upgrade operations for any installed Azure CLI extensions. This means that factors affecting pip (e.g., network proxy settings, Python environment issues, permissions) can also directly impact the success and behavior of az upgrade.

INSTALLATION TYPE CONSIDERATIONS

The necessity and optimal usage of az upgrade are highly dependent on how the Azure CLI was originally installed. If the CLI was installed via the official Microsoft installer script (recommended for most users) or directly via pip, then az upgrade is the correct and recommended method for updating. However, if the Azure CLI was installed through a Linux distribution's native package manager (such as apt, yum, or dnf), it is generally best practice to use that system's package upgrade commands (e.g., sudo apt upgrade azure-cli) rather than az upgrade, to maintain system package consistency and avoid potential conflicts.

HISTORY

The az upgrade command was introduced as a significant quality-of-life feature within the Azure CLI to streamline and simplify the process of keeping the tool updated. In earlier versions of the Azure CLI, users were required to manually run pip install --upgrade azure-cli (for pip installations) or rely solely on system package managers for updates. This command encapsulates and automates that underlying mechanism, making the update process more user-friendly, less error-prone, and consistent across different environments. Its development reflects a broader trend in modern command-line tools to provide robust self-updating capabilities, thereby reducing manual maintenance overhead and ensuring users always have access to the latest features and security patches.

SEE ALSO

az(1), pip(1), apt(8), yum(8), dnf(8)

Copied to clipboard