Azure CLI
The Azure CLI is a cross-platform command-line tool for managing Azure resources. It runs on Linux, macOS, and Windows, and can be used interactively or in automation scripts. This guide covers instal
Installation (2025)
Fedora / RHEL / CentOS
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo dnf install -y https://packages.microsoft.com/config/rhel/9.0/packages-microsoft-prod.rpm
sudo dnf install -y https://packages.microsoft.com/config/rhel/8/packages-microsoft-prod.rpm
sudo dnf install azure-cliUbuntu / Debian
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bashmacOS (Homebrew)
brew update && brew install azure-cliWindows
winget install -e --id Microsoft.AzureCLINixOS Installation & Configuration (2025)
Using Nix Package Manager
# Add to your /etc/nixos/configuration.nix
environment.systemPackages = with pkgs; [ azure-cli ];Apply the configuration:
sudo nixos-rebuild switchUsing Home Manager (per-user)
# Add to your home.nix
home.packages = with pkgs; [ azure-cli ];Apply the configuration:
home-manager switchPost-Install Configuration
Ensure you have Python 3 available (NixOS provides this by default).
If you need to use Azure CLI behind a proxy, set the
HTTP_PROXYandHTTPS_PROXYenvironment variables as described above.For persistent configuration, add proxy variables to your shell profile (e.g.,
.bashrc,.zshrc).
Proxy Settings
If you are behind a proxy, configure the following environment variables:
# No auth
export HTTP_PROXY=http://[proxy]:[port]
export HTTPS_PROXY=https://[proxy]:[port]
# Basic auth
export HTTP_PROXY=http://[username]:[password]@[proxy]:[port]
export HTTPS_PROXY=https://[username]:[password]@[proxy]:[port]Running Azure CLI in Docker/Podman
docker run -it mcr.microsoft.com/azure-cliTo use your local SSH keys (for az ssh, az vm, etc.):
docker run -it -v ${HOME}/.ssh:/root/.ssh mcr.microsoft.com/azure-cliReal-Life DevOps Examples (2025)
1. Login and Set Subscription
az login
az account set --subscription "My-Prod-Subscription"2. Create a Resource Group
az group create --name devops-rg --location westeurope3. Deploy Infrastructure with Bicep
az deployment group create \
--resource-group devops-rg \
--template-file main.bicep \
--parameters environment=dev4. Assign a Managed Identity to a VM
az vm identity assign --name myvm --resource-group devops-rg5. Use Azure CLI in GitHub Actions
- name: Azure Login
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Run Azure CLI Script
run: |
az group list --output tableAzure CLI Jokes
Why did the Azure resource group break up with the VM? Because it needed more space!
Why do Azure engineers love the CLI? Because it's always az-y to automate!
Why did the Azure cloud get invited to all the parties? Because it always brings the best resources on demand!
More Examples & Resources
Tip: Use az upgrade to keep your CLI up to date!
Last updated