LinuxCommandLibrary

az-tag

Manage Azure resource tags

TLDR

Create a tag value

$ az tag add-value --name [tag_name] --value [tag_value]
copy

Create a tag in the subscription
$ az tag create --name [tag_name]
copy

Delete a tag from the subscription
$ az tag delete --name [tag_name]
copy

List all tags on a subscription
$ az tag list --resource-id /subscriptions/[subscription_id]
copy

Delete a tag value for a specific tag name
$ az tag remove-value --name [tag_name] --value [tag_value]
copy

SYNOPSIS

az tag create|delete|list|update --name {name} --value {value} --resource-id {resource-id} [optional parameters]

PARAMETERS

--name {name}
    The name of the tag.

--value {value}
    The value of the tag.

--resource-id {resource-id}
    The ID of the resource to tag. This could be a resource, resource group, or subscription.

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

--resource-group {resource-group}
    The resource group name.

--operation {operation}
    Type of operation to perform. Can be 'create', 'update', 'delete', or 'list'.

DESCRIPTION

The `az tag` command in the Azure CLI allows you to manage Azure Resource Manager tags. Tags are key-value pairs that you can apply to your Azure resources, resource groups, and subscriptions to logically organize them into a taxonomy. This command lets you create, update, list, and delete tags. Using `az tag`, you can easily query and manage your resources based on their assigned tags, which is helpful for billing, management, and automation. It provides functionalities like creating tags at different scopes (subscription, resource group, or individual resource), updating existing tags (either replacing them entirely or merging new tags), listing all tags within a scope, and deleting specific tags or tag sets. Tagging helps in better resource organization and provides a powerful metadata mechanism for managing Azure infrastructure. This command enables users to assign metadata to Azure resources for better organization, billing, and automation.

CAVEATS

Using incorrect resource IDs will result in errors. Be sure to use the correct scope when applying tags.

EXAMPLES

Example 1: Create a tag on a resource:
`az tag create --resource-id /subscriptions/{subscriptionId}/resourcegroups/{resourceGroup}/providers/{providerNamespace}/{resourceType}/{resourceName} --tags key1=value1 key2=value2`

Example 2: List all tags in a subscription:
`az tag list --subscription {subscriptionId}`

SEE ALSO

az resource(1), az group(1), az account(1)

Copied to clipboard