az policy definition version

Manage policy definition versions.

Policy definition versions represent different iterations of a policy definition, allowing changes to be tracked and applied in a controlled and predictable way.

Commands

Name Description Type Status
az policy definition version create

Create a policy definition version.

Core GA
az policy definition version delete

Delete a policy definition version.

Core GA
az policy definition version list

Retrieve policy definition versions.

Core GA
az policy definition version show

Retrieves a policy definition version.

Core GA
az policy definition version update

Update a policy definition version.

Core GA

az policy definition version create

Create a policy definition version.

Create a policy definition version in the given subscription or management group with the given name and other properties.

az policy definition version create --name
                                    --version
                                    [--acquire-policy-token]
                                    [--change-reference]
                                    [--description]
                                    [--display-name]
                                    [--external-evaluation-enforcement-settings --external-settings]
                                    [--management-group]
                                    [--metadata]
                                    [--mode]
                                    [--params]
                                    [--rule --rules]

Examples

Create a policy definition with older version

az policy definition version create --name readOnlyStorage --rules "{ 'if': { 'field': 'type', 'equals': 'Microsoft.Storage/storageAccounts/write' }, 'then': { 'effect': 'deny' } }" --version 1.1.0

Required Parameters

--name -n

The name of the policy definition.

--version

The policy definition version.

Optional Parameters

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--acquire-policy-token

Acquiring an Azure Policy token automatically for this resource operation.

Property Value
Parameter group: Global Policy Arguments
--change-reference

The related change reference ID for this resource operation.

Property Value
Parameter group: Global Policy Arguments
--description

The policy definition description.

Property Value
Parameter group: Properties Arguments
--display-name

The display name of the policy definition.

Property Value
Parameter group: Properties Arguments
--external-evaluation-enforcement-settings --external-settings

The details of the source of external evaluation results required by the policy during enforcement evaluation. Support shorthand-syntax, json-file and yaml-file. Try "??" to show more.

Property Value
Parameter group: Properties Arguments
--management-group

The management group.

--metadata

The policy definition metadata. Support shorthand-syntax(full value only), json-file and yaml-file.

Property Value
Parameter group: Properties Arguments
--mode -m

The policy definition mode.

Property Value
Parameter group: Properties Arguments
Default value: Indexed
--params -p

The policy rule parameter definitions. Support shorthand-syntax, json-file and yaml-file. Try "??" to show more.

Property Value
Parameter group: Properties Arguments
--rule --rules

The policy rule. Support shorthand-syntax(full value only), json-file and yaml-file.

Property Value
Parameter group: Properties Arguments
Global Parameters
--debug

Increase logging verbosity to show all debug logs.

Property Value
Default value: False
--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

Property Value
Default value: False
--output -o

Output format.

Property Value
Default value: json
Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

Property Value
Default value: False

az policy definition version delete

Delete a policy definition version.

Delete the policy definition version in the given subscription or management group with the given name and other properties.

az policy definition version delete --name
                                    --version
                                    [--acquire-policy-token]
                                    [--change-reference]
                                    [--management-group]
                                    [--yes]

Examples

Delete a policy definition version

az policy definition version delete --name ResourceNaming --version 1.2.1

Required Parameters

--name -n

The name of the policy definition.

--version

The policy definition version.

Optional Parameters

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--acquire-policy-token

Acquiring an Azure Policy token automatically for this resource operation.

Property Value
Parameter group: Global Policy Arguments
--change-reference

The related change reference ID for this resource operation.

Property Value
Parameter group: Global Policy Arguments
--management-group

The management group.

--yes -y

Do not prompt for confirmation.

Property Value
Default value: False
Global Parameters
--debug

Increase logging verbosity to show all debug logs.

Property Value
Default value: False
--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

Property Value
Default value: False
--output -o

Output format.

Property Value
Default value: json
Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

Property Value
Default value: False

az policy definition version list

Retrieve policy definition versions.

Retrieve the list of all policy definition versions for a policy definition in the given subscription or management group.

az policy definition version list --name
                                  [--management-group]
                                  [--max-items]
                                  [--next-token]
                                  [--top]

Examples

List policy definition versions by subscription

az policy definition version list --name ResourceNaming

Required Parameters

--name -n

The name of the policy definition.

Optional Parameters

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--management-group

The management group.

--max-items

Total number of items to return in the command's output. If the total number of items available is more than the value specified, a token is provided in the command's output. To resume pagination, provide the token value in --next-token argument of a subsequent command.

Property Value
Parameter group: Pagination Arguments
--next-token

Token to specify where to start paginating. This is the token value from a previously truncated response.

Property Value
Parameter group: Pagination Arguments
--top

Maximum number of records to return. When the $top filter is not provided, it will return 500 records.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

Property Value
Default value: False
--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

Property Value
Default value: False
--output -o

Output format.

Property Value
Default value: json
Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

Property Value
Default value: False

az policy definition version show

Retrieves a policy definition version.

Retrieve and show the details of the policy definition version in the given subscription or management group with the given name and version.

az policy definition version show --name
                                  --version
                                  [--management-group]

Examples

Retrieve a policy definition version

az policy definition version show --name ResourceNaming --version 1.2.1

Required Parameters

--name -n

The name of the policy definition.

--version

The policy definition version.

Optional Parameters

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--management-group

The management group.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

Property Value
Default value: False
--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

Property Value
Default value: False
--output -o

Output format.

Property Value
Default value: json
Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

Property Value
Default value: False

az policy definition version update

Update a policy definition version.

Update the policy definition version in the given subscription or management group with the given name and version by applying the given properties.

az policy definition version update --name
                                    --version
                                    [--acquire-policy-token]
                                    [--add]
                                    [--change-reference]
                                    [--description]
                                    [--display-name]
                                    [--external-evaluation-enforcement-settings --external-settings]
                                    [--force-string {0, 1, f, false, n, no, t, true, y, yes}]
                                    [--management-group]
                                    [--metadata]
                                    [--mode]
                                    [--params]
                                    [--remove]
                                    [--rule --rules]
                                    [--set]

Examples

Update a policy definition version

az policy definition version update -n readOnlyStorage --display-name "Updated display name goes here"

Required Parameters

--name -n

The name of the policy definition.

--version

The policy definition version.

Optional Parameters

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--acquire-policy-token

Acquiring an Azure Policy token automatically for this resource operation.

Property Value
Parameter group: Global Policy Arguments
--add

Add an object to a list of objects by specifying a path and key value pairs. Example: --add property.listProperty <key=value, string or JSON string>.

Property Value
Parameter group: Generic Update Arguments
--change-reference

The related change reference ID for this resource operation.

Property Value
Parameter group: Global Policy Arguments
--description

The policy definition description.

Property Value
Parameter group: Properties Arguments
--display-name

The display name of the policy definition.

Property Value
Parameter group: Properties Arguments
--external-evaluation-enforcement-settings --external-settings

The details of the source of external evaluation results required by the policy during enforcement evaluation. Support shorthand-syntax, json-file and yaml-file. Try "??" to show more.

Property Value
Parameter group: Properties Arguments
--force-string

When using 'set' or 'add', preserve string literals instead of attempting to convert to JSON.

Property Value
Parameter group: Generic Update Arguments
Accepted values: 0, 1, f, false, n, no, t, true, y, yes
--management-group

The management group.

--metadata

The policy definition metadata. Support shorthand-syntax(full value only), json-file and yaml-file.

Property Value
Parameter group: Properties Arguments
--mode -m

The policy definition mode.

Property Value
Parameter group: Properties Arguments
--params -p

The policy rule parameter definitions. Support shorthand-syntax, json-file and yaml-file. Try "??" to show more.

Property Value
Parameter group: Properties Arguments
--remove

Remove a property or an element from a list. Example: --remove property.list <indexToRemove> OR --remove propertyToRemove.

Property Value
Parameter group: Generic Update Arguments
--rule --rules

The policy rule. Support shorthand-syntax(full value only), json-file and yaml-file.

Property Value
Parameter group: Properties Arguments
--set

Update an object by specifying a property path and value to set. Example: --set property1.property2=<value>.

Property Value
Parameter group: Generic Update Arguments
Global Parameters
--debug

Increase logging verbosity to show all debug logs.

Property Value
Default value: False
--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

Property Value
Default value: False
--output -o

Output format.

Property Value
Default value: json
Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

Property Value
Default value: False