Install and Run Azure CLI on?Mac
Photo by Safar Safarov on Unsplash

Install and Run Azure CLI on?Mac


If you, like me, are new to Mac and don’t want to use only Azure Portal to manage your Azure resources, come with me on this article to install the Azure CLI on your Mac.

Disclaimer

I am new to Mac. I’m a Microsoft user since MS-DOS 6.0 and Windows 3.1, so you do the math, and you know how long I’m on the road.

But recently, I decided to jump in and acquired a MacBook Pro — Black Friday helped with that. And the adaptation is being more comfortable than I thought.

Prologue

On a DevOpsDC meetup, I mentioned to a friend that I was setting up my development environment on Mac and was learning everything from scratch. She just replied:

Oh, that’s easy, just install Homebrew and you’re good to go!

I honestly didn’t understand. And this time was not an English problem!

Azure CLI

What is not new to me is working on Azure. And the Azure portal is a great tool, friendly, and easy to use. But we need to agree that a GUI is suitable for particular tasks, but if you need successive commands running or create multiple resources, relying on the portal might take a lot of time.

For these situations, you can count on the command line interface — or CLI — where you can create the set of commands and put it to run while you take care of other tasks. Scripting comes very hand with repetitive tasks or executing sequential commands.

Obviously, when typing “az” or “az login”, the terminal doesn’t recognize the command

No alt text provided for this image

So, my first google search was “Azure CLI Mac”. The first result got me to Azure documentation page with the installation instructions:

Homebrew is the easiest way to manage your CLI install. It provides convenient ways to install, update, and uninstall. If you don’t have homebrew available on your system, install homebrew before continuing.

Oh, I got it now, Homebrew. Why didn’t she mentioned before that it is a package manager, just like NuGet or NPM. Everything seems so obvious now!

Installing Homebrew

Following the instructions on the homebrew page, open the terminal and run the following command:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

On the confirmation message, just hit RETURN (The same as ENTER, on Windows!). It will request your password to continue. Type and hit RETURN again.

No alt text provided for this image

Installation successful message means that… well, you know what it means!

No alt text provided for this image

Installing Azure CLI for Mac

Back to installation instructions on Microsoft website, get the following code to download the Azure CLI package and install it:

brew update && brew install azure-cli
No alt text provided for this image

After installing the package, type “az” and hit RETURN to confirm it is working.

az

You should see a message like this:

No alt text provided for this image

Now try to login into your Azure account:

az login
No alt text provided for this image

When you hit RETURN, a web browser will open with an authentication window. Follow the authentication as you would using the Microsoft account you regularly use to access the Azure portal.

No alt text provided for this image

After completing your login, you will be redirected back to the terminal with the success login message and the information about your subscription:

No alt text provided for this image

Go ahead and try commands using the CLI. For example, list the virtual machine resources from a specific resource group with the following command:

az resource list --resource-group "rg-name" --resource-type microsoft.compute/virtualmachines
No alt text provided for this image

To close the session, just execute the logout command:

az logout

Note that when you try to list the resource again, the system shows a message that you must run az login to start a session.

No alt text provided for this image

Azure CLI Reference

Now that you have the CLI installed on your Mac visit Microsoft’s reference guide with all the available commands.


Don’t forget to comment, react, and check the other articles of DevOps, Cloud & IT Career Publication!


要查看或添加评论,请登录

Marcello Marrocos的更多文章

  • Azure DevOps or GitHub?

    Azure DevOps or GitHub?

    In 2018 Microsoft acquired GitHub. But what about Azure DevOps? Microsoft acquired GitHub in 2018 for 7.

  • 4 Azure Services to Improve Performance of Applications

    4 Azure Services to Improve Performance of Applications

    Developing software solutions has evolved in the last years, and with the introduction of cloud technologies and…

  • 7 Must-Read DevOps?Books

    7 Must-Read DevOps?Books

    In this article, I will share seven books about DevOps that can be considered a must-read not only by DevOps Engineers,…

  • An Overview of Azure Integration Services

    An Overview of Azure Integration Services

    Azure Integration Services is a Microsoft cloud offering of services for mission-critical integrations. It provides a…

  • Create Environment with Azure Deployment Slots

    Create Environment with Azure Deployment Slots

    When deploying your application using a serverless solution, for example, Azure Functions or Azure App Service, you can…

  • Microsoft Azure DevOps? Start Here!

    Microsoft Azure DevOps? Start Here!

    Are you excited to start exploring Azure DevOps? Or are you studying for Microsoft Azure DevOps AZ-400 certification?…

  • How to Grow in IT Career Improving These Four Pillars

    How to Grow in IT Career Improving These Four Pillars

    The IT area is challenging and pushes the professionals to be continually updating their skills. But nowadays, not only…

  • Microsoft Retires Technology-Based Certifications

    Microsoft Retires Technology-Based Certifications

    Microsft is killing its certifications MCSA, MCSD, and MCSE. Yes, those technical-base certifications are being retired.

    2 条评论
  • Cloud Computing Is Important and Not Optional Anymore

    Cloud Computing Is Important and Not Optional Anymore

    The fourth industrial revolution is already here. And to go along with this revolution, cloud computing is important…

  • Understanding Cloud Models for Adoption Strategy

    Understanding Cloud Models for Adoption Strategy

    When moving your applications to Cloud is not only a matter of selecting the provider that most fit your needs, but…

社区洞察

其他会员也浏览了