If, like me you’re a bit of an Apple Fan Boy and prefer to use a Mac / MacBook for your daily machine you’ll want to make sure you get the Azure CLI installed. The CLI is a command-line tool allowing you to manage your Azure resources from code built upon Python.
So why CLI and not PowerShell? There’s no right or wrong answer to this, REST, PS and CLI, depending on what the requirements are, use the tools you’re confirmable with and the right tool, for the right job. CLI is generally more cross-platform capable although with the introduction of the ‘new Azure PowerShell Az module’ which is again a cross-platform (thanks to Az using the .NET Standard library, which means it runs on PowerShell 5.x and PowerShell 6.x. Since PowerShell 6.x can run on Linux, macOS, and Windows, Azure PowerShell).
Enough about which one to use – the choice is yours – for now we’ll look at installing the CLI in MacOS.
To make things a little simpler we’ll be taking advantage of ‘Brew’ (a MacOS package manager) . If you don’t have Brew installed then you an find an installation guide here (https://docs.brew.sh/Installation.html)
- Update Brew – “update brew” – if you get an error then make sure you have brew correctly installed.
- “brew install azure-cli“
You can check that brew has installed the CLI package correctly by running the command ‘az login’. This will use the Microsoft devices login service by opening your default browser and adding you to enter the displayed code.
The CLI team at Microsoft are regularly updating and adding features to the CLI tools so it’s wroth running the command: “brew update && brew upgrade azure-cli” to get the latest features and bug-fixes.
As mentioned above the CLI tools are built upon Python which means the correct version of Python needs to be installed. If you get an error during the Brew install then it’s worth running the commands:
brew update && brew install python3 && brew upgrade python3
brew link –overwrite python3
Have fun with Azure and the CLI on your Apple machine!