Introduction
Azure Policy is one of the core governance services in Azure that helps organisations enforce standards, maintain security, and ensure regulatory compliance across their environments.
Unlike Azure RBAC, which controls who can perform an action, Azure Policy controls what can be deployed or configured within Azure. By default, Azure Policy is resource-focused and evaluates every deployment the same way, regardless of who performs it. However, identity-based exemptions allow specific users or service principals to be exempted, as this blog explains.
Challenge
Modern cloud environments rely heavily on automation for resource deployments. Most deployments are performed by service principals rather than interactive users.
Common examples include:
- CI/CD pipelines
- Infrastructure as Code (ARM templates, Bicep, or Terraform)
- Azure DevOps and GitHub Actions workflows
- Automation scripts and platform integrations
In some situations, these automated deployments may fail with an error similar to:
The resource operation was disallowed by one or more Azure Policy assignments.
The deployment fails because the resource being created or modified does not comply with the assigned Azure Policy.
A common question from administrators is: "This is our approved automation identity. Can we exempt this Service Principal from Azure Policy so that it can complete the deployment?"
Solution:
Azure Policy Exemptions provide a mechanism to create exemptions for the required identities where specific policy assignments should not be enforced. This scenario can be addressed by creating an identity-based exemption in Azure Policy for the policy assignment and configuring Resource selectors within the exemption structure.
When a service principal, managed identity or user needs to deploy resources that would otherwise be blocked by an Azure Policy assignment, you can create a policy exemption against the initiative or policy assignment and use Resource selectors to target that identity. This approach allows organisations to maintain governance controls while accommodating approved operational exceptions.
Creating an Identity-Based Policy Exemption
To configure the exemption:
- Navigate to Azure Policy in the Azure portal.
- Select Exemptions.
- Create a new exemption.
- Choose the applicable policy or initiative assignment.
- Under Resource Selectors, select Add Resource Selector.
- Specify the Service Principal's Object ID (Principal ID).
Toggle the resource selector ‘userPrincipalId’, select the ‘in’ operator and give the principal Id value.
You can provide one or more principal IDs, for example:
["11111111-2222-3333-4444-555555555555", "a1b2c3d4-e5f6-7890-abcd-ef1234567xxx","f47ac10b-58cc-4372-a567-0e02b2c3xxxx"]
An in list can contain up to 50 values
- To exempt a security group, add its Object ID to the groupPrincipalId resource selector.
- Save the exemption.
Once configured, the exemption allows approved scenarios to bypass the selected policy assignment without requiring the policy itself to be modified or removed.
Important Considerations:
Before implementing this approach, consider the following:
- Exemptions should be used sparingly and only for approved business scenarios.
- Document the reason for each exemption.
- Define an expiration date whenever possible.
- Regularly review existing exemptions as part of governance audits.
- Prefer fixing deployment configurations over creating permanent exemptions.
Best Practices:
Instead of broadly exempting automation identities, consider whether:
- The deployment template can be updated to comply with policy.
- The policy scope can be refined.
- A temporary exemption can be used during migration or onboarding activities.
Maintaining strong governance while allowing controlled exceptions helps organisations balance agility and compliance.
Conclusion:
By default, Azure Policy enforces organisational standards regardless of who performs the deployment. When approved service principals, managed identities or users require exceptions, Policy Exemptions provide a governed and auditable mechanism to accommodate those scenarios without weakening overall security and compliance controls.
By combining Azure Policy Exemptions with proper governance processes, organisations can support automation at scale while maintaining compliance across their Azure environments.
Note: Always validate the behaviour in a non-production environment before implementation.
References:
Details of the policy exemption structure - Azure Policy | Microsoft Learn