Azure-docs: Azure CLI scripts do not copy tags properly when tag (or tag's value) contains spaces

Created on 28 Nov 2019  Â·  8Comments  Â·  Source: MicrosoftDocs/azure-docs

Hi team,
I moved this from here: https://github.com/MicrosoftDocs/azure-docs.pl-pl/issues/469

@siudeks commented 2 hours ago — with docs.microsoft.com
Azure CLI scripts on the page are working well for single-word tags and values. For instance, when tag=value is abc=def (abc - tag name, def - tag value) - scripts are working well.
In case when spaces are in tag - like a b c=d e f, tags from resource group to resources are copied partially.


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Pri1 assigned-to-author azure-resource-managesvc product-feedback triaged

All 8 comments

@siudeks Thank you for your feedback! We will review and update as appropriate.

This also appears to be similar to #43741

@siudeks Thanks fore reaching out!! Can you please share the resources for which the tags are being applied partially so that we can verify and assist you accordingly?

I temporary removed spaces inside my tags (names and values), so my tagging looks well but is impractical. As the result my tagging (right now) does not reflect the problem

My question - how looking to tagging of my resources would help with improving script which does not include spaces? Do you have problem with reproducing the issue?

I tried to reproduce the issue from my end and I could see the resources were being tagged even though if tags has spaces.Except for few resources like Traffic manager, the tags with spaces weren't enforced ( which is known limitation). So as you mentioned that some of the tags were applied partially , I would like to know the resources for which the tags were applied partially so that I can verify from my end and check whether they were supported or not and let you know.

Steps to reproduce

  1. Create resource group and add a tag with value (spaces included)
    Example: resource group siudeks-lab, tag: "my tag"="my value"
    image

  2. Add a resource (e.g. storage account) into the resource group

  3. Reuse slightly modified script from docs descrbed as
    To apply all tags from a resource group to its resources, and keep existing tags on resources, use the following script: scope of change: first line uses my example resource group instead of all available resource groups
groups=siudeks-lab
for rg in $groups
do
  jsontag=$(az group show -n $rg --query tags -o json)
  t=$(echo $jsontag | tr -d '"{},' | sed 's/: /=/g')
  r=$(az resource list -g $rg --query [].id --output tsv)
  for resid in $r
  do
    jsonrtag=$(az resource show --id $resid --query tags -o json)
    rt=$(echo $jsonrtag | tr -d '"{},' | sed 's/: /=/g')
    az resource tag --tags $t$rt --id $resid
  done
done

Expected:
resource's tag
image

Actual:
image

@siudeks Thanks for the information.
@tfitzmac Can you please review the document and update the example ?

Thanks for this feedback. I have added an example that shows how to apply tags that include spaces.

please-close

Was this page helpful?
0 / 5 - 0 ratings