Azure Policy Denies Workload¶
Symptom¶
A deployment, StatefulSet, Job, or Pod admission request fails with an Azure Policy or Gatekeeper denial message even though the workload previously deployed or appears valid to the application team.
Possible Causes¶
- The assignment effect was changed from
audittodeny. - The workload violates a built-in initiative such as baseline or restricted pod security.
- The assignment scope now includes this cluster or namespace when it did not before.
- Expected namespace exclusions were never configured or were removed.
- A custom Gatekeeper-backed constraint has stricter logic than the team expects.
Diagnosis Steps¶
flowchart TD
A[Workload denied by Azure Policy] --> B[Capture full deny message]
B --> C[Identify policy assignment and constraint]
C --> D{Scope or exclusion changed?}
D -->|Yes| E[Fix assignment scope or exclusions]
D -->|No| F{Manifest truly noncompliant?}
F -->|Yes| G[Remediate workload spec]
F -->|No| H[Use audit or disabled mode for safe rollout testing] -
Capture the exact error text from
kubectl applyor the controller event. -
Inspect the related workload events.
-
List constraint templates to confirm Azure Policy objects are present.
-
Inspect the failing constraint object and look for Azure Policy annotations.
-
In Azure Policy, confirm:
- assignment scope,
- assignment effect,
- namespace exclusions,
- whether the definition is built-in or custom.
-
If the deny started during rollout, compare whether the assignment should temporarily be
auditordisabledwhile the team fixes manifests.
Resolution¶
- Fix the manifest if the workload is genuinely violating the intended policy.
- Restore or add namespace exclusions only when the exception is approved and time-bound.
- Narrow assignment scope if the cluster or resource group was included by mistake.
- Move a new policy assignment back to
auditordisabledwhen the problem is rollout sequencing rather than workload risk. - Correct or retest custom constraint logic if the deny reason does not match intended policy semantics.
Prevention¶
- Roll out new initiatives in
auditbeforedeny. - Track exclusions with owner, expiry, and removal plan.
- Keep one inventory of built-in versus custom constraints applied to each cluster.
- Require platform review for scope expansion at subscription or management-group level.