Share via

Azure Policy View Compliance Detail

Tengku Aiman 0 Reputation points
2026-05-05T06:18:11.3333333+00:00

Hello, I want to ask whether it is possible to get this data from Azure Resource Graph

  1. This is the built-in policy from Azure
       
       {
         "properties": {
           "displayName": "Inherit a tag from the resource group",
           "policyType": "BuiltIn",
           "mode": "Indexed",
           "description": "Adds or replaces the specified tag and value from the parent resource group when any resource is created or updated. Existing resources can be remediated by triggering a remediation task.",
           "metadata": {
             "version": "1.0.0",
             "category": "Tags"
           },
           "version": "1.0.0",
           "parameters": {
             "tagName": {
               "type": "String",
               "metadata": {
                 "displayName": "Tag Name",
                 "description": "Name of the tag, such as 'environment'"
               }
             }
           },
           "policyRule": {
             "if": {
               "allOf": [
                 {
                   "field": "[concat('tags[', parameters('tagName'), ']')]",
                   "notEquals": "[resourceGroup().tags[parameters('tagName')]]"
                 },
                 {
                   "value": "[resourceGroup().tags[parameters('tagName')]]",
                   "notEquals": ""
                 }
               ]
             },
             "then": {
               "effect": "modify",
               "details": {
                 "roleDefinitionIds": [
                   "/providers/microsoft.authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"
                 ],
                 "operations": [
                   {
                     "operation": "addOrReplace",
                     "field": "[concat('tags[', parameters('tagName'), ']')]",
                     "value": "[resourceGroup().tags[parameters('tagName')]]"
                   }
                 ]
               }
             }
           }
         },
         "id": "/providers/Microsoft.Authorization/policyDefinitions/cd3aa116-8754-49c9-a813-ad46512ece54/versions/1.0.0",
         "type": "Microsoft.Authorization/policyDefinitions/versions",
         "name": "1.0.0"
       }
    
  2. This is the View Compliance Detail for the Assignments the policy is grouped at policy redacted The questions is:
    1. Is it possible to pull this data using Azure Resource Graph?
Azure Policy
Azure Policy

An Azure service that is used to implement corporate governance and standards at scale for Azure resources.

0 comments No comments

Answer accepted by question author

  1. Siva shunmugam Nadessin 9,625 Reputation points Microsoft External Staff Moderator
    2026-05-05T07:34:04.5333333+00:00

    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

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. kholienchieh 0 Reputation points MVP
    2026-05-06T01:36:48.5466667+00:00

    Have you ever tried to connect the PowerBI tool with Microsoft Graph ?

    https://learn.microsoft.com/en-us/azure/defender-for-cloud/integration-power-bi


  2. Q&A Assist
    2026-05-05T06:18:26.3066667+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    Yes. Azure Policy compliance data, including per-assignment and per-resource compliance state, can be queried through Azure Resource Graph.

    Azure Policy continuously evaluates resources and produces compliance results. These results are exposed in several ways, one of which is Azure Resource Graph queries. The compliance information that appears in the View compliance details blade for a policy assignment is part of this same data set.

    To work with it at scale:

    1. Ensure policy evaluations have run so that compliance state is up to date (policy evaluation cycles are what populate the compliance data).
    2. Use Azure Resource Graph to query the policy compliance resources. From the documentation, Azure Policy compliance data is explicitly listed as one of the ways to access compliance information, alongside the Azure portal, command line, and Azure Monitor logs.

    This allows pulling the same compliance details shown in the portal (for example, which resources are compliant or non-compliant for the built-in policy Inherit a tag from the resource group) via Resource Graph queries.


    References:

Your answer

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