Home › Studies › AZ-104 › Identities & Governance › Locks & Tags

Locks & Tags

CanNotDelete · ReadOnly · inheritance · tags · Merge vs Replace · tag policies

By the tools4free.dev team · Last reviewed November 13, 2026

Practice questions for this topic →

Resource locks

Lock levelEffect
Delete (CanNotDelete)Authorized users can read and modify the resource, but not delete it
Read-only (ReadOnly)Similar to restricting everyone to the Reader role

Side effects of locks

LockWhereWhat breaks
ReadOnlyStorage accountList Keys (a POST) is blocked, and blob container creation is blocked
ReadOnlyResource group with a VMStart and restart are blocked
ReadOnlyResource group with an App Service planScale up and scale out are blocked
ReadOnlyResource group with an Automation accountStarting a runbook is blocked
ReadOnlyNetwork security groupFlow log creation is blocked
ReadOnlySubscriptionAzure Advisor can't store results
CanNotDeleteResource groupAutomatic deletion of deployment history is blocked (deployments fail at 800 history entries), RBAC assignments can't be deleted, and Azure Backup restore point cleanup can break

Locks and moves: a ReadOnly lock on the source or destination resource group or subscription blocks a move. Remove it first.

Lock commands

TaskAzure CLIPowerShell
Lock a resource groupaz lock create --name LockGroup --lock-type CanNotDelete --resource-group exampleresourcegroupNew-AzResourceLock -LockName LockGroup -LockLevel CanNotDelete -ResourceGroupName exampleresourcegroup
Lock a resourceaz lock create --name LockSite --lock-type CanNotDelete --resource-group <rg> --resource-name <n> --resource-type Microsoft.Web/sitesNew-AzResourceLock -LockLevel CanNotDelete -LockName LockSite -ResourceName <n> -ResourceType Microsoft.Web/sites -ResourceGroupName <rg>
List locksaz lock listGet-AzResourceLock
Delete a lockaz lock delete --ids <lockId>Remove-AzResourceLock -LockId <id>

Tags

LimitValue
Tag name-value pairs per resource, resource group and subscription50
Services limited to 15 tagsAutomation, CDN, public and private DNS, Log Analytics saved search
Tag name length512 characters (128 for storage accounts)
Tag value length256 characters
Characters not allowed in names< > % & \ ? /

Tag commands

TaskAzure CLIPowerShell
Set tags, replacing the whole setaz tag create --resource-id $resource --tags Dept=Finance Status=NormalNew-AzTag -ResourceId $resource.id -Tag $tags
Merge: add new names and update existing values, keep the restaz tag update --resource-id <id> --operation Merge --tags key1=value1Update-AzTag -ResourceId <id> -Tag $tags -Operation Merge
Replace the whole setaz tag update --resource-id <id> --operation Replace --tags key1=value1Update-AzTag -ResourceId <id> -Tag $tags -Operation Replace
Delete only the named tagsaz tag update --resource-id $resource --operation Delete --tags Project=ECommerce Team=WebUpdate-AzTag -ResourceId $resource.id -Tag $removeTags -Operation Delete
Remove all tagsaz tag delete --resource-id $resourceRemove-AzTag -ResourceId <id>
List tagsaz tag list --resource-id $resourceGet-AzTag -ResourceId $resource.id
Find by tagaz resource list --tag CostCenter=00123 --query [].name(Get-AzResource -Tag @{ "CostCenter"="00123"}).Name

Built-in tag policies

Policy typeEffectExisting resources
Require a tag (and its value)DenyEnforces the tag (Deny)
Append a tag and its valueAppendNot changed until they are changed
Add a tag, Add or replace a tag, Inherit a tagModifyFixed by a remediation task

Exam Tips

Tick each tip once you can answer it without looking.

“Prevent accidental deletion but keep editing allowed” → CanNotDelete lock. Trap: ReadOnly also blocks changes.

“Owner can't delete a resource group that has a lock” → A lock overrides permissions: remove the lock first. Trap: a higher role doesn't bypass a lock.

“Delete lock on one VM, then delete its resource group” → The whole group delete is blocked. Trap: it isn't a partial delete that spares only the VM.

“ReadOnly lock on a resource group; a VM won't start” → Start and restart are blocked by the lock: remove it. Trap: a VM extension problem.

“ReadOnly lock on a storage account; listing keys fails” → List Keys is a POST, which the lock blocks. Trap: a firewall problem.

“ReadOnly lock on a subscription; Advisor shows errors” → Advisor can't store its results under the lock. Trap: an Advisor outage.

“Lock a management group” → Not supported. Trap: the portal Locks blade.

“Who can create or delete locks?” → Owner or User Access Administrator (Microsoft.Authorization/locks/*). Trap: Contributor isn't named on the page as having it.

“Storage account has a lock, but blobs were still deleted” → Locks cover the control plane, not data-plane calls. Trap: assuming the data is protected.

“Move resources out of a resource group with a ReadOnly lock” → Blocked: remove the lock first. Trap: a ReadOnly lock on the source or destination resource group or subscription blocks a move.

“VMs in a group must carry the group's CostCenter tag, including existing ones” → Azure Policy Modify (Inherit a tag) plus a remediation task. Trap: tags aren't inherited automatically.

“Tag any resource without access to the resource” → Tag Contributor role. Trap: Contributor also works, but only because it has write access to the resource itself.

“Tag limit per resource” → 50 name-value pairs. Trap: 15 applies only to a few services.

“Tags Env and ENV” → Names are case-insensitive; values are case-sensitive. Trap: treating them as two different tags.

“Tag a management group” → Not possible. Trap: applying the tag at the root management group.

“Store a password in a tag” → Don't: tags are plain text and appear in cost reports and templates. Trap: tags are encrypted.

“Add a tag and keep the existing ones” → az tag update --operation Merge. Trap: az tag create and New-AzTag replace the whole set.

“Remove only two tags and keep the rest” → az tag update --operation Delete with those tags. Trap: az tag delete --resource-id removes all tags.

“Require a tag on every new resource” → Require a tag on resources (Deny). Trap: it doesn't apply to resource groups; use the resource group version.

Sources

Checked against Microsoft Learn on November 13, 2026.

← Azure PolicySubscriptions & Management Groups →