How to Install Azure CLI on Ubuntu (24.04, 22.04)

Last updated Thursday, March 12, 2026 7:10 pm 9 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. That keeps the whole job inside one Ubuntu package-management workflow, from installation and sign-in through updates and clean removal.

Install Azure CLI on Ubuntu

Microsoft’s Azure CLI repository is the supported APT path for Ubuntu and 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. As of March 12, 2026, Microsoft has not published a dedicated resolute suite for Ubuntu 26.04 LTS, so this article does not document a 26.04 installation path yet. When Microsoft ships native 26.04 packages, the guide should be updated to add them directly instead of pointing Ubuntu 26.04 at an older release suite.

Update Ubuntu Before Installing Azure CLI

Refresh your package lists and install any pending updates before you add Microsoft’s repository.

sudo apt update && sudo apt upgrade

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 ca-certificates curl gpg -y

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 -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 and writes the matching Azure CLI repository file for the supported release you are on.

AZ_REPO="$(. /etc/os-release && printf '%s' "$VERSION_CODENAME")"
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

The printf | sudo tee pattern writes a root-owned file without relying on a heredoc, which makes the command easier to copy and paste from a browser or WordPress export.

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

The Microsoft repository should appear in the update output on supported releases.

Get:1 https://packages.microsoft.com/repos/azure-cli noble InRelease [3,564 B]
Get:2 https://packages.microsoft.com/repos/azure-cli noble/main amd64 Packages [2,072 B]
Fetched 5,636 B in 1s (9,063 B/s)
Reading package lists...

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.84.0-1~noble
  Version table:
     2.84.0-1~noble 500
        500 https://packages.microsoft.com/repos/azure-cli noble/main amd64 Packages
     2.83.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. 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 azure-cli -y

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.84.0",
  "azure-cli-core": "2.84.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 code and waits while you finish sign-in in another browser.

To sign in, use a web browser to open the page https://login.microsoft.com/device and enter the code PN72WRZ6C to authenticate.

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

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 first 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.

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.

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 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 point the Azure CLI source file at resolute on Ubuntu 26.04, apt update fails because Microsoft has not published that suite yet.

Ign:5 https://packages.microsoft.com/repos/azure-cli resolute InRelease
Err:6 https://packages.microsoft.com/repos/azure-cli resolute Release
  404  Not Found [IP: 13.107.246.32 443]
Reading package lists...
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.

At the moment, the clean answer is to wait for Microsoft’s native Ubuntu 26.04 packages instead of pointing 26.04 at an older Ubuntu suite. 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 apt update

Once Microsoft publishes a native resolute suite, this article can be updated to add Ubuntu 26.04 properly.

Hit:1 http://au.archive.ubuntu.com/ubuntu resolute InRelease
Hit:2 http://au.archive.ubuntu.com/ubuntu resolute-updates InRelease
Hit:3 http://au.archive.ubuntu.com/ubuntu resolute-backports InRelease
Hit:4 http://security.ubuntu.com/ubuntu resolute-security InRelease
Reading package lists...

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, then let APT clean up any dependencies that were installed only for Azure CLI.

sudo apt remove azure-cli
sudo apt autoremove

apt autoremove can list Python libraries and helper 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.

Verify that Ubuntu no longer considers Azure CLI installed.

dpkg -l azure-cli | 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 is gone.

ls /etc/apt/sources.list.d | grep -i azure-cli || 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

Azure CLI on Ubuntu FAQ

Is Azure CLI available in Ubuntu’s default repositories?

No. On Ubuntu 24.04 and 22.04, the azure-cli package is not in Ubuntu’s default repositories. Add Microsoft’s Azure CLI repository first, then install the azure-cli package with APT.

Does Azure CLI support Ubuntu 26.04 LTS yet?

Not yet. As of March 12, 2026 Microsoft has not published a dedicated resolute suite for Azure CLI, so this guide is intentionally limited to Ubuntu 24.04 LTS and 22.04 LTS until native 26.04 packages exist.

How do I sign in to Azure CLI on a headless Ubuntu server?

Use az login --use-device-code. Azure CLI prints a short code and the https://login.microsoft.com/device URL so you can complete sign-in in a browser on another machine, then return to the SSH session and keep working.

Does deleting ~/.azure remove my Azure resources?

No. Removing ~/.azure deletes only local Azure CLI data such as cached tokens, cloud profile metadata, command logs, and output settings. It does not delete subscriptions, resource groups, virtual machines, storage accounts, or any other resources in Azure.

Conclusion

Azure CLI is now installed on Ubuntu 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.

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 coffee Buy 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:

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

Leave a Comment

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

Let us know you are human: