Azure Policy, Resource Locks and Standardized Deployments: Governance Guardrails for Every Subscription

Microsoft Azure Architect Technologies AZ 300 55 min min read Updated: Nov 17, 2026 Intermediate
Azure Policy, Resource Locks and Standardized Deployments: Governance Guardrails for Every Subscription
Intermediate Topic 1 of 3

RBAC vs Policy

Azure RBACAzure Policy
QuestionWho can do an action?What is allowed on resources?
ExampleAsha can create VMsVMs may only be created in India regions
Applies toPeople and identitiesResource properties, even for Owners

Azure Policy Concepts

TermMeaning
Policy definitionA rule in JSON: a condition (if) and an effect (then)
Initiative (policy set)A group of definitions with one goal (for example 'ISO 27001' or 'tagging standard')
AssignmentApplies a definition or initiative to a scope (management group, subscription, resource group) with parameters and exclusions
ComplianceDashboard showing which resources follow the rules
Remediation taskFix existing non-compliant resources (for Modify and DeployIfNotExists)

Effects

EffectWhat happens
DenyBlocks the request that would create or change a non-compliant resource
AuditAllows it, but records it as non-compliant
ModifyAdds or changes properties such as tags automatically
AppendAdds fields during creation
DeployIfNotExistsDeploys a related resource if missing (for example diagnostic settings)
AuditIfNotExistsReports missing related resources
DisabledTurn the policy off for testing

A Policy: Allowed Locations

json { "properties": { "displayName": "Allowed locations for resources", "mode": "Indexed", "parameters": {"allowedLocations": {"type": "Array"}}, "policyRule": { "if": {"not": {"field": "location", "in": "[parameters('allowedLocations')]"}}, "then": {"effect": "deny"} } } }
bash # Assign the built-in "Allowed locations" policy to a subscription az policy definition list --query "[?displayName=='Allowed locations'].name" -o tsv az policy assignment create --name allowed-locations --display-name "Allowed locations" \ --policy $(az policy definition list --query "[?displayName=='Allowed locations'].name | [0]" -o tsv) \ --scope /subscriptions/<sub-id> --params '{"listOfAllowedLocations":{"value":["centralindia","southindia"]}}' az policy state summarize --query "results.nonCompliantResources"

Good Policy Ideas

  • Require tags such as owner and env, or inherit tags from the resource group with Modify
  • Allowed regions and allowed VM sizes
  • Deny public IP on network interfaces
  • Require HTTPS on storage accounts and web apps
  • DeployIfNotExists: send diagnostic logs to a Log Analytics workspace
  • Use built-in initiatives such as Microsoft cloud security benchmark
Roll out safely Assign with Audit first, read compliance results, fix problems, then switch to Deny. Use exclusions for special cases.

Resource Locks

LockEffect
CanNotDeleteUsers can read and change but not delete
ReadOnlyUsers can only read (like Reader for everyone, including Owners)
bash az lock create --name keep-db --lock-type CanNotDelete --resource-group rg-shop-data-prod az lock list --resource-group rg-shop-data-prod -o table
  • Locks apply to everyone, even Owners, until the lock is removed
  • Locks inherit to child resources
  • A ReadOnly lock can break things that need to write (for example a storage account listing keys, or an App Service plan scaling)

Standardized Deployments

  • Template specs: store ARM or Bicep templates in Azure with versions and RBAC so teams reuse approved patterns
  • Deployment stacks: manage a group of resources as one unit and prevent unmanaged changes or deletes
  • Azure Blueprints (older packaged environment definitions) is being retired in favor of template specs, deployment stacks and Azure Policy. Check current status before using it for new work

Practice

  1. Assign the Allowed locations policy in Audit mode, then Deny
  2. Create a policy that requires an owner tag
  3. Add a CanNotDelete lock to a resource group and try to delete it
  4. Explain why a ReadOnly lock may break a service

Conclusion

Azure Policy enforces standards on resources with effects like Deny, Audit, Modify and DeployIfNotExists. Use initiatives, start with Audit, add resource locks for critical items and reuse approved templates.

Quick Summary: RBAC vs Policy; concepts; effects; example; ideas; locks; deployments.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators