How to Set Default Subscription in Azure CLI (Step-by-Step)

A cleanup script was supposed to delete a few test resource groups in a dev subscription. It ran without errors, but the groups it deleted belonged to a staging subscription. The engineer had signed in that morning, never checked which subscription was active, and Azure CLI had quietly picked the wrong one. Nothing in the script was wrong. The context was.

Knowing how to set default subscription in Azure CLI is a small skill with a big payoff.I have seen this exact mix-up in companies with five subscriptions and in companies with fifty. You will learn how to list subscriptions, set the default, verify it, override it for one command, and protect your environments so a wrong choice cannot do real damage.

What the Default Subscription Is and Why It Matters

An Azure subscription is the billing and governance boundary for Azure resources. Read what an Azure subscription is if you want the basics. Every resource lives inside one subscription, and every subscription belongs to one tenant, which is a dedicated Microsoft Entra directory. Here is what a tenant in Azure means.

When you run az login, the CLI collects every subscription your identity can see. It then marks one as the default. Microsoft’s documentation states that most CLI commands act within a subscription, and if you don’t specify one, the command uses your current active subscription. That active subscription is stored in your local Azure CLI profile, so it persists after you close the terminal.

Why the Wrong Default Is Dangerous

  • Cost. New resources land in the wrong subscription and bill the wrong budget.
  • Deletion. A delete command hits the wrong environment.
  • Policy. Each subscription can have different Azure Policy rules, so a deployment that passes in dev may fail in production.
  • Access. Your permissions differ by subscription, which produces confusing authorization errors.
  • Pro Tip: In my experience, the default subscription is the most forgotten setting in Azure. I treat az account show like pwd in a shell: I run it before every command that changes anything.

How to Set Default Subscription in Azure CLI: Step by Step

Follow these five steps in order. The whole process takes about two minutes.

Step 1: Sign In

<