Skip to content

Commit a08907c

Browse files
authored
Merge pull request #43479 from jtuliani/patch-13
Added '-o json' as needed to CLI examples
2 parents 694385e + ac5a4a6 commit a08907c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

articles/azure-resource-manager/resource-group-using-tags.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ az resource tag --tags Dept=IT Environment=Test -g examplegroup -n examplevnet -
200200
To add tags to a resource that already has tags, retrieve the existing tags, reformat that value, and reapply the existing and new tags:
201201

202202
```azurecli
203-
jsonrtag=$(az resource show -g examplegroup -n examplevnet --resource-type "Microsoft.Network/virtualNetworks" --query tags)
203+
jsonrtag=$(az resource show -g examplegroup -n examplevnet --resource-type "Microsoft.Network/virtualNetworks" --query tags -o json)
204204
rt=$(echo $jsonrtag | tr -d '"{},' | sed 's/: /=/g')
205205
az resource tag --tags $rt Project=Redesign -g examplegroup -n examplevnet --resource-type "Microsoft.Network/virtualNetworks"
206206
```
@@ -211,7 +211,7 @@ To apply all tags from a resource group to its resources, and *not keep existing
211211
groups=$(az group list --query [].name --output tsv)
212212
for rg in $groups
213213
do
214-
jsontag=$(az group show -n $rg --query tags)
214+
jsontag=$(az group show -n $rg --query tags -o json)
215215
t=$(echo $jsontag | tr -d '"{},' | sed 's/: /=/g')
216216
r=$(az resource list -g $rg --query [].id --output tsv)
217217
for resid in $r
@@ -227,12 +227,12 @@ To apply all tags from a resource group to its resources, and *keep existing tag
227227
groups=$(az group list --query [].name --output tsv)
228228
for rg in $groups
229229
do
230-
jsontag=$(az group show -n $rg --query tags)
230+
jsontag=$(az group show -n $rg --query tags -o json)
231231
t=$(echo $jsontag | tr -d '"{},' | sed 's/: /=/g')
232232
r=$(az resource list -g $rg --query [].id --output tsv)
233233
for resid in $r
234234
do
235-
jsonrtag=$(az resource show --id $resid --query tags)
235+
jsonrtag=$(az resource show --id $resid --query tags -o json)
236236
rt=$(echo $jsonrtag | tr -d '"{},' | sed 's/: /=/g')
237237
az resource tag --tags $t$rt --id $resid
238238
done

0 commit comments

Comments
 (0)