How to Install Azure CLI on Ubuntu 24.04 and 22.04

Last updated Friday, May 8, 2026 9:47 pm Joshua James 6 min read

Managing resource groups, storage accounts, and virtual machines is much easier when the same Azure workflow stays in your Ubuntu terminal. To install Azure CLI on Ubuntu Linux, you add Microsoft’s APT repository, install the azure-cli package, and sign in with either a browser session or a device code when you are working over SSH.

Ubuntu’s default repositories do not currently ship azure-cli on Ubuntu 24.04 LTS or 22.04 LTS, so Microsoft’s repository is the practical install path. The package name is azure-cli, but the installed command is az; readers often see the same tool described as Azure CLI, az CLI, or azcli.

Install Azure CLI on Ubuntu

Microsoft’s Azure CLI Linux install documentation describes the APT repository path for Ubuntu, and it keeps Azure CLI updates inside the package manager workflow most Ubuntu users already trust.

These steps support Ubuntu 24.04 LTS and 22.04 LTS with Microsoft’s native noble and jammy Azure CLI suites. Microsoft has not published a dedicated resolute suite for Ubuntu 26.04 LTS as of May 8, 2026, so the source-writing command stops before writing an unsupported 26.04 source file instead of pointing 26.04 at an older Ubuntu suite.

Update Ubuntu Before Installing Azure CLI

Refresh your package lists before you add Microsoft’s repository. If APT reports pending system upgrades, install them separately and return to the Azure CLI setup after the normal upgrade finishes.

sudo apt update

If your account does not have sudo access yet, set that up first with our guide on adding a new user to sudoers on Ubuntu.

Install Packages Azure CLI Needs

Install the packages needed for HTTPS downloads and GPG key handling.

sudo apt install -y ca-certificates curl gpg

Desktop Ubuntu installs usually already have these packages, but minimal images and cloud instances often do not.

Import the Azure CLI Microsoft Key

Import Microsoft’s signing key so APT can verify the Azure CLI packages before installation.

curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor --yes -o /usr/share/keyrings/azure-cli.gpg

This uses curl to download the ASCII-armored Microsoft key and gpg --dearmor to convert it into the binary keyring format APT expects.

Add the Azure CLI Repository

Ubuntu 24.04 uses the noble suite and Ubuntu 22.04 uses the jammy suite. This block detects the active codename, writes the source only for those native suites, and stops with a message on unsupported Ubuntu releases.

AZ_REPO="$(. /etc/os-release && printf '%s' "$VERSION_CODENAME")"

case "$AZ_REPO" in
  jammy|noble)
    printf '%s\n' \
      "Types: deb" \
      "URIs: https://packages.microsoft.com/repos/azure-cli/" \
      "Suites: ${AZ_REPO}" \
      "Components: main" \
      "Architectures: $(dpkg --print-architecture)" \
      "Signed-By: /usr/share/keyrings/azure-cli.gpg" \
    | sudo tee /etc/apt/sources.list.d/azure-cli.sources > /dev/null
    ;;
  *)
    printf 'Azure CLI does not currently provide a native Ubuntu suite for %s.\n' "$AZ_REPO" >&2
    false
    ;;
esac

The printf | sudo tee pattern writes a root-owned file without relying on a heredoc, which keeps quoting predictable in ordinary terminal sessions. If the command prints the unsupported-suite message, do not create a source file manually; use the 26.04 troubleshooting section instead.

cat /etc/apt/sources.list.d/azure-cli.sources

You should see the repository file APT will use for Azure CLI.

Types: deb
URIs: https://packages.microsoft.com/repos/azure-cli/
Suites: noble
Components: main
Architectures: amd64
Signed-By: /usr/share/keyrings/azure-cli.gpg

Verify the Azure CLI Repository on Ubuntu

Refresh APT so Ubuntu reads the new Azure CLI source and indexes the package metadata.

sudo apt update

If APT completes without repository errors, check the candidate version before you install the package.

apt-cache policy azure-cli

The output should show Microsoft’s Azure CLI repository as the candidate source.

azure-cli:
  Installed: (none)
  Candidate: 2.86.0-1~noble
  Version table:
     2.86.0-1~noble 500
        500 https://packages.microsoft.com/repos/azure-cli noble/main amd64 Packages

