LinuxCommandLibrary

az-tag

Manage Azure resource tags

TLDR

Create a tag value

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

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

Delete a tag from the subscription
$ az tag delete [[-n|--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 [[-n|--name]] [tag_name] --value [tag_value]
copy

SYNOPSIS

az tag create|delete|list [--resource-id] [--tags] [--tag] [--subscription] [--output {json,jsonc,table,tsv,yaml}]

PARAMETERS

--resource-id, -i
    ID of the target Azure resource (e.g., /subscriptions/{sub}/resourceGroups/{rg}/providers/...)

--tags
    Space-separated tags in 'key[=value]' format for create subcommand

--tag
    Single tag key to delete

--subscription
    Name or ID of Azure subscription

--output (-o)
    Output format: json, jsonc, table, tsv, yaml

--query
    JMESPath query string for output filtering

--debug
    Increase logging verbosity for troubleshooting

--help (-h)
    Show help for command or subcommand

DESCRIPTION

The az tag command is part of the Azure Command-Line Interface (CLI), a cross-platform toolset for managing Azure resources from Linux, macOS, or Windows. It provides subcommands to create, delete, and list tags, which are customizable key-value pairs attached to Azure resources for organization, cost allocation, automation, and policy enforcement.

Tags enable logical grouping across resource types (e.g., VMs, storage accounts) without affecting runtime. For example, apply 'Environment=Production' or 'Department=Finance'. Limits include 50 tags per resource, 512-character keys/values, and specific reserved names.

az tag targets specific resources via ID, supporting hierarchical inheritance in some cases. It's essential for large-scale deployments, integrating with Azure Resource Manager (ARM) templates, PowerShell, and REST APIs. Requires Azure CLI v2.0+ and authentication via az login. Usage streamlines tag governance without portal navigation.

CAVEATS

Requires Azure CLI installed and az login authentication.
Tag keys/values limited to 512 chars; max 50 tags/resource.
Some resources don't support tags; check Azure docs.
Deletes are permanent without undo.

SUBCOMMANDS

az tag create: Add tags to resource.
az tag delete: Remove specific tag.
az tag list: Retrieve all tags on resource.

EXAMPLE

az tag create --resource-id /subscriptions/... --tags Env=Prod CostCenter=123
az tag list --resource-id /subscriptions/...

HISTORY

Introduced in Azure CLI 2.0 (2017) as part of Resource Manager enhancements. Evolved with CLI updates; v2.30+ added better query support and bulk operations. Tracks Azure tag feature expansions since 2014.

SEE ALSO

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

Copied to clipboard