Azure / Azure/azure-powershell

`Update-AzTag -Operation Replace` returns success but does not replace tags for some resource types

Open
#18,133 6 comments 0 reactions 0 assignees View on GitHub
act-identity-squad ARM - Tags bug customer-reported Service Attention
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
3d 14h
Merged PRs (30d)
54

Description

### Description

This is likely an Azure API issue, more than an issue with PowerShell, but I'll just start here in case.

I use `Update-AzTag -Operation Replace -Tag @{New=Tags;etc}` to update tags on some Azure resources, mostly to fix casing, remove whitespaces etc. But for certain resource types, the command returns success, but tags does not actually get updated. This is especially aparent when replacing existing tags where only case on tag name has changed. Resource types where I've noticed this kind of behavior:

* Microsoft.Compute/virtualMachines/extensions
* Microsoft.Compute/virtualMachineScaleSets
* Microsoft.DocumentDB/databaseAccounts
* Microsoft.Insights/autoscalesettings

Relevant resources / documentation, confirming these resource types are taggable:

* [Tag support for Azure resources](https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/tag-support)
* [Tag limitations](https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/tag-resources?tabs=json#limitations)

Concrete example:

* Cosmos DB account `Microsoft.DocumentDB/databaseAccounts` with tag `@{'Costcenter'=1234}`.
* I want to change it to `@{'CostCenter'=1234}`.
* `Update-AzTag -ResourceId $ResourceId -Operation 'Merge' -Tag @{'CostCenter'='1234'}`
* `Update-AzTag -ResourceId $ResourceId -Operation 'Replace' -Tag @{'CostCenter'='1234'}`
* Both `-Operation Replace` and `-Operation Merge` returns success, but tag stays the same.

### Issue script & Debug output

```PowerShell
^
```

### Environment data

```PowerShell
Name Value
---- -----
PSVersion 5.1.22621.1
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.22621.1
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
```

### Module versions

```PowerShell
Name Version
---- -------
Az.Accounts 2.7.6
Az.Compute 4.26.0
Az.Resources 5.6.0
```

### Error output

_No response_

Contributor guide

Open the contributing guide

Research direction

Start at the Update-AzTag entry point in the Az.Resources module and reproduce the Cosmos DB example, including the case-only tag-name change. Compare the reported success with the resource's tags for the listed resource types, then determine whether the behavior is specific to the Azure API or the module. Done means Replace and Merge produce the requested tags or the limitation is documented and covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, powershell
Domain
cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.