How to apply policy initiative Azure

Copper Contributor

Hello Mightly Wizards,


trying to Assign an Azure Policy Initiative via power shell:


step 1: 


New-AzPolicySetDefinition -Name 'DATABASE_OPEN_SOURCE_ID' -ManagementGroupName MGname -DisplayName 'DATABASES OPEN SOURCE' -PolicyDefinition "C:\path\initiatives\DATABASES_-_OPEN_SOURCE\policyset1.json"



note policyset1.json comes from exporting to GitHub Initiative definition and assignment




ew-AzPolicySetDefinition : InvalidRequestContent : The request content was invalid and could not be deserialized: 'Could not find member 'properties' on object of type
'PolicyDefinitionReference'. Path 'properties.policyDefinitions[0].properties', line 7, position 21.'.
CorrelationId: f01ee272-73c1-43b7-99fc-51a67650463a
At line:1 char:1
+ New-AzPolicySetDefinition -Name 'DATABASE_OPEN_SOURCE_ID' -Management ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzPolicySetDefinition], ErrorResponseMessageException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzurePolicySetDefinitionCmdlet


First question. How does this file have to be formatted? can you give me an example?


Second question how to assign this definition? With New-AzPolicyAssignment?


Thank you in advance for yout reply.



0 Replies