Ubuntu 24.04 shows the noble package stream, while Ubuntu 22.04 shows the matching jammy package suffix. The exact version changes as Microsoft publishes releases; the important check is that the candidate comes from packages.microsoft.com and carries your release suffix. If you want to compare the package with upstream release history, check Microsoft’s Azure CLI release notes or the Azure CLI GitHub repository.

Install Azure CLI with APT

Install the package once the repository and candidate version both look correct.

sudo apt install -y azure-cli

Verify Azure CLI Installation

Confirm that Azure CLI is installed and that the az command is ready to use.

az version --output json

You should see Azure CLI version information similar to the following.

{
  "azure-cli": "2.86.0",
  "azure-cli-core": "2.86.0",
  "azure-cli-telemetry": "1.1.0",
  "extensions": {}
}

Sign In and Use Azure CLI on Ubuntu

The package is installed at this point, but commands that query subscriptions or resources still need authentication. Desktop Ubuntu systems can open the browser-based flow directly, while remote SSH sessions usually work better with a device code.

Sign In to Azure CLI on Ubuntu Desktop

Use the standard login flow if this Ubuntu system has a browser session available.

az login

Azure CLI opens a browser session or prints a browser URL if one is not already available.

Sign In to Azure CLI on Headless Ubuntu Servers

Use the device-code flow when you are connected over SSH or managing a server without a local desktop session.

az login --use-device-code

The command prints a short-lived code and the https://login.microsoft.com/device URL, then waits while you finish sign-in in another browser. Do not publish or reuse the code itself because each code belongs to one login attempt.

List Available Azure Clouds with Azure CLI

This command works even before you authenticate, which makes it a safe first check that the CLI itself is functioning.

az cloud list --output table

You should see the supported Azure cloud environments.

IsActive    Name               Profile
----------  -----------------  ---------
True        AzureCloud         latest
False       AzureChinaCloud    latest
False       AzureUSGovernment  latest
False       AzureGermanCloud   latest
False       AzureBleuCloud     latest

Learn Azure CLI Basics on Ubuntu

Once Azure CLI is installed, the next step is learning how to discover commands before you make changes in your subscription. These checks are safe to run on any Ubuntu system because they focus on help output and session state instead of creating or modifying resources.

Browse Azure CLI Command Groups

Start with the top-level help screen to see the major Azure command groups and how the CLI is organized.

az --help

The command-group section of the help output should look similar to this.

Group
    az

Subgroups:
    account                 : Manage Azure subscription information.
    acr                     : Manage private registries with Azure Container Registries.
    ad                      : Manage Microsoft Entra ID (formerly known as Azure Active Directory,
                              Azure AD, AAD) entities needed for Azure role-based access control
                              (Azure RBAC) through Microsoft Graph API.
    advisor                 : Manage Azure Advisor.
    afd                     : Manage Azure Front Door Standard/Premium.
    aks                     : Azure Kubernetes Service.
    ams                     : Manage Azure Media Services resources.
    apim                    : Manage Azure API Management services.

Inspect Azure VM Commands Before Running Them

Use a command group’s help page before you run any resource action that could affect subscriptions, resource groups, or virtual machines.

az vm --help

This shows the subcommands available under the Azure VM group.

Group
    az vm : Manage Linux or Windows virtual machines.

Subgroups:
    application             : Manage applications for VM.
    availability-set        : Group resources into availability sets.
    boot-diagnostics        : Troubleshoot the startup of an Azure Virtual Machine.
    diagnostics             : Configure the Azure Virtual Machine diagnostics extension.
    disk                    : Manage the managed data disks attached to a VM.
    encryption              : Manage encryption of VM disks.
    extension               : Manage extensions on VMs.
    host                    : Manage Dedicated Hosts for Virtual Machines.
    identity                : Manage service identities of a VM.
    image                   : Information on available virtual machine images.

Check Azure CLI Authentication State

Use this command after sign-in to confirm which account and subscription Azure CLI is using. If you have not authenticated yet, Azure CLI tells you immediately.

az account show

Before sign-in, the command returns this error.

ERROR: Please run 'az login' to setup account.

After you authenticate, a practical next sequence is az account list --output table to review subscriptions, az group list --output table to inspect resource groups, and az vm list -d --output table to review virtual machines with their power state and public IP details.

Update Azure CLI on Ubuntu

Once Microsoft’s repository is configured, Azure CLI updates like any other APT-managed package.

Update Azure CLI with APT

Refresh the package lists, then upgrade only Azure CLI without pulling unrelated packages forward.

