Create an Azure Policy definition with DeployIfNotExists effect and trigger a remediation task

domain: learn.microsoft.com/azure/governance/policy · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Author a policy definition JSON with `policyRule.then.effect: DeployIfNotExists` and a `details.deployment` block that contains the ARM template to deploy when the condition is not met.
  2. Assign the policy at the desired scope (subscription or management group) using `az policy assignment create --policy <definition-id> --scope <scope> --assign-identity --location <region>`; the `--assign-identity` flag creates a managed identity for remediation.
  3. Grant the managed identity the required RBAC role (e.g., Contributor) on the target scope so it can deploy the remediation ARM template.
  4. Verify non-compliant resources in the Azure Portal under Policy > Compliance or via `az policy state list --policy-assignment <assignment-id> --filter "complianceState eq 'NonCompliant'"`.
  5. Start a remediation task with `az policy remediation create --name <NAME> --policy-assignment <assignment-id> --resource-discovery-mode ReEvaluateCompliance`; `ReEvaluateCompliance` re-evaluates all resources before selecting targets.
  6. Monitor remediation progress with `az policy remediation show --name <NAME>` until `provisioningState` reaches `Succeeded`.

Known gotchas

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans