Azure Custom Policy - Programmatic Deployment Help / Problem

Hamid 1 Reputation point
2020-06-03T09:47:44.66+00:00

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
Azure Policy
An Azure service that is used to implement corporate governance and standards at scale for Azure resources.
916 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Kenieva-MSFT 161 Reputation points Microsoft Employee
    2020-06-04T22:41:14.557+00:00

    Hi @Hamid ,

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

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.