sudo apt update && sudo apt install --only-upgrade -y azure-cli

After the upgrade finishes, rerun az version --output json to confirm the newer version is active.

Troubleshoot Azure CLI on Ubuntu

The main Ubuntu-specific edge case right now is trying to install Azure CLI on Ubuntu 26.04 before Microsoft publishes a native repository suite for it.

Understand the Azure CLI 26.04 Repository 404

If you force the Azure CLI source file to use resolute on Ubuntu 26.04, apt update fails because Microsoft has not published that suite yet.

Err: https://packages.microsoft.com/repos/azure-cli resolute Release
  404  Not Found
Error: The repository 'https://packages.microsoft.com/repos/azure-cli resolute Release' does not have a Release file.

If you are not sure which Ubuntu release you are on, confirm it first with our guide to check Ubuntu version.

Although Microsoft’s upstream troubleshooting notes describe older-suite fallbacks for unsupported distributions, avoid that path on Ubuntu 26.04 because it mixes release suites. The clean answer is to wait for Microsoft’s native Ubuntu 26.04 packages. If you already added the unsupported source file, remove it so APT returns to a healthy state.

sudo rm -f /etc/apt/sources.list.d/azure-cli.sources
sudo rm -f /usr/share/keyrings/azure-cli.gpg
sudo apt update

Once Microsoft publishes a native resolute suite, use a current source file for that suite instead of reusing noble or jammy on Ubuntu 26.04.

Remove Azure CLI on Ubuntu

Removing Azure CLI cleanly means uninstalling the package, deleting the repository and key, and deciding whether to keep or delete the local account data under ~/.azure.

Remove the Azure CLI Package

Remove the package first.

sudo apt remove azure-cli

Preview the dependency cleanup before you remove anything extra.

sudo apt autoremove --dry-run

apt autoremove can list helper libraries and packages that Azure CLI pulled in automatically. Review that list before you confirm so you do not remove anything you decided to keep for other software.

If the preview lists only packages you are comfortable removing, run the cleanup interactively.

sudo apt autoremove

Verify that Ubuntu no longer considers Azure CLI installed.

dpkg-query -W -f='${db:Status-Abbrev} ${binary:Package}\n' azure-cli 2>/dev/null | grep '^ii' || echo removed
removed

Remove the Azure CLI Repository and Key

Delete the repository definition and the Azure CLI keyring if you do not plan to reinstall the tool.

sudo rm -f /etc/apt/sources.list.d/azure-cli.sources
sudo rm -f /usr/share/keyrings/azure-cli.gpg
sudo apt update

Confirm that the Azure CLI source file and keyring are gone.

test ! -e /etc/apt/sources.list.d/azure-cli.sources && test ! -e /usr/share/keyrings/azure-cli.gpg && echo removed
removed

Remove Azure CLI Account Data

Azure CLI stores local sign-in tokens, cloud profile data, command logs, and settings in ~/.azure.

The next command permanently deletes your local Azure CLI account data, including cached tokens, profile metadata, command logs, and output preferences. It does not delete subscriptions, resource groups, virtual machines, storage accounts, or any other resources in Azure itself.

rm -rf ~/.azure

Verify that the local Azure CLI data directory is gone.

test -d ~/.azure && echo present || echo absent
absent

Conclusion

On Ubuntu 24.04 or 22.04, Azure CLI is now installed and ready for browser-based or device-code sign-in, and the Microsoft APT repository gives you a clean update path through normal package management. If this system is remote, pair it with our guide to install SSH on Ubuntu, and keep the base system current with updating Ubuntu packages from the command line.

Follow LinuxCapable

Want more LinuxCapable guides in Google?

Add LinuxCapable as a preferred source so Google can show more of our fresh Linux tutorials in Top Stories and From your sources when relevant.

Add LinuxCapable as a preferred source on Google
Search LinuxCapable

Need another guide?

Search LinuxCapable for package installs, commands, troubleshooting, and follow-up guides related to what you just read.

Found this guide useful?

Support LinuxCapable to keep tutorials free and up to date.

Buy me a coffeeBuy me a coffee
Before commenting, please review our Comments Policy.
Formatting tips for your comment

You can use basic HTML to format your comment. Useful tags currently allowed in published comments:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<blockquote>quote</blockquote> quote block

Got a Question or Feedback?

We read and reply to every comment - let us know how we can help or improve this guide.

Let us know you are human: