Steps to Export Definitions in an Initiative Policy

Step 1: Open Azure Portal

Step 2: Access Azure Resource Graph Explorer from Azure global search

Step 3: Select the desired scope of your selection

Step 4: Add the following KQL Azure Resource Graph Explorer

policyresources
| where type =~ 'Microsoft.Authorization/PolicySetDefinitions'
| where name == "add custom policy definition name or id"
| extend policysetDefId = tolower(id)
| extend policyDefinitions = properties.policyDefinitions
| mv-expand policyDefinition = policyDefinitions limit 400
| extend policyDefinitionId = tolower(policyDefinition.policyDefinitionId)
| extend policyDefinitionReferenceId = policyDefinition.policyDefinitionReferenceId
| extend groupNames = policyDefinition.groupNames
| parse policyDefinitionId with "/providers/microsoft.authorization/policydefinitions/" policyId
| project policyDefinitionReferenceId, groupNames, policyId, policyDefinitionId

This query will list all Azure Policy definitions that are part of an Azure Policy initiative. We are filtering the following details to export the list.

  • Policy Definition Reference Id
  • Policy Group Name
  • Policy Id
  • Policy Definition Id

To list Policy Definition Reference Parameters use the following query:

policyresources
| where type =~ 'Microsoft.Authorization/PolicySetDefinitions'
| where name == "add custom policy definition name or id"
| extend policysetDefId = tolower(id)
| extend policyDefinitions = properties.policyDefinitions
| mv-expand policyDefinition = policyDefinitions limit 400
| extend policyDefinitionId = tolower(policyDefinition.policyDefinitionId)
| extend policyDefinitionReferenceId = policyDefinition.policyDefinitionReferenceId
| extend policyDefinitionReferenceParameters = policyDefinition.parameters
| extend groupNames = policyDefinition.groupNames
| parse policyDefinitionId with "/providers/microsoft.authorization/policydefinitions/" policyId
| project policyDefinitionReferenceId, policyDefinitionReferenceParameters, groupNames, policyId, policyDefinitionId

With this query you can get the details of

  • Policy Definition Reference Id
  • Policy Definition Reference Parameters
  • Policy Group Name
  • Policy Id
  • Policy Definition Id

To download the results click on Download as CSV.

Sample Output:

That’s it! These are the simple steps to to Export Definitions in an Azure Initiative Policy to CSV File. You can follow the same steps to export other policy definitions. I have linked the reference for Azure Policy Initiative for Knowledge base. I hope this helps! Happy Learning.

How to Export Definitions in an Azure Initiative Policy to CSV File?

An Azure Policy Initiative Definition is a collection of Azure Policy definitions that are grouped together. Here in this article, we will show how to export Azure policy definitions that are listed in an Azure policy initiative. We will be using the Azure Resource Graph KQL query to export the Azure Policy definitions that are grouped together in an Azure Policy initiative. This is the base KQL query that will be used it export Definitions in an Azure Initiative Policy.

policyresources
| where type =~ 'Microsoft.Authorization/PolicySetDefinitions'
| where name == "add custom policy definition id"

Similar Reads

Steps to Export Definitions in an Initiative Policy

Step 1: Open Azure Portal...

Frequently Asked Questions

1. Is there a direct option to export Definitions in an Azure Initiative Policy to CSV File in Azure Portal?...

Also, Read

Microsoft Azure – Create a Custom Policy Initiative in Azure Microsoft Azure – Creating JSON Snippet For Policy Initiative Creation using CSV File Microsoft Azure – Creating Custom Policy Initiative using PowerShell Microsoft Azure – Export Policy Assignments...