az tag

Tag Management on a resource.

Commands

az tag add-value

Create a tag value.

az tag create

Create tags on a specific resource.

az tag delete

Delete tags on a specific resource.

az tag list

List the entire set of tags on a specific resource.

az tag remove-value

Deletes a predefined tag value for a predefined tag name.

az tag update

Selectively update the set of tags on a specific resource.

az tag add-value

Create a tag value.

az tag add-value --name
                 --value
                 [--subscription]

Examples

Create a tag value.

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

Required Parameters

--name -n

The tag name.

--value

The tag value.

Optional Parameters

--subscription

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

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.

az tag create [--name]
              [--resource-id]
              [--subscription]
              [--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.

--subscription

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

--tags

The tags to be applied on the resource.

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]
              [--subscription]
              [--yes]

Examples

Delete a tag from the subscription.

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.

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.

--subscription

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

--yes -y

Do not prompt for confirmation.

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 [--query-examples]
            [--resource-id]
            [--subscription]

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

--query-examples

Recommend JMESPath string for you. You can copy one of the query and paste it after --query parameter within double quotation marks to see the results. You can add one or more positional keywords so that we can give suggestions based on these key words.

--resource-id

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

--subscription

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

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
                    [--subscription]

Required Parameters

--name -n

The tag name.

--value

The tag value.

Optional Parameters

--subscription

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

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
              [--subscription]

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.

Optional Parameters

--subscription

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