Overview
Azure organizes everything you create into a hierarchy, management groups, subscriptions, resource groups, and individual resources, and understanding that hierarchy matters more than understanding any single resource type, because it's where access control, policy enforcement, and cost management actually happen. Every operation, regardless of whether it comes from the Portal, CLI, or an infrastructure-as-code tool, goes through Azure Resource Manager (ARM), which is what makes that hierarchy consistently enforceable no matter how a change was made.
Quick Reference
| Level | Purpose | Deleting it |
|---|---|---|
| Management group | Governance (policy, RBAC) across multiple subscriptions | Doesn't delete subscriptions, just removes grouping |
| Subscription | Billing and access-management boundary | Requires explicit cancellation, resources first |
| Resource group | Logical container for resources sharing a lifecycle | Deletes every resource inside it |
| Resource | An individual manageable object (VM, storage account...) | Deletes just that resource |
The commands below are grouped by resource type, not an exhaustive reference (see the official Azure CLI reference for every flag), but the set that covers nearly all day-to-day az CLI work.
| Command | Description | Copy |
|---|---|---|
az login | Sign in interactively, via the browser. | |
az account show | Show the currently active subscription. | |
az account list | List every subscription available to the signed-in account. | |
az account set --subscription <id> | Switch the active subscription for subsequent commands. |
| Command | Description | Copy |
|---|---|---|
az group create --name <rg> --location eastus | Create a resource group in a region. | |
az group list | List resource groups in the active subscription. | |
az group show --name <rg> | Show details of a resource group. | |
az group delete --name <rg> | Delete a resource group and every resource inside it. |
| Command | Description | Copy |
|---|---|---|
az vm create --resource-group <rg> --name <vm> --image Ubuntu2404 | Create a virtual machine. | |
az vm list | List VMs in the active subscription. | |
az vm start --resource-group <rg> --name <vm> | Start a stopped VM. | |
az vm deallocate --resource-group <rg> --name <vm> | Stop a VM and release its compute allocation, so it stops incurring compute charges. |
| Command | Description | Copy |
|---|---|---|
az storage account create --name <name> --resource-group <rg> --sku Standard_LRS | Create a storage account. | |
az storage container create --name <name> --account-name <account> | Create a blob container inside a storage account. | |
az storage blob upload --account-name <account> --container-name <container> --name <blob> --file <path> | Upload a local file as a blob. | |
az storage account list | List storage accounts in the active subscription. |
| Command | Description | Copy |
|---|---|---|
az aks create --resource-group <rg> --name <cluster> --node-count 3 --generate-ssh-keys | Create an AKS (managed Kubernetes) cluster. --generate-ssh-keys generates an SSH key pair automatically if one doesn't already exist, so the command succeeds even on a machine with no existing public key. | |
az aks get-credentials --resource-group <rg> --name <cluster> | Fetch cluster credentials into kubeconfig, so kubectl can target the cluster. | |
az aks list | List AKS clusters in the active subscription. | |
az aks scale --resource-group <rg> --name <cluster> --node-count 5 | Scale an AKS cluster's node pool. |
| Command | Description | Copy |
|---|---|---|
az monitor metrics list --resource <id> | Query metrics for a specific resource. | |
az monitor activity-log list | List subscription activity log events (who did what, and when). | |
az monitor log-analytics query --workspace <id> --analytics-query "<KQL>" | Run a Kusto (KQL) query against a Log Analytics workspace. |
Syntax
az group create --name rg-app-prod --location eastus
az deployment group create \
--resource-group rg-app-prod \
--template-file main.bicepExamples
// main.bicep, declarative resource definition, deployed
// through Azure Resource Manager like every other Azure change.
resource storage 'Microsoft.Storage/storageAccounts@2023-01-01' = {
name: 'appuploadsprod'
location: resourceGroup().location
sku: { name: 'Standard_LRS' }
kind: 'StorageV2'
}Deleting a resource group deletes everything in it
There's no confirmation beyond the initial prompt, and it cascades to every resource the group contains. Treat resource-group deletion with the same care as a destructive database operation.
Visual Diagram
Common Mistakes
- Putting unrelated resources with different lifecycles into the same resource group, making it impossible to delete or manage one without affecting the others.
- Managing access at the individual-resource level instead of at the resource-group or subscription level, creating an unmanageable sprawl of one-off role assignments.
- Ignoring management groups entirely and configuring policy per-subscription, which doesn't scale past a handful of subscriptions and drifts out of consistency over time.
- Assuming the Portal, CLI, and ARM templates behave differently; they're all just different clients of the same Resource Manager API and produce identical results for identical input.
Performance
- ARM deployment speed scales with the number of resources and their interdependencies in a single deployment, very large templates benefit from being split into modules deployed independently where dependencies allow.
- Resource group and subscription structure has no runtime performance impact on the resources themselves; it's purely a management/governance concern, not a latency one.
Best Practices
- Group resources by lifecycle, not by resource type, everything in a resource group should reasonably be created and deleted together.
- Use management groups and Azure Policy to enforce organization-wide rules once, rather than per-subscription.
- Assign RBAC roles at the resource-group or subscription level whenever the access genuinely applies that broadly, instead of per-resource.
- Adopt a consistent subscription strategy (e.g., separate subscriptions per environment or business unit) before resource sprawl makes retrofitting one expensive.