Azure Cheatsheet
Resource Groups
Use this Azure reference while you build software engineering projects, review code for technical interview prep, or polish examples for a software engineer resume.
Create & Delete
# Create az group create --name myRG --location eastus # Create with tags az group create --name myRG --location eastus \ --tags env=prod team=platform owner=alice # Delete (and all resources inside it) az group delete --name myRG --yes # Delete without waiting az group delete --name myRG --yes --no-wait
List & Inspect
| Command | What it does |
|---|---|
az group list -o table | List all resource groups |
az group show -n myRG | Show details of one group |
az group exists -n myRG | Returns true/false |
az resource list -g myRG -o table | List all resources inside a group |
az group list --query "[?location=='eastus']" -o table | Filter by region |
# Count resources per group az resource list --query "length(@)" -g myRG # Find groups by tag az group list --tag env=prod -o table
Move Resources Between Groups
# Move one resource az resource move \ --destination-group targetRG \ --destination-subscription-id <sub-id> \ --ids /subscriptions/<sub>/resourceGroups/sourceRG/providers/Microsoft.Compute/virtualMachines/myVM # Validate move first (dry-run) az resource invoke-action \ --action validateMoveResources \ --ids /subscriptions/<sub>/resourceGroups/sourceRG \ --request-body '{"resources":["<resource-id>"],"targetResourceGroup":"/subscriptions/<sub>/resourceGroups/targetRG"}'
Not all resource types support move. Check docs first.
Locks
Prevent accidental modification or deletion.
# Lock a group (CanNotDelete) az lock create --name no-delete \ --resource-group myRG \ --lock-type CanNotDelete # Lock a group (ReadOnly — prevents all writes) az lock create --name read-only \ --resource-group myRG \ --lock-type ReadOnly # List locks on a group az lock list --resource-group myRG -o table # Delete a lock az lock delete --name no-delete --resource-group myRG
Role-Based Access Control (RBAC) on a Group
# Assign Contributor to a user az role assignment create \ --assignee user@example.com \ --role Contributor \ --scope /subscriptions/<sub>/resourceGroups/myRG # Assign Reader to a service principal az role assignment create \ --assignee <app-id> \ --role Reader \ --scope /subscriptions/<sub>/resourceGroups/myRG # List assignments on a group az role assignment list --resource-group myRG -o table # Remove assignment az role assignment delete \ --assignee user@example.com \ --role Contributor \ --resource-group myRG
ARM Template Deployments to a Group
# Deploy a Bicep / ARM template az deployment group create \ --resource-group myRG \ --template-file main.bicep \ --parameters @params.json # What-if (dry-run) az deployment group what-if \ --resource-group myRG \ --template-file main.bicep \ --parameters @params.json # List deployments az deployment group list -g myRG -o table # Show a deployment az deployment group show -g myRG -n myDeployment # Cancel a running deployment az deployment group cancel -g myRG -n myDeployment
Policies
# Assign a built-in policy to a group az policy assignment create \ --name "require-tags" \ --scope /subscriptions/<sub>/resourceGroups/myRG \ --policy "871b6d14-10aa-478d-b590-94f262ecfa99" # Require a tag # List assignments az policy assignment list --scope /subscriptions/<sub>/resourceGroups/myRG