Governing the Snips Environment
Azure Policy and compliance·45 minutes
The governance problem
Three weeks after the Azure environment went live, you receive a message from the Head of Digital & IT. A developer has created a virtual machine in North Europe. Another team has deployed resources with no tags and no identifiable owner. Last week, a test VM was accidentally deleted from the production resource group.
You need to put guardrails in place. Azure Policy will enforce the rules automatically, and resource locks will protect critical infrastructure from accidental deletion.
What you will learn
Azure Policy concepts
Policy definition
A rule that describes what is evaluated and what action to take. For example: deny resource creation outside UK South and UK West.
Initiative (policy set)
A collection of policy definitions grouped for a common purpose. The Snips Cloud Baseline initiative includes all governance policies.
Policy assignment
Applying a policy definition or initiative to a specific scope (management group, subscription or resource group).
Policy effects
What happens when a resource does not comply: Deny (block creation), Audit (log but allow), Append (add fields), Modify (change properties), DeployIfNotExists (deploy a remediation resource).
Compliance
Azure Policy continuously evaluates resources and reports compliance status. Non-compliant resources are flagged for remediation.
The Snips Cloud Baseline
The Snips Cloud Baseline is an initiative containing the following policies:
Interactive compliance dashboard
Review the Snips resources below. Identify which are non-compliant and why. Click a non-compliant resource to see the issue.
vm-contractors-prod-001storage-test-123Click to reveal the compliance issue
rg-paultestClick to reveal the compliance issue
vnet-snips-prod-uks-001vm-dev-eastus-001Click to reveal the compliance issue
Azure CLI
# List all policy assignments in a subscription
az policy assignment list --output table
# Check compliance for a specific policy
az policy state list \
--resource-group rg-contractors-prod-uks-001 \
--output table
# Create a policy assignment to enforce UK South/West only
az policy assignment create \
--name "snips-allowed-locations" \
--display-name "Snips: Allowed locations" \
--policy "e56962a6-4747-49cd-b67b-bf8b01975c4f" \
--params '{"listOfAllowedLocations":{"value":["uksouth","ukwest"]}}' \\
--scope "/subscriptions/<sub-id>"Knowledge check
Five questions on Azure Policy and governance.
1.A team has deployed a virtual machine in North Europe, which is outside the Snips approved regions. Which Azure Policy effect would have prevented this?
2.You apply a CanNotDelete lock to the rg-network-prod-uks-001 resource group. What can users with Contributor access still do?
3.Snips has an Azure Policy initiative called 'Snips Cloud Baseline'. What is an initiative?
4.A resource is showing as Non-compliant in Azure Policy. What does this mean?
5.You need to apply a ReadOnly lock to a resource group. A colleague says this will prevent the team from working. Why might they be right?
Ready to mark this module complete?
Mark complete when you have read all sections, attempted the lab and completed the knowledge check.
- Manage Azure identities and governance