
In this Azure tutorial, we will discuss Install Azure CLI On Windows, Along with this, we will also discuss a few other topics like below
- What is Azure CLI?
- Key Features of Azure CLI
- Update Azure CLI Version
- Azure CLI login
- Install Azure CLI Mac.
- Install Azure CLI Linux
- Install Azure CLI ubuntu
- Azure CLI Version
- Azure CLI vs PowerShell.
- Unable to locate package azure-cli
Table of Contents
- Install Azure CLI On Windows
- What is Azure CLI?
- Key Features of Azure CLI
- Azure CLI windows
- Update Azure CLI Version
- Run the Azure CLI
- Uninstall Azure CLI
- Azure CLI login
- Install Azure CLI Mac
- Install Azure CLI Linux
- Install Azure CLI ubuntu
- Azure CLI Version
- Azure CLI vs PowerShell
- Unable to locate package azure-CLI [Soluton]
- Wrapping Up
Install Azure CLI On Windows
Well, Let’s discuss an interesting topic i.e Install Azure CLI On Windows. But before starting the installation what if we will discuss What is Azure CLI ?.
- Azure SQL Database Vs. SQL Server
- Azure Cognitive Services Text Analytics Python SDK
- How To Create Azure Cognitive Service Account PowerShell
- az account show
What is Azure CLI?
The Azure CLI is termed the Azure command-line interface. This is nothing but a set of commands that actually helps us to create and manage all our Azure Resources. That is designed in such a way that it gets you working quickly with Azure.
Key Features of Azure CLI
Below are a few key features of the Azure CLI
- Provides the command-line interface to manage different Azure solutions.
- It supports different operating systems like Windows, Linux, and macOS.
- It provides you the facility to work with different clouds.
- Azure CLI can fit with the long-running operations.
- Provides the configurations for the logging, data collection, etc.
Azure CLI windows
Assuming we have a bit of idea on Azure CLI, let’s start with the main topic i.e Installing Azure CLI On Windows.
You can install the Azure CLI On Windows in two ways.
- Use the Microsoft Installer (MSI)
You can download the Azure CLI executable file from the below path and install that on your machine
https://aka.ms/installazurecliwindows
Once you will access the above URL, it will prompt you to save the Azure CLI executable file in your local path. It will take a few minutes to download the executable file. Once you download the executable file, You can double click on the executable file to install the Azure CLI setup.

Now, as the next step, select the “I accept the terms in the License Agreement” option and then click on the Install button to start the installation process.

- Microsoft Installer (MSI) with PowerShell command (install azure CLI on windows PowerShell)
Another way is to install the Azure CLI using the PowerShell cmdlet. you can use the below PowerShell cmdlet to install the Azure CLI.
Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'; rm .\AzureCLI.msi
Note: One important thing to note down here is. If you have already installed the Azure CLI on your machine and you are trying to run the PowerShell cmdlet on top of that then it will update the Azure CLI to the latest version.
After executing the script, you might get the error ” Invoke-WebRequest: The operation has timed out”. The complete error message is as below.
Invoke-WebRequest : The operation has timed out.
At line:1 char:1
- Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile …
~~~~~~~~~~~~~~~~~- CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebReq
uest) [Invoke-WebRequest], WebException - FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Comm
ands.InvokeWebRequestCommand
- CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebReq
But if you will try executing the same script once or twice, it will definitely work for you and Azure CLI will install successfully for you without any issue. This is how we can install Azure CLI On Windows.
Update Azure CLI Version
Suppose you have already the Azure CLI installed on your machine and you want to upgrade to the latest version of Azure CLI, then you can execute the below PowerShell cmdlet to upgrade the Azure CLI version to the latest one.
az upgrade
Run the Azure CLI
Ohk, till now we have done with the installation of Azure CLI and then we have discussed how to update the Azure CLI version. Now Let’s discuss How to run the Azure CLI. You can use the Windows command prompt or PowerShell to execute the commands. Follow the below steps to run the Azure CLI.
Step-1: Run the below az command to login
az login
Once you will execute the above PowerShell cmdlet, it will prompt you to sign in with the Browser.
Step-2: Enter your account credentials to log in.
Uninstall Azure CLI
If By chance, you have decided to uninstall the Azure CLI, then you can uninstall the Azure CLI using the below steps.
- If you are using Windows 10, To uninstall the Azure CLI, Navigate to Start > Settings > Apps.
- If you are using Windows 7 or Windows 8, To uninstall the Azure CLI, Navigate to Start > Control Panel > Programs > Uninstall a program.
Azure CLI login
While working with the Azure CLI, you can sign in with the help of the Browser with the az login command as discussed above. you can use the below PowerShell cmdlet
az login
Once you will execute the above Azure CLI command, you need to enter your Account credentials to log in. But with the command itself, you can also provide your credentials to log in to the Azure CLI. you can use the az login command along with the username and password like below.
az login -u <username> -p <password>
It is obvious that you don’t want to display the password openly. So avoid this scenario, you can use the PowerShell cmdlet like below
$Cred = Get-Credential -UserName <Enter your username>
az login -u $Cred.UserName -p $Cred.GetNetworkCredential().Password
Once you will execute the above command, you will get something like below

Sign in Azure CLI with a service principal
You can also sign in with the service principal. To give you a glance at the service principal. Service Principals are the accounts that are not tied to any specific user that can have permissions on them assigned via predefined roles. Using the service principal to log in is one of the most secure ways.
There are a few things that you need to sign in with a service principal
- The URL or the name that is actually associated with the service principal.
- You need the X509 certificate or the service principal password.
- You need the tenant that is associated with the service principal.
The PowerShell cmdlet will be like below
az login --service-principal -u <app-url> -p <password-or-cert> --tenant <tenant>
If you don’t want to display the details to the outer world, you can use the PowerShell cmdlet below
$Cred = Get-Credential -UserName <app-url>
az login --service-principal -u $Cred.UserName -p $Cred.GetNetworkCredential().Password --tenant <tenant>
Sign in with a different tenant
You can also sign in with a different tenant. You need to specify the tenant name with the –tenant parameter.
az login --tenant <tenant>
Sign in with a managed identity
One more way to log in is to sign in with a managed identity. Below is the cmdlet that you can use to sign in with a managed identity.
az login --identity
So, this is all about Azure CLI login.
Install Azure CLI Mac
Well, above, we have discussed How to install Azure CLI in Windows?. Now, let’s discuss How to Install Azure CLI on macOS. Homebrew is an excellent way to manage the Azure CLI installation on the macOS. So the first step is to install the Homebrew if you don’t have Homebrew installed on your machine.
Installing Homebrew
You can install the Homebrew on your machine by following the instruction on the official website. As per the instruction mentioned on the website, you need to open the terminal and run the below cmdlet
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Once you will install the Homebrew in your machine. Then with the help of the Homebrew, we can easily install the Azure CLI on the macOS.
Installing Azure CLI for Mac
Now we are ready to install the Azure CLI on the macOS. Now you can use the below cmdlet to install the Azure CLI on the macOS.
brew update && brew install azure-cli
To check the installation has been completed properly, you can use the below cmdlet
az
The next step is to try to login into your Azure account using the below cmdlet
az login
Once you will execute the above cmdlet, it will prompt you to enter your Azure credential details to sign in.
Install Azure CLI Linux
Well, it’s quite easy to install the Azure CLI in Linux. There are multiple ways to install Azure CLI on Linux But there is a very quick way for installing Azure CLI on a Linux machine by using a single command to install Azure CLI on your Linux machine.
curl -L https://aka.ms/InstallAzureCli | bash
Another important point is, Once you are done with the installation, don’t forget to restart your shell to view the changes.
Install Azure CLI ubuntu
If you are specific to Ubuntu and you want to install the Azure CLI on ubuntu then there are two ways for the installation but the quickest and simple way is to use the below single command for the installation of Azure CLI on ubuntu.
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
Note: Better to restart once after the installation to view the changes.
Azure CLI Version
You can check out the current version of your Azure CLI installed on your machine using the below command.
az --version
Once, you will execute the above command, you will get the output below.

Azure CLI vs PowerShell
Before discussing the Azure CLI vs PowerShell. We need to know a little background on both Azure CLI and Azure PowerShell. The main point here is both Azure CLI and Azure PowerShell are available in the Azure cloud. You can also use both of them remotely from your local machine.
To locate the Azure Cloud Shell, you can log in to the Azure Portal and click on the Cloud Shell icon as highlighted below which is present just before the Directory + Subscription button.

Once you will click on the Cloud Shell, it will give you the option, to either you can use Bash or PowerShell based on your requirement.
Azure CLI is a command-line tool that connects to Azure and executes different administrative commands on the different Azure resources. you can use the same commands for whatever platform you want to use like Windows, Linux or Mac, etc.
There are two versions of Azure CLI that are present now. The first one is the Azure CLI version 1.0 which is written with Node.js and the other Azure CLI version is 2.0 which is actually written in Python to support better cross-platform capabilities. Azure CLI can also be used with Groovy, Python, Ruby, or any other scripting language.
Whereas PowerShell is a great choice for the Azure Functions and Azure Automation Runbooks and you can’t use the Azure CLI here.
PowerShell has very excellent multithreaded workload support. PowerShell is very suitable for any of the quick script requirements.
Microsoft keeps on revising the Azure PowerShell modules. Now we have the az PowerShell module to perform many activities to manage the Azure resources.
Unable to locate package azure-CLI [Soluton]
There might be a chance that you will get an error “Unable to locate package azure-cli” . I have fixed the same issue by running the below cmdlet
sudo apt-get update && sudo apt-get upgrade
You may also like following the below articles
- What is the azure active directory and how Azure AD works?
- The term ‘get-azuresubscription’ is not recognized
- How To Convert Text To Speech With Azure Cognitive Services
- CS1061 C# ‘HttpRequest’ does not contain a definition for ‘Content’ and no accessible extension method ‘Content’ accepting a first argument of type ‘HttpRequest’ could be found
- How to Create And Consume Azure Function From ASP.NET Core
Wrapping Up
In this article, we have discussed Install Azure CLI On Windows. Along with this, we have also discussed What is Azure CLI ?, Key Features of Azure CLI, Update Azure CLI Version, Azure CLI login. Finally, we have discussed Install Azure CLI Mac, Install Azure CLI Linux, Install Azure CLI ubuntu, Azure CLI vs PowerShell, and Unable to locate package azure-cli. I hope, you have enjoyed this article !!!