This design implements Azure Policy to enforce compliance (e.g., "Only deploy in East US", "Require Tags").
Topology: Policies are assigned at the Management Group or Subscription level, affecting all Hub and Spoke resources.
+---------------------------------------------------------+
| Root Management Group (Tenant Root) |
| |
| +-------------------------------------------------+ |
| | Corp Management Group | |
| | [Policy: Allowed Locations = East US, West US] | |
| | | |
| | +-----------------------+ | |
| | | Subscription: Prod | | |
| | | (Inherits Policy) | | |
| | | | | |
| | | +---------------+ | | |
| | | | Hub VNet | | | |
| | | +---------------+ | | |
| | +-----------------------+ | |
| +-------------------------------------------------+ |
+---------------------------------------------------------+
+-----------------------------------------------------------------------+
| Policy Definition: Require-SQL-Encryption |
| JSON Rule: "If type is SQL and Encryption is Off -> Deny" |
+-----------------------------------|-----------------------------------+
|
v
+-----------------------------------|-----------------------------------+
| Assignment: Assign-SQL-Enc-Prod |
| Scope: /providers/Microsoft.Management/managementGroups/Corp |
| Parameters: None |
+-----------------------------------|-----------------------------------+
|
v
+-----------------------------------|-----------------------------------+
| Compliance Scan | |
| Result: | |
| - vm-hub (Compliant) | |
| - sql-spoke (Non-Compliant) | |
+-----------------------------------|-----------------------------------+
rg-legacy) if they cannot comply yet.1. User: Runs az vm create --location japanwest.
2. ARM: Azure Resource Manager receives request.
3. Policy Engine: Checks "Allowed Locations" policy.
4. Match: japanwest is NOT in [East US, West US].
5. Deny: ARM rejects the request.
6. Output: "Deployment failed due to Policy violation."
1. Search: "Policy" -> Definitions.
2. + Policy definition.
3. Definition location: Select your Management Group (e.g., Corp) or Subscription.
4. Name: Audit-Storage-Public-Access.
5. Category: Storage.
6. Policy Rule:
* Paste the JSON rule (or select "Use existing" and find "Storage accounts should disable public network access").
* *Tip: Using built-in policies is safer.*
7. Save.
1. Go to Assignments -> Assign policy.
2. Basics:
* Scope: Select Subscription: Production.
* Policy definition: Select Audit-Storage-Public-Access.
* Assignment name: Enforce-Secure-Storage.
3. Parameters:
* Effect: Audit (Start with Audit) or Deny (Block new deployments).
4. Remediation:
* Uncheck "Create a Managed Identity" (unless using DeployIfNotExists).
5. Review + create -> Create.
1. Wait 30 minutes (Policy evaluation cycle).
2. Go to Compliance (Left Menu).
3. Find Enforce-Secure-Storage.
4. Status:
* Compliant: All storage accounts have public access disabled.
* Non-compliant: Click to see which accounts are violating the rule.
1. If you have non-compliant resources, click Create Remediation Task.
2. Azure will attempt to modify the resources (if the policy supports Modify or DeployIfNotExists) to fix the setting.
* *Note: Deny policies do not remediate existing resources; they only block new ones.*