Install the Azure CLI on your computer and sign in
In this task you'll install the Azure CLI and sign in.
Cloud Shell is handy, but for regular work it's faster to have the Azure CLI on your own computer, where it works with your own editor, files and scripts.
The CLI runs on Windows, macOS and Linux. After installing, az login opens your browser so you sign in the usual way, including MFA.
Example. A Larkfield Group developer installs the CLI on their laptop, signs in once, and keeps deployment scripts in the team's git repository instead of retyping commands in Cloud Shell.
Before you start
You need: Permission to install software on your computer. Time: 15 minutes.
Where to look
- Your computer
- Terminal
Steps
- On Windows, open a terminal and run
winget install --exact --id Microsoft.AzureCLI. Or download the installer from Microsoft's official Azure CLI page.Only install from Microsoft's own site or package manager. - On macOS, run
brew install azure-cli. On Ubuntu or Debian, follow the install steps on Microsoft's Azure CLI page for your distribution. - Close and reopen the terminal, then check it works:
az version. - Sign in with
az login. Your browser opens; sign in there yourself, then come back to the terminal.On a machine without a browser, useaz login --use-device-codeand enter the code on another device. - If you have several subscriptions, pick one:
az account set --subscription "<name or ID>". - Keep it up to date with
az upgrade.
Commands
# Windows (winget)
winget install --exact --id Microsoft.AzureCLI
# macOS (Homebrew)
brew install azure-cli
# Then, on any system
az version
az login
az account show --output table
Watch out for
- Cost
- The Azure CLI is free.
- Security
- Your sign-in is cached on the computer, so anyone using your account there can run commands as you. Run
az logouton shared machines, and lock your computer. - Common mistakes
- Installing an outdated version from an unofficial source. Forgetting which subscription is the default after signing in. Not reopening the terminal, so az isn't found.
Clean up
Nothing to clean up. To sign out, run az logout.
Words to know
- winget
- The Windows package manager, used to install apps from the command line.
- Homebrew
- A package manager for macOS.
- Device code sign-in
- A way to sign in on a machine without a browser: you enter a short code on another device.
Tick off each step and track your progress in the guide.
Open this task in Azure Portal, Hands On