Skip to content

Switching Azure Accounts

Working with multiple Azure tenants and subscriptions requires clear commands and careful verification. This guide walks through switching contexts safely—whether you’re toggling between corporate and personal accounts, or managing multi-tenant deployments.

Step 1: Logout to clear cached tokens

Terminal window
az logout

Removes all cached tokens; essential when switching between accounts to avoid stale credentials.

Step 2: Login to your target account

Terminal window
az login
# Or with explicit tenant (recommended for multi-tenant orgs):
az login --tenant "your-tenant-id"

Opens browser auth, or prompts for device code. Using --tenant prevents Azure from guessing your directory.

Step 3: List available subscriptions

Terminal window
az account list --output table

Displays subscription ID, name, and tenant; helps you pick the right subscription.

Step 4: Set your active subscription

Terminal window
az account set --subscription "Your-Subscription-ID-or-Name"

Activates a subscription; use either the subscription ID or friendly name.

Step 5: Configure Azure Developer CLI (if using azd)

Terminal window
azd env set AZURE_SUBSCRIPTION_ID <ID> -e <env-name>
azd env set AZURE_LOCATION eastus -e <env-name>

Syncs your CLI context to azd workflows; azd maintains its own environment file separate from az.

Step 6: Verify your active context

Terminal window
az account show --output table

Confirms you’re logged into the correct tenant and subscription before running any deployment.

ScenarioCommand
Quick subscription switch (already logged in)az account set --subscription "my-prod-sub"
List all my subscriptionsaz account list --output table
Check who I am right nowaz account show --output table
Switch tenants (multi-org)az logout && az login --tenant "tenant-id"
  • Always verify before deploying. Three seconds of az account show saves hours of troubleshooting wrong-tenant incidents.
  • Use subscription names thoughtfully. Name subscriptions descriptively (e.g., prod-internal-billing, client-a-dev) so typos are obvious.
  • Document tenant IDs. Save a local reference (plaintext or password manager) for frequently-used tenant IDs—beats hunting through Azure portal every time.