az account set: Subscriptions & Common CI Errors
Choose which Azure subscription the CLI operates against.
az account set selects the active subscription for subsequent Azure CLI commands. When an identity has access to several subscriptions, this is how you target the right one in CI.
What it does
az account set --subscription <id-or-name> changes the default subscription stored in the CLI’s profile. All later commands operate against it unless overridden per-command with --subscription. az account show confirms the current selection, and az account list enumerates available subscriptions.
Common usage
# Set the active subscription by ID (preferred) or name
az account set --subscription "00000000-0000-0000-0000-000000000000"
# Confirm what is active
az account show --query "{name:name, id:id}" -o table
# List all accessible subscriptions
az account list --query "[].{name:name, id:id}" -o tableCommon error in CI: "subscription ... not found" / wrong default
Commands fail with "The subscription of \"...\" doesn't exist in cloud \"AzureCloud\"" when the name/ID is wrong or the logged-in identity has no access to it, or operations silently hit the wrong subscription because the default was never set. Fix: set the subscription explicitly by GUID (names are ambiguous across tenants) right after az login, and verify with az account show. If "not found" persists, the service principal lacks a role assignment on that subscription - grant it (e.g. Contributor scoped to the subscription).
Key options
| Command / option | Purpose |
|---|---|
| --subscription | Subscription ID or name to activate |
| az account show | Show the active subscription |
| az account list | List accessible subscriptions |
| --query / -o | Shape and format output |