You will install the Azure CLI, authenticate, select the right subscription, and set defaults so later commands are short and safe. By the end you will have a reproducible az workflow ready for every other Azure lab.

Learning Objectives

  • Authenticate interactively and view your subscriptions.
  • Set the active subscription and default resource group/location.
  • Create a service principal for automation.
  • Time: ~1 hour · Difficulty: Beginner · Prereqs: an Azure account.

Architecture Overview

Environment Setup

You will need: the Azure CLI (install docs) and an Azure account.

Before you begin: know which subscription you should deploy into to avoid surprise billing.

Step-by-Step Execution

01
Authenticate
az login
Opens a browser to sign in to Microsoft Entra ID.
02
Select the subscription
$ az account list -o table && az account set --subscription "Pay-As-You-Go"
Name IsDefault Pay-As-You-Go True
03
Set defaults to shorten commands
az configure --defaults group=tyf-rg location=eastus
04
Create a service principal for automation

A service principal lets pipelines authenticate without your personal account.

az ad sp create-for-rbac --name tyf-ci --role Contributor --scopes /subscriptions/$(az account show --query id -o tsv)

Progress So Far

Testing & Validation

az account show -o table && az group create -n tyf-rg -l eastus

You should see your active subscription and a created resource group using your defaults. If so, your CLI is ready.

Troubleshooting
  • az: command not found: the CLI is not on PATH; reinstall or restart your shell.
  • Wrong subscription used: always confirm with az account show before deploying.
  • SP secret printed once: store it immediately in a secret manager; it is not retrievable later.

Extension Ideas

Key Results

  • Authenticated and confirmed the correct subscription.
  • Set defaults that shorten and de-risk every later command.
  • Created a least-privilege service principal for automation.
  • Validated by creating a resource group from defaults.