Share via


az tag

Tag Management on a resource.

Commands

Name Description Type Status
az tag add-value

Create a tag value.

Core GA
az tag create

Create tags on a specific resource.

Core GA
az tag delete

Delete tags on a specific resource.

Core GA
az tag list

List the entire set of tags on a specific resource.

Core GA
az tag remove-value

Deletes a predefined tag value for a predefined tag name.

Core GA
az tag update

Selectively update the set of tags on a specific resource.

Core GA

az tag add-value

Create a tag value.

az tag add-value --name
                 --value

Examples

Create a tag value.

az tag add-value --name MyTag --value MyValue

Required Parameters

--name -n

The tag name.

--value

The tag value.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--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.

az tag create

Create tags on a specific resource.

The az tag create command with an id creates or updates the entire set of tags on a resource, resource group or subscription. This operation allows adding or replacing the entire set of tags on the specified resource, resource group or subscription. The specified entity can have a maximum of 50 tags. Please note: 'tag create' acts like a 'tag init' hence tags created with this command are the only ones being present after execution.

az tag create [--name]
              [--resource-id]
              [--tags]

Examples

Create a tag in the subscription.

az tag create --name MyTag

Create or update the entire set of tags on a subscription.

az tag create --resource-id /subscriptions/{subId} --tags Dept=Finance Status=Normal

Create or update the entire set of tags on a resource group.

az tag create --resource-id /subscriptions/{sub-id}/resourcegroups/{rg} --tags Dept=Finance Status=Normal

Create or update the entire set of tags on a resource.

az tag create --resource-id /subscriptions/{sub-id}/resourcegroups/{rg}/providers/Microsoft.Compute/virtualMachines/{vmName} --tags Dept=Finance Status=Normal

Optional Parameters

--name -n

The name of the tag to create.

--resource-id

The resource identifier for the entity being tagged. A resource, a resource group or a subscription may be tagged.

--tags

The tags to be applied on the resource.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--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.

az tag delete

Delete tags on a specific resource.

The az tag delete command with an id deletes the entire set of tags on a resource, resource group or subscription.

az tag delete [--name]
              [--resource-id]
              [--yes]

Examples

Delete a predefined tag from the subscription not associated with a resource or having no tag values.

az tag delete --name MyTag

Delete the entire set of tags on a subscription.

az tag delete --resource-id /subscriptions/{sub-id}

Delete the entire set of tags on a resource group.

az tag delete --resource-id /subscriptions/{sub-id}/resourcegroups/{rg}

Delete the entire set of tags on a resource. (Even using --name along with --resource-id to specify a single tag)

az tag delete --resource-id /subscriptions/{sub-id}/resourcegroups/{rg}/providers/Microsoft.Compute/virtualMachines/{vmName}

Optional Parameters

--name -n

The name of the tag to be deleted.

--resource-id

The resource identifier for the entity being tagged. A resource, a resource group or a subscription may be tagged.

--yes -y

Do not prompt for confirmation.

Default value: False
Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--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.

az tag list

List the entire set of tags on a specific resource.

The az tag list command with an id lists the entire set of tags on a resource, resource group or subscription.

az tag list [--resource-id]

Examples

List the entire set of tags on a subscription.

az tag list --resource-id /subscriptions/{sub-id}

List the entire set of tags on a resource group.

az tag list --resource-id /subscriptions/{sub-id}/resourcegroups/{rg}

List the entire set of tags on a resource.

az tag list --resource-id /subscriptions/{sub-id}/resourcegroups/{rg}/providers/Microsoft.Compute/virtualMachines/{vmName}

Optional Parameters

--resource-id

The resource identifier for the entity being tagged. A resource, a resource group or a subscription may be tagged.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--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.

az tag remove-value

Deletes a predefined tag value for a predefined tag name.

This operation allows deleting a value from the list of predefined values for an existing predefined tag name. The value being deleted must not be in use as a tag value for the given tag name for any resource.

az tag remove-value --name
                    --value

Required Parameters

--name -n

The tag name.

--value

The tag value.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--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.

az tag update

Selectively update the set of tags on a specific resource.

The az tag update command with an id selectively updates the set of tags on a resource, resource group or subscription. This operation allows replacing, merging or selectively deleting tags on the specified resource, resource group or subscription. The specified entity can have a maximum of 50 tags at the end of the operation. The 'replace' option replaces the entire set of existing tags with a new set. The 'merge' option allows adding tags with new names and updating the values of tags with existing names. The 'delete' option allows selectively deleting tags based on given names or name/value pairs.

az tag update --operation {Delete, Merge, Replace}
              --resource-id
              --tags

Examples

Selectively update the set of tags on a subscription with "merge" Operation.

az tag update --resource-id /subscriptions/{sub-id} --operation merge --tags key1=value1 key3=value3

Selectively update the set of tags on a resource group with "replace" Operation.

az tag update --resource-id /subscriptions/{sub-id}/resourcegroups/{rg} --operation replace --tags key1=value1 key3=value3

Selectively update the set of tags on a resource with "delete" Operation.

az tag update --resource-id /subscriptions/{sub-id}/resourcegroups/{rg}/providers/Microsoft.Compute/virtualMachines/{vmName} --operation delete --tags key1=value1

Required Parameters

--operation

The update operation. Options are Merge, Replace and Delete.

Accepted values: Delete, Merge, Replace
--resource-id

The resource identifier for the entity being tagged. A resource, a resource group or a subscription may be tagged.

--tags

The tags to be updated on the resource.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--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.