What is the preferred way to do ongoing Azure Policy remediations?

Eric Burgueño 20 Reputation points
2025-03-17T11:37:06.23+00:00

I know remediations tasks only run once, and one can create multiple tasks over time to bring resources back into compliance.

Is there any preferred pattern to automate this? The docs mention routing state changes to Azure Event Grid, but I wondered if that's a common approach.

Azure Policy
Azure Policy
An Azure service that is used to implement corporate governance and standards at scale for Azure resources.
992 questions
0 comments No comments
{count} votes

Accepted answer
  1. Stanislav Zhelyazkov 27,321 Reputation points MVP
    2025-03-18T14:13:47.54+00:00

    Hi,

    In order to answer this question we need to mention that there are different effects that can be used in Azure Policy. Effects like audit, auditIfNotExists, deny, denyAction, disabled and manual do not have remediation capability. So if you have non-compliant resources via those you will need to remediate manually without having the option to execute task. Remediation tasks are available for deployIfNotExists and modify. In general you might not need to use remediation for those effects at all. The reason for that is that these effects will apply when resource is deployed thus the actual action behind these policies will execute. That is the same action if you create remediation task. So in general you will have non-compliant resource for these policies only if the policies were deployed after the resource creation, the policy was not enforced, resources were exempted/excluded or the policy had some bug and it was not applied appropriate to all resources in its scope. The role of remediation tasks is to be able to remediate in any of those scenarios rather run them on regular bases like daily for example. In any case if you want to automate something around policies and their compliance state you can choose to initiate such automation via Azure Event Grid as you have already mentioned or use Log Alerts. The Azure Policy compliance data is available in Resource Graph. Log Alerts can use data from ARG. You can even use other automation tools like Azure Automation Runbooks, Logic Apps, Azure Functions, etc. that query ARG data. In summary you have many different methods that you can use to automate depending on your requirements.

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.