Part 2: Completing the Homebrew & Azure CLI Installation
Published on February 19, 2025
Recently, I embarked on a journey to build a Terraform project integrated with Azure services. The process turned out to be an adventure in dependency management, disk space clean-up, and environment configuration. Here’s the detailed story of how I went from “command not found” errors to a fully authenticated Azure CLI.
1. Confirming My Terraform Environment
I began by ensuring that Terraform was correctly installed:
which terraform
/usr/local/bin/terraform
With my Terraform configuration file (main.tf) in place, I felt ready to integrate Azure.
2. Encountering Missing Azure CLI
I attempted to check the version of the Azure CLI:
az --version
But the terminal replied:
zsh: command not found: az
It was clear that I needed to install the Azure CLI. My plan was to use Homebrew—a popular macOS package manager—to install it. However, when I tried:
brew install azure-cli
I hit another snag:
zsh: command not found: brew
3. Installing Homebrew (with a Few Hurdles)
Since Homebrew wasn’t installed on my system, I ran the official installation script:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
The script announced its intentions (like installing the Xcode Command Line Tools) and began creating the necessary directories. At first, I encountered errors due to insufficient disk space for the Xcode tools. I used commands like df -h / to inspect available space and even tried cleaning up caches and the Trash:
rm -rf ~/Library/Caches/*
rm -rf ~/.Trash/*
Some protected directories couldn’t be cleared due to macOS’s security measures, but after a few rounds of cleanup, I finally had enough free space. I also updated my shell configuration by adding Homebrew’s path:
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
4. A Successful Homebrew Installation:
I re-ran the Homebrew installation script. This time, the script successfully installed the Xcode Command Line Tools and Homebrew itself:
/opt/homebrew/bin/brew shellenv
Following the on-screen instructions, I added Homebrew to my PATH by updating my ~/.zprofile:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/eaton/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
A quick check with brew help confirmed that Homebrew was up and running.
5. Installing Azure CLI via Homebrew
With Homebrew installed, I proceeded to install the Azure CLI:
brew install azure-cli
Homebrew fetched and installed all the necessary dependencies—such as libsodium, libyaml, ca-certificates, openssl@3, mpdecimal, readline, sqlite, xz, and python@3.12. The installation completed successfully, with Homebrew noting that zsh completions were installed for convenience.
A subsequent check with:
az --version
yielded:
azure-cli 2.69.0
...
Your CLI is up-to-date.
This confirmed that the Azure CLI was ready for use.
6. Logging into Azure
Next, I ran:
az login
This command opened a web browser for authentication. After logging in, the CLI retrieved my tenant and subscription information. For example, I saw output like:
No Subscription name Subscription ID Tenant
----- -------------------- ------------------------------------ -----------------
[1] * Azure subscription 1 90e715ee-6967-453b-9d25-4e8ef640be04 Default Directory
With my default subscription selected, my environment was finally ready for further work with Terraform and Azure!
Final Thoughts
This setup journey taught me several valuable lessons:
- Verify prerequisites early: Double-checking installations like Terraform saves time later.
- Homebrew is a powerful ally: It simplifies installing packages like the Azure CLI.
- Disk space matters: Freeing up space is sometimes as critical as installing new software.
- Embrace the bumps: Warnings and errors are part of the learning process and help refine your setup.
With the environment now properly configured, I’m excited to continue building with Terraform and harnessing the power of the Azure CLI. Stay tuned for more updates as I progress further into cloud automation and infrastructure as code!