Azure-docs: Executing policy template failed

Created on 15 Aug 2018  Â·  3Comments  Â·  Source: MicrosoftDocs/azure-docs

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


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

azure-policsvc cxp product-issue triaged

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

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JeffLoo-ong picture JeffLoo-ong  Â·  3Comments

bityob picture bityob  Â·  3Comments

bdcoder2 picture bdcoder2  Â·  3Comments

JamesDLD picture JamesDLD  Â·  3Comments

AronT-TLV picture AronT-TLV  Â·  3Comments