fbpx
Install Azure CLI on macOS 1

The Azure CLI is the cross-platform, command-line tool for managing and automating cloud resources in Microsoft Azure. The tool is supported across macOS, Linux, Windows, and more newly usable from within a web browser in the Azure Portal. While you can run it in the browser now, there are certainly benefit from being able to run the Azure CLI from your local machine. One of these benefits is to easily execute bash scripts locally to perform automation and other tasks. This article will guide you through the step-by-step process of installing the Azure CLI 2.0 on macOS.

Install Azure CLI 2.0 on macOS

Here are the fairly simple steps you can run to install the Azure CLI 2.0 on macOS:

Step 1: Run Terminalon macOS. This will open up a bashshell that you can use to access the command-line on macOS.

Install Azure CLI on macOS 2

Step 2: Within the Terminal, run the following command to install Azure CLI 2.0 with a single command:

curl -L https://aka.ms/InstallAzureCli | bash

Step 3: When prompted with “In what directory would you like to place the install?” you can just hit Return on your keyboard (aka leave it blank) and it’ll install it within “/Users/{username}/lib/azure-cli”.

Install Azure CLI on macOS 3

Step 4: When prompted with “In what directory would you like to place the ‘az’ executable?” you can just hit Return on your keyboard (aka leave it blank) and it’ll install it within “/Users/{username}/bin“.

Install Azure CLI on macOS 4

Step 5: Just sit back and relax while it gets busy installing…

Install Azure CLI on macOS 5

Step 6: When prompted with “Modify profile to update your $PATH and enable shell/tab completion now?” you can type ‘Y‘ and hit Return.

Install Azure CLI on macOS 6

Step 7: If prompted with “Could not automatically find a suitable file to use. Create /Users/{username}/.bash_profile now?” you can typeY‘ and hit Return.

Install Azure CLI on macOS 7

Step 8: You have now successfully installed the Azure CLI 2.0 on macOS!!

Install Azure CLI on macOS 8

Next Steps

Error using ‘az’ command?: If you get a “command not found” error when trying to run Azure CLI 2. commands in the bash shell on macOS after you just installed it, you may need to restart your shell. To do this you can run the following command:

exec -l $SHELL


Running ‘az’ commands:
You can just type ‘az‘ to get started running Azure CLI 2.0 commands in the bash shell. If you need some help, with commands you can run the following ‘az‘ command to get some help information:

az -h
Install Azure CLI on macOS 1

If you want some additional help with how to use the Azure CLI 2.0 commands, here are a few links you can reference:

Happy scripting!

Microsoft MVP

Chris Pietschmann is a Microsoft MVP, HashiCorp Ambassador, and Microsoft Certified Trainer (MCT) with 20+ years of experience designing and building Cloud & Enterprise systems. He has worked with companies of all sizes from startups to large enterprises. He has a passion for technology and sharing what he learns with others to help enable them to learn faster and be more productive.
HashiCorp Ambassador Microsoft Certified Trainer (MCT) Microsoft Certified: Azure Solutions Architect

Discover more from Build5Nines

Subscribe now to keep reading and get access to the full archive.

Continue reading