How to install Azure CLI to Ubuntu WSL

Given my background in pentesting AD environments, I chose to work with Azure as my first cloud service provider.

Here's a part of my documentation for setting up Azure CLI in my WSL environment, so I can better interact with the Azure Cloud platform.

Prerequisites

Please ensure that you have the prerequisites installed before installing the Azure CLI tool. This is for WSL Ubuntu setup. If you are operating on a Mac or Linux platform, your configuration may differ slightly.

Installation

  • Make sure that you do not have a previous installation of the Azure CLI tool. It is possible to install it from Ubuntu's universe repository. It will be better to get the Azure CLI tool from Microsoft directly.

  •   sudo apt purge azure-cli -y
    

There are two options to install the Azure CLI, one is through an installation script that installs the command in one step. The other is to manually set it up. For our purposes, we will use the one-liner command.

💡
Remember to check what the script does before running it. It is also advisable to refrain from directly copying commands from the browser to your terminal.
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash

If you wish to inspect the contents of the script yourself before executing, download the script first using curl and inspect it in your favorite text editor.

It's that easy. Now, we have the Azure CLI command accessible through the az command.

Azure CLI version number as of time of writing

Reference/s:

Please refer to the official Microsoft documentation for more up-to-date information:

Did you find this article valuable?

Support Daryl Galvez by becoming a sponsor. Any amount is appreciated!