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 Terminal on macOS. This will open up a bash shell that you can use to access the command-line on macOS.

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

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

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

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

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.

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

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

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!

Posted by Chris Pietschmann

Chris is a Microsoft MVP and has 15+ years of experience building enterprise systems both in the cloud and on-premises. He is also a Microsoft Certified (MCSD) Azure Solutions Architect. He has a passion for technology and sharing what he learns with others to help enable them to learn faster and be more productive.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s