Hi all,
just for testing, I wanted to execute the following policy definition described in this doc ->
{
"policyRule": {
"if": {
"allOf": [{
"field": "type",
"equals": "Microsoft.Compute/virtualMachines"
},
{
"field": "Microsoft.Compute/virtualMachines/sku.name",
"like": "Standard_G*"
}
]
},
"then": {
"effect": "deny"
}
}
}
I saved this template as json and executed it with powershell command "New-AzureRmPolicyDefinition". Unfortunately, it didn't work. I got this error-message:
"InvalidPolicyRule : Failed to parse policy rule: 'Could not find member 'policyRule' on object of type 'PolicyRule'. Path 'policyRule'.'.
At line:1 char:1"
Do you know what I'm doing wrong?
Thank you very much!
nnamedieh
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
This example is for use in the Azure Portal - the JSON is invalid when using this as input for PowerShell. Check out the example at https://docs.microsoft.com/en-au/azure/azure-policy/policy-insights for valid JSON
Ah, didn't know! Thank you :)
Thanks for the response @anwather.
@nnamedieh we will now close this issue, please don't hesitate to ping if you have any followup questions.
Most helpful comment
This example is for use in the Azure Portal - the JSON is invalid when using this as input for PowerShell. Check out the example at https://docs.microsoft.com/en-au/azure/azure-policy/policy-insights for valid JSON