An Azure service that is used to implement corporate governance and standards at scale for Azure resources.
Hello Tengku Aiman
Thank you for reaching out to the Microsoft Q&A forum.
When investigated you can absolutely pull policy‐compliance data out of Azure Resource Graph – at least the high-level stuff (which resources are compliant vs. non-compliant, when they were last evaluated, which assignment/definition they belong to, etc.). What you can’t get via Resource Graph is the deep “Compliance details” pane (the per-setting or per-field “Current value” vs. “Target value” info). For that, you’d need to call the Policy Insights APIs (or use az policy state list / PowerShell) instead.
Here’s a quick sample ARG query to list all non-compliant resources for a given assignment:
// Replace with your real assignment ID:
let assignmentId = '/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/policyAssignments/InheritTagRG';
policyresources
| where properties.policyAssignmentId == assignmentId
and properties.complianceState == 'NonCompliant'
| extend
resourceId = properties.resourceId,
resourceType = tostring(split(properties.resourceId, '/')[6])
+ '/' + tostring(split(properties.resourceId, '/')[7]),
location = properties.resourceLocation,
lastEvaluated = properties.timestamp
| project resourceId, resourceType, location, lastEvaluated
If you need the extra “Compliance reason” details (fields, current value, target value), switch over to the Policy Insights REST API or CLI:
az policy state list \
--assignment '/subscriptions/…/providers/Microsoft.Authorization/policyAssignments/InheritTagRG' \
--filter "complianceState eq 'NonCompliant'" \
--query "[].{resource:resourceId, reason:complianceReason, details:policyDefinitionAction}" \
--output table
Let me know if any further queries - feel free to reach out!
References
Get compliance data in Portal & ARG samples: https://learn.microsoft.com/azure/governance/policy/how-to/get-compliance-data
Export compliance with Azure Resource Graph: https://learn.microsoft.com/azure/governance/policy/samples/resource-graph-samples
Policy Insights REST API (detailed compliance): https://learn.microsoft.com/azure/governance/policy/concepts/policy-insights-rest-api
az policy state list docs: https://learn.microsoft.com/cli/azure/policy/state#az-policy-state-list