How to Install Azure CLI on Windows (one-liner)
There are many ways you can manage Azure, for example, by using the Azure PowerShell, Cloud Shell, or many other tools. One of them is the Azure CLI, which is a command-line tool providing a management experience for Azure resources. In this blog post, I will show you how you can download, install, and update the Azure CLI on Windows with a simple PowerShell one-liner.
First, if you want to install the CLI, on Windows, Linux or other platforms, we have some excellent documentation on this on Microsoft Docs.
- Install on Windows
- Install on macOS
- Install on Linux or Windows Subsystem for Linux (WSL)
Install Azure CLI on Windows using a PowerShell One-liner
Instead of downloading the MSI file manually and install it on your Windows 10 machine, you can run the following PowerShell one-liner to install the Azure CLI. Start PowerShell as administrator and run the following command:
Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'
This will download and install the latest version of the Azure CLI for Windows. If you already have a version installed, it will update the existing version. Reopen PowerShell or the command prompt to start using it, and just type:
If you are running behind a proxy, make sure you configure your proxy settings.
Run Azure CLI on Windows using a Docker Container
If you have Docker installed, you can also run the CLI in an isolated environment using the mcr.microsoft.com/azure-cli container image and run the following command:
docker run -it mcr.microsoft.com/azure-cli
You can also use the container image as a base for your custom container image. Little fun fact, the container image is based on Linux, and with Linux containers on Windows, it runs great on Windows 10. You can find more information about running the CLI in a Docker container, on Microsoft Docs.
After the CLI is installed, you can also configure some default settings.
One of the settings which I really like to change is the default output from JSON to table. However, you can configure it the way you like it.
To manage your Azure resources you now need to log in using the login command.
After the login, you will run the commands in the context of the specific user, and start working with your Azure resources.
Azure PowerShell vs. Azure CLI
I often get asked by customers, which one should they use. The short answer is: it depends. I am a long-time PowerShell user, so PowerShell is more natural to me when it comes to scripting. But if someone is using different CLIs in the past, he might prefer the CLI experience. I personally love that PowerShell gives me objects and especially in scripts, this makes things much easier for me. However, when it commands to do something in a one-liner quickly, the Azure CLI experience often works better for me. So it really depends on what you prefer, Microsoft gives you a choice to use whatever works best for you. Yes, not all services are indeed available in both of them. Especially when the service is in preview, it can happen that you only have one of them available. However, the teams are working hard to bring services to both experiences.
I hope this helps you installing the Azure CLI on Windows if you have any questions feel free to leave a comment.