question

Hamid-4764 avatar image
0 Votes"
Hamid-4764 asked azure-cxp-api edited

Azure Custom Policy - Programmatic Deployment Help / Problem

Hi,

I am looking for some assistance with deploying a custom Azure Policy.
I have authored a policy and am able to deploy via the portal, but when I attempt to deploy via CLI I am getting the following error:
Failed to parse policy rule: 'Could not find member 'properties' on object of type 'PolicyRuleDefinition'. Path 'properties'.'.

The command used is below:

az policy definition create --name "deploy-networkwatcher-extension-windows" --display-name "Deploy Network Watcher Extension Agent" --description "This policy deploys the Azure Network Watcher Extension on Windows VMs." --rules "policy.json" --mode all


Looking at the examples/samples I did not that authors were using a rules.json that did not include properties. I tried creating one myself but this didnt work either, so I am stuck in understanding my error.

I have attached a copy of my policy and rules json files. I would appreciate if someone could review and advise on my mistake.

8949-policy-copyjson.txt


8950-rules-copyjson.txt


azure-policy
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

KenievaMSFT-5537 avatar image
0 Votes"
KenievaMSFT-5537 answered

Hi @Hamid-4764,

When doing CLI --rule the json should only encompass the policy rule. Example can be found here: https://docs.microsoft.com/en-us/cli/azure/policy/definition?view=azure-cli-latest#az-policy-definition-create

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.