How to provide an array value to az policy definition create --metadata

MyTestAcct3564 0 Reputation points
2024-07-09T18:44:42.24+00:00

When I create a policy definition using the portal with category "Guest Configuration", the resulting policy definition correctly includes "requiredProviders": ["Microsoft.GuestConfiguration"] in the metadata section.

I am unable to recreate the same using Azure CLI, specifically az policy definition create ... --metadata .... I have tried a number of variations with different quoting schemes, including brackets in the value, not including brackets in the value, using a bash list, etc., but these all result in a policy definition where requiredProviders is some flavor of string, not an array.

So far I have not found any examples online of someone getting az policy definition create --metadata to result in an array in the resulting policy definition.

Note that I am not talking about passing multiple metadata key-value pairs. That is easily done with space delimiting. I am talking about a single KVP where the value is an array.

Azure Policy
Azure Policy
An Azure service that is used to implement corporate governance and standards at scale for Azure resources.
824 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Stanislav Zhelyazkov 22,021 Reputation points MVP
    2024-07-10T07:49:33.5+00:00

    Hi,

    This must be some limit in Az CLI so I would advise to raise a support case to Microsoft. Otherwise you can try to use Azure Bicep template to deploy the policy definition. You could do the deployment of the template by using Az CLI.

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

    0 comments No comments