Azure Resource Graph (ARG) Query to List All Failed Policy Deployments

Adin Ermie 0 Reputation points
2025-02-07T17:18:21.59+00:00

When using Azure Policy, in particular a policy with Deploy If Not Exist (DINE), naturally the policy will try to remediate anything that doesn't align to the policy definition.

However, if there is something that prevents the Policy Deployment from executing properly, the Resource Group's Deployments will show a Status of Failed.

User's image

This is different than an error when actually remediating, or something being non-compliant.

I want to create an Azure Resource Graph (ARG) query that will list all of the Resource Groups that have any "Failed" deployments, where Deployment Name contains PolicyDeployment_.

I've used something like the following, but this doesn't seem to find the actual failed policy deployments. I tried cross-referencing for similar ways to use Azure Activity Logs as well.

resourcecontainers
| where type == "microsoft.resources/subscriptions/resourcegroups"
| project subscriptionId, resourceGroup=name, location, tostring(properties['provisioningState'])

Any ideas would be appreciated.

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

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.