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

Examples

Create a tag value.

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

Required Parameters

--name -n

The tag name.

--value

The tag value.

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.

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 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.

--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 [--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.

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.

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.