How do you authenticate the Azure CLI on a laptop, in CI and on a VM?
BeginnerConceptFundamentals and Resource Hierarchy
Answer
| Where | How |
|---|---|
| Laptop | az login (browser), or az login --use-device-code on a headless box |
| CI | Workload identity federation: azure/login@v2 in GitHub, a WIF service connection in Azure DevOps; never a stored secret if you can avoid it |
| VM, App Service, AKS pod | Managed identity: az login --identity (add --username <clientId> or --client-id for a user-assigned identity on newer CLI) |
Then pin the subscription: az account set --subscription <id>. Most "wrong resources changed" incidents start with a default subscription nobody checked.
More on Fundamentals and Resource Hierarchy
Explain the Azure resource hierarchy from top to bottom.BeginnerWhat is the difference between an Entra tenant and a subscription?BeginnerWhat should go into a resource group and what should not?BeginnerWhat are regions, region pairs and availability zones in Azure?BeginnerWhy do logical zone numbers differ between subscriptions?IntermediateWhat is Azure Resource Manager (ARM)?Beginner