Update-AzTag

Selectively updates the set of tags on a resource or subscription.

Syntax

Update-AzTag
        -ResourceId <String>
        -Operation <TagPatchOpeation>
        -Tag <Hashtable>
        [-DefaultProfile <IAzureContextContainer>]
        [-WhatIf]
        [-Confirm]  
      [<CommonParameters>]

Description

The Update-AzTag cmdlet with a ResourceId selectively updates the set of tags on a resource or subscription. This operation allows replacing, merging or selectively deleting tags on the specified resource 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.

Examples

Example 1: Selectively updates the set of tags on a subscription with "Merge" Operation

PS C:\>$mergedTags = @{"key1"="value1"; "key3"="value3";}
PS C:\>Update-AzTag -ResourceId /subscriptions/{subId} -Tag $mergedTags -Operation Merge

Id         : {Id}
Name       : {Name}
Type       : {Type}
Properties :
             Name     Value
             =======  =========
             key1     value1
             key2     value2
             key3     value3

This command Merges the set of tags on the subscription with {subId}.

Example 2: Selectively updates the set of tags on a subscription with "Replace" Operation

PS C:\>$replacedTags = @{"key1"="value1"; "key3"="value3";}
PS C:\>Update-AzTag -ResourceId /subscriptions/{subId} -Tag $replacedTags -Operation Replace

Id         : {Id}
Name       : {Name}
Type       : {Type}
Properties :
             Name     Value
             =======  =========
             key1     value1
             key3     value3

This command Repalces the set of tags on the subscription with {subId}.

Example 3: Selectively updates the set of tags on a subscription with "Delete" Operation

PS C:\>$deletedTags = @{"key1"="value1"}
PS C:\>Update-AzTag -ResourceId /subscriptions/{subId} -Tag $deletedTags -Operation Delete

Id         : {Id}
Name       : {Name}
Type       : {Type}
Properties :
             Name     Value
             =======  =========
             key3     value3

This command Deletes the set of tags on the subscription with {subId}.

Parameters

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False
-DefaultProfile

The credentials, account, tenant, and subscription used for communication with azure.

Type:Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Operation

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

Type:Microsoft.Azure.Commands.Tags.Model.TagPatchOpeation
Accepted values:Merge, Replace, Delete
Position:2
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-ResourceId

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

Type:String
Position:0
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Tag

The set of tags to use for update.

Type:Hashtable
Position:1
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

String

Microsoft.Azure.Commands.Tags.Model.TagPatchOpeation

Hashtable

Outputs

Microsoft.Azure.Commands.Tags.Model.PSTagResource