Azure Policy Design and Assignment

Watch the video to deepen your understanding.
SubscribeComplete the full lesson to earn 25 points — 50 with Pro
Work through each section, then tap “Mark as Complete” on the last one.
✦ Skip the page breaks, the wait, and see fewer ads — read each lesson on a single page with Pro
Lesson: Azure Policy Design and Assignment
Introduction: What is Azure Policy?
In a cloud environment, managing compliance and governance at scale is a significant challenge. As your organization grows, maintaining consistency across hundreds or thousands of resources becomes impossible to do manually.
Azure Policy is a governance service that allows you to create, assign, and manage policies that enforce rules for your Azure resources. Think of it as the "guardrails" of your cloud environment. It evaluates your resources and highlights those that are not compliant with your assigned policies.
Why use Azure Policy?
- Enforcement: Prevent the creation of non-compliant resources (e.g., preventing the deployment of VMs in unauthorized regions).
- Compliance: Maintain industry standards (like ISO 27001 or PCI-DSS) by auditing existing resources.
- Cost Management: Enforce tagging policies to ensure every resource has a
CostCentertag, making it easier to track spend. - Security: Ensure that public access is disabled on sensitive services like Storage Accounts or SQL Databases.
Designing Azure Policies
Designing effective policies requires a structured approach. Before writing code, you must define the "What" and the "How."
1. Definitions
A policy definition expresses what you want to evaluate and what effect to take.
- Policy Rule: The logic (If/Then) that defines the evaluation.
- Effect: What happens when a resource is evaluated (e.g.,
Audit,Deny,DeployIfNotExists,Modify).
2. Initiatives (Policy Sets)
An initiative is a collection of policy definitions grouped together toward a single goal. For example, a "Security Best Practices" initiative might include policies for enabling diagnostic logs, requiring encryption, and restricting public IP usage.
Practical Example: Restricting VM SKUs
Imagine you want to prevent developers from deploying expensive VM sizes (e.g., G-Series) to keep costs down.
Policy Definition (JSON)
{
"properties": {
"displayName": "Allowed VM SKUs",
"policyType": "Custom",
"mode": "Indexed",
"parameters": {
"allowedList": {
"type": "Array",
"metadata": { "description": "List of allowed VM sizes" }
}
},
"policyRule": {
"if": {
"allOf": [
{ "field": "type", "equals": "Microsoft.Compute/virtualMachines" },
{ "field": "Microsoft.Compute/virtualMachines/sku.name", "notIn": "[parameters('allowedList')]" }
]
},
"then": { "effect": "deny" }
}
}
}
Assignment
Once defined, you must assign the policy to a scope. Scopes follow the Azure resource hierarchy:
- Management Group: The highest level; policies apply to all subscriptions within.
- Subscription: Policies apply to all resource groups within.
- Resource Group: Policies apply only to resources within that specific group.
Pro Tip: Always assign at the highest possible scope (Management Group) to ensure consistent governance across the entire organization.
Governance Strategies & Best Practices
Designing governance is not just about writing rules; it is about organizational maturity.
1. Use Built-in Policies First
Microsoft provides hundreds of built-in policy definitions (e.g., "Require a tag on resources"). Before creating custom policies, search the Azure Policy portal to see if a built-in one already meets your needs. It is easier to maintain and receives updates from Microsoft automatically.
2. The "Audit" Before "Deny" Pattern
Never jump straight to Deny for a new policy in a production environment.
- Audit: Deploy the policy with the
Auditeffect first. This allows you to identify all non-compliant resources without breaking existing workflows. - Remediate: Work with teams to fix the non-compliant resources.
- Deny: Once the environment is clean, update the policy to
Denyto enforce the rule moving forward.
3. Use Parameters
Make your policies reusable by using parameters. Instead of hardcoding values like "East US" or "Standard_D2s_v3", define them as parameters so you can reuse the same policy definition with different values for different departments or environments.
Common Pitfalls to Avoid
- Over-complicating Logic: Complex logic in policy rules can lead to slower evaluation times. If a policy is too complex, consider splitting it into smaller, focused policies.
- Ignoring "Modify" and "DeployIfNotExists": Many admins only use
AuditandDeny. However,ModifyandDeployIfNotExistscan automatically fix issues (e.g., automatically adding a missing tag or configuring a Storage Account to use HTTPS), reducing the operational burden on your team. - Lack of Communication: Implementing
Denypolicies without notifying your development teams will lead to deployment failures and frustration. Always communicate governance changes before they take effect. - Missing Exemptions: Sometimes, a specific resource needs to be non-compliant for a valid business reason. Use the Policy Exemption feature rather than deleting the policy or moving the resource to a different scope.
Key Takeaways
- Governance as Code: Treat your Azure Policy definitions like application code. Store them in a Git repository, use CI/CD pipelines to deploy them, and version control your changes.
- Hierarchy Matters: Use Management Groups to push consistent policies across your entire Azure footprint.
- Start with Audit: Always assess the impact of a policy using the
Auditeffect before enforcing it withDeny. - Automation is Key: Utilize
ModifyandDeployIfNotExistseffects to automatically remediate non-compliant resources, moving from "Governance by Detection" to "Governance by Correction." - Lifecycle Management: Regularly review your policy assignments. As your cloud architecture evolves, some policies may become obsolete or require updates.
Important: Azure Policy evaluation is not instantaneous. When you assign or modify a policy, it can take up to 30 minutes for the policy to take effect across existing resources. For new resources, evaluation happens during the deployment process.
Reach the last section to complete this lesson and earn points — you're on section 1 of 5.
- Introduction to Azure Monitor
- Azure Monitor Architecture and Data Sources
- Configuring Log Analytics Workspaces
- Designing Log Routing Solutions
- Configuring Diagnostic Settings
- Application Insights for Solution Architects
- Network Watcher and Network Monitoring
- Azure Monitor Alerts and Action Groups
- Workbooks and Custom Dashboards
- Designing a Comprehensive Monitoring Strategy
- Logging and Monitoring Quiz5q
- Microsoft Entra ID for Solution Architects
- Designing Identity Solutions: B2B Collaboration
- Designing Identity Solutions: B2C Scenarios
- Conditional Access Policy Design
- Designing for Multi-Factor Authentication
- Managed Identities for Azure Resources
- Service Principals and App Registrations
- Role-Based Access Control Design
- Privileged Identity Management
- Microsoft Entra ID Protection
- Zero Trust Architecture with Microsoft Entra
- Authentication and Authorization Quiz5q
- Introduction to Azure Governance
- Designing Management Group Hierarchies
- Subscription Strategy Design
- Resource Group Organization Patterns
- Azure Policy Design and Assignment
- Custom Policy Definitions and Initiatives
- Resource Locks and Tagging Strategies
- Azure Blueprints and Landing Zones
- Cost Management and Budget Design
- Cloud Adoption Framework for Governance
- Governance Solutions Quiz5q
- Introduction to Azure Storage
- Storage Account Types and Replication
- Blob Storage Tiers and Lifecycle Management
- Azure Files and Azure NetApp Files
- Azure Managed Disks Design
- Azure Data Lake Storage Gen2
- Cosmos DB Consistency Models
- Cosmos DB Partitioning and Throughput Design
- Cosmos DB API Selection Guide
- Table Storage and Queue Storage Design
- Storage Security and Encryption
- Non-Relational Storage Quiz5q
- Azure SQL Database Service Tiers
- Azure SQL Managed Instance Design
- Azure Database for MySQL and PostgreSQL
- Database Scaling: Vertical and Horizontal
- Read Replicas and Geo-Replication
- Database Security and Auditing Design
- Transparent Data Encryption and Always Encrypted
- Caching with Azure Cache for Redis
- Azure SQL Elastic Pools Design
- Relational Storage Quiz5q
- Azure Data Factory Design Patterns
- Data Integration Pipeline Architecture
- Azure Synapse Analytics Design
- Azure Databricks Integration Patterns
- Azure Stream Analytics for Real-Time Data
- Azure Event Hubs for Data Ingestion
- Data Migration Strategies and Tools
- Azure Purview for Data Governance
- Data Integration Quiz5q
- Introduction to High Availability in Azure
- Availability Zones and Availability Sets
- Azure Load Balancer Design
- Application Gateway and WAF Design
- Azure Front Door and Global Load Balancing
- Azure Traffic Manager Routing Methods
- Multi-Region Architecture Design
- SLA Design and Composite SLAs
- Health Probes and Failover Configuration
- Azure Service Fabric for Stateful HA
- High Availability Quiz5q
- Azure Backup Architecture and Vaults
- Backup Policies for VMs and Databases
- Azure Site Recovery Design
- RTO and RPO Planning Strategies
- Geo-Redundant and Cross-Region Recovery
- Hybrid and On-Premises Backup Solutions
- Resiliency Patterns and Chaos Engineering
- Disaster Recovery Testing and Drills
- Azure Immutable Backup and Soft Delete
- Backup and Disaster Recovery Quiz5q
- Introduction to Azure Compute Options
- Virtual Machine Design and Sizing
- VM Scale Sets and Autoscaling Strategies
- Azure Batch for Large-Scale Workloads
- Azure App Service Plans and Design
- App Service Environments and Isolation
- Azure Container Instances
- Azure Kubernetes Service Architecture
- AKS Networking and Storage Design
- Azure Functions and Serverless Design
- Durable Functions and Orchestration
- Compute Decision Framework
- Azure Virtual Desktop Design
- Compute Solutions Quiz5q
- Microservices Architecture Patterns
- Azure API Management Design
- Azure Service Bus Messaging Design
- Azure Event Grid and Event-Driven Architecture
- Azure Event Hubs for Streaming
- Azure Logic Apps and Integration Workflows
- Azure SignalR and Web PubSub
- Caching Strategies and Azure CDN
- App Configuration and Feature Flags
- Designing for Scalability and Performance
- Azure Container Apps Design
- Application Architecture Quiz5q
- Virtual Network Design and Address Planning
- Subnet Design and Network Segmentation
- Hub-Spoke Network Topology
- Azure Virtual WAN Design
- VPN Gateway Design and Configuration
- ExpressRoute Circuit Design
- Network Security Groups Design
- Azure Firewall and Firewall Manager
- Azure DDoS Protection Design
- Private Endpoints and Private Link
- Azure DNS and DNS Architecture
- Network Performance and Traffic Routing
- Azure Bastion and Secure Access
- Network Solutions Quiz5q
- Azure Migrate Overview and Assessment
- Migration Assessment and Discovery
- Azure Cloud Adoption Framework for Migration
- VM Migration with Azure Migrate
- Database Migration with Azure DMS
- Application Migration to App Service
- Containerizing Applications for Migration
- Migration Cost Planning and Optimization
- Data Box and Offline Migration Methods
- Migrations Quiz5q
Enjoying the courses?
Everything stays free. Pro shows fewer ads, doubles the points you earn on every lesson and quiz so you progress twice as fast, unlocks half of every practice exam — plus full case studies — with the Learn & Exam study modes, and lets you read each lesson on one page.
- ✓ Fewer advertisements
- ✓ 2× points per lesson & quiz
- ✓ 50% of every exam unlocked
- ✓ Learn & Exam modes
- ✓ Distraction-free lessons