Hello @Mohamed CHALABI ,
You can do it using powershell script , below are the commands:
$tags = (Get-AzResource -ResourceGroupName ResourceGroupName -Name VirtualMachineName).Tags //Get the tags on that Virtual Machine
$tags["decom"] = [int]$tags["decom"] + 1 //Increase the value of decom tag
Set-AzResource -ResourceGroupName ResourceGroupName -Name VirtualMachineName -ResourceType "Microsoft.Compute/VirtualMachines" -Tag $tags //set the updated tag
Before execution of the script:
Step By Step Execution of above script:
Step1:- Get the tags
$tags = (Get-AzResource -ResourceGroupName ResourceGroupName -Name VirtualMachineName).Tags
Step2:- Check the current tag decom value:
$tags
Key Value
--- -----
decom 1
Step3:- Increase the tag decom value
$tags["decom"] = [int]$tags["decom"] + 1
Step4:- Check the increased tag value
$tags
Key Value
--- -----
decom 2
Step5:- Update the VM with new tag value
Set-AzResource -ResourceGroupName ResourceGroupName -Name ResourceGroupName -ResourceType "Microsoft.Compute/VirtualMachines" -Tag $tags