Azure-docs: New-AzureRmPolicyDefinition - category

Created on 14 Nov 2018  Â·  6Comments  Â·  Source: MicrosoftDocs/azure-docs

How to set policy Category for policy definition using New-AzureRmPolicyDefinition cmdlet?


Document Details

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

assigned-to-author azure-policsvc in-progress product-question triaged

Most helpful comment

Yes, with category in lower-case it works. Thx!

All 6 comments

@JozoSlejko That's something that would typically be in the cmdlet reference page (https://docs.microsoft.com/powershell/module/azurerm.resources/new-azurermpolicydefinition). I believe that Category is passed through the Metadata parameter, but will validate with engineering. I'll also ask if they can add an example for metadata to include category. Thanks for the feedback!

@MicrosoftDocs/azure-cxp-triage Please assign to me, label 'product-question', and #in-progress

@JozoSlejko Got confirmation, Category can be used with Metadata. Metadata takes a string, but that string is JSON that contains the property key/value pairs. So, something like this:

-Metadata '{"Category":"Virtual Machine"}'

We'll get the ref content updated with an example to cover using Metadata like this that includes Category. Thanks again for the feedback!

@MicrosoftDocs/azure-cxp-triage #please-close

Azure/azure-powershell#7829 Here's the link to the PR to update the example in the ref content.

If i use the example (_New-AzureRmPolicyDefinition -Name 'VMPolicyDefinition' -Metadata '{"Category":"Virtual Machine"}' -Policy '{"if":{"source":"action","equals":"Microsoft.Compute/virtualMachines/write"},"then":{"effect":"deny"}}'_) to create a policy, the Category is still empty:
image

@Obiwan72 The issue appears to be that 'category' is case-sensitive within the Portal UX. Please use all lower-case 'category' and validate that solves the issue for you of it not showing up in Portal UX.

Yes, with category in lower-case it works. Thx!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jebeld17 picture jebeld17  Â·  3Comments

AronT-TLV picture AronT-TLV  Â·  3Comments

varma31 picture varma31  Â·  3Comments

ianpowell2017 picture ianpowell2017  Â·  3Comments

behnam89 picture behnam89  Â·  3Comments