Need to query specific azure policy compliance using resource graph query

Shinde, Balaji 116 Reputation points
2023-03-13T04:53:31.33+00:00

Hi All,

We have two policy initiatives "Deploy Windows Azure Monitor Agent with user-assigned managed identity-based auth and associate with Data Collection Rule" and "Deploy Linux Azure Monitor Agent with user-assigned managed identity-based auth and associate with Data Collection Rule" assinged to per subscription. Now I want to query compliance state of these two policy for each subscription assignment.

When I am using below query to search for keyword "Monitor" in policysetdefinition, its not returing me any results, Note: When I am using keywork "Paas" to query other policy definition, its working fine.

so what are the other ways I can use to get these two policy compliance report.

PolicyResources
| join kind=leftouter (ResourceContainers | where type=='microsoft.resources/subscriptions' | project SubName=name, subscriptionId) on subscriptionId
| where type == 'microsoft.policyinsights/policystates'
| where properties.policySetDefinitionName contains "Monitor"
| extend complianceState = tostring(properties.complianceState)
| summarize count() by SubName, complianceState
Azure Policy
Azure Policy
An Azure service that is used to implement corporate governance and standards at scale for Azure resources.
833 questions
{count} votes