DevOps Peach

Azure Basics · Azure Resources – Tools, Resource Manager and ARM Templates · Lesson 3 of 4

Resource Manager, Resource Groups and Locks

ARM is the common management layer for every tool; resource groups hold resources that share a lifecycle; CanNotDelete or ReadOnly locks stop accidental deletes/changes and are inherited downwards.

Practice interactively →

Azure Resource Manager (ARM) is the unified management layer: the Portal, CLI, PowerShell, SDKs and templates all go through it, so they share authentication, RBAC, Policy, tags and audit logs. ARM deploys, updates and deletes a whole group of resources in one operation.

A resource group (RG) is a logical container for resources that share a lifecycle (everything of a lab environment, say). Each resource belongs to exactly one RG; the RG has its own region (where metadata is stored) but can hold resources in other regions. Deleting an RG deletes every resource inside.

flowchart TB
  S["Subscription"] --> RG["rg-devops-lab<br/>lock: CanNotDelete"]
  RG --> V["vnet-lab"]
  RG --> VM["vm-web-01"]
  RG --> ST["stdevopslab01"]
  RG -. "lock inherited" .-> VM

Locks

Type (CLI / Portal) Blocks
CanNotDelete / Delete Deletion; reads and changes still work
ReadOnly / Read-only Every change, including deletion

Moving, deleting, quotas

Command Meaning
az group create -n rg-devops-lab -l southeastasia Create an RG
az lock create --name no-delete --lock-type CanNotDelete -g rg-devops-lab Delete protection
az lock list -g rg-devops-lab -o table Locks of the RG

Resource IDs

Every resource has a full ID that encodes where it lives:

/subscriptions/<sub-id>/resourceGroups/rg-devops-lab/providers/Microsoft.Compute/virtualMachines/vm-web-01

The segment after providers is the resource provider namespace and type. Role assignments, policies, locks, and --ids arguments all use this format. az resource show --ids <id> works for any type.

Resource providers

Each service is delivered by a provider such as Microsoft.Compute or Microsoft.ContainerService. A subscription must have a provider registered before you create its resources; most common ones register automatically, but a new service may fail with "subscription is not registered". Fix it with az provider register --namespace Microsoft.ContainerService and check with az provider show -n Microsoft.ContainerService --query registrationState.

Deployment history and request flow

Every request goes through ARM, which checks authentication, RBAC, Policy, and locks before passing it to the provider. That is why a deny policy or a lock produces an ARM error before anything is created. Template deployments are listed with az deployment group list -g rg-devops-lab -o table, and individual operations appear in the Activity log.

Using locks well

Use az lock delete --name no-delete -g rg-devops-lab when a lab really must be removed.

Practice interactively →