Introduction

Here’s a quick how-to guide for using Azure CLI, based on Microsoft’s official documentation [1 - 3].

Azure CLI is a cross-platform command-line tool for managing Azure resources. You can run it:

  • Locally (Windows, macOS, Linux)
  • In a Docker container
  • In the browser via Azure Cloud Shell (no installation required)

Installation

Choose your platform:

Windows

winget install --exact --id Microsoft.AzureCLI

macOS

brew update && brew install azure-cli

Linux

curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash

Docker

docker run -it mcr.microsoft.com/azure-cli:azurelinux3.0

Or use Azure Cloud Shell directly in your browser.


Authentication

To sign in:

az login

When you use az login interactively, it opens a browser window and requires multi-factor authentication (MFA). This is fine for manual use, but not suitable for automation (CI/CD pipelines, scripts, etc) because MFA requires human interaction and it’s not secure to store credentials in scripts.

If you’re using automation, consider switching to service principals or managed identities, especially with upcoming MFA requirements.


Managing Subscriptions

To view your current subscription:

az account show --output table

To switch subscriptions:

az account set --subscription "MySubscriptionName"

Finding Commands

Use:

az find "vm"

Or:

az vm --help

To explore subgroups and parameters.


Interactive Mode

Launch with:

az interactive

This mode provides inline help, autocomplete, and command suggestions.


Examples

Create a VM

az vm create -g MyResourceGroup -n MyVm --image UbuntuLTS

List storage accounts

az storage account list --output table

Set default location and resource group

az config set defaults.location=westus2 defaults.group=MyResourceGroup

References

[1] Get started with Azure CLI

[2] Azure Command-Line Interface (CLI) documentation

[3] Azure CLI onboarding cheat sheet