Skip to content

Sync Tags to Azure Resources or Resource Groups from a CSV file

License

Notifications You must be signed in to change notification settings

UbhiTS/az-cli-scripts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Az CLI Scripts

Budgets

Bulk upload budget settings for Resource Groups from a CSV file

Usage


Bash

bash budgets.sh <csv_file> [EXECUTE]

Example


To just view the commands:

bash budgets.sh budgets.csv

To execute the commands:

bash budgets.sh budgets.csv EXECUTE

Sync CSV Tags (Azure CLI BASH or PowerShell)

Sync Tags to Azure Resources or Resource Groups from a CSV file

  • one execution for all tags per resource
  • pass in any number of tags in the CSV file, it's not hardcoded (except the ResourceName header in the CSV file) :)
  • see the actual Azure CLI commands that will run before you choose to execute

Usage


Bash

bash synccsvtags.sh <csv_file> <azure_subscription_id> [EXECUTE]

PowerShell

.\synccsvtags.ps1 <csv_file> <azure_subscription_id> [EXECUTE]

Example


To just view the commands:

bash synccsvtags.sh tags.csv 11111111-1111-1111-1111-111111111111

To execute the commands:

bash synccsvtags.sh tags.csv 11111111-1111-1111-1111-111111111111 EXECUTE

Output


az tag create --resource-id /subscriptions/11111111-1111-1111-1111-111111111111/resourcegroups/RG1 --tags Tag1=aaaa Tag2=bbbb Tag3=cccc Tag4=dddd
az tag create --resource-id /subscriptions/11111111-1111-1111-1111-111111111111/resourcegroups/RG2 --tags Tag1=eeee Tag2=ffff Tag3=gggg Tag4=hhhh

CSV Sample


ResourceName,Tag1,Tag2,Tag3,Tag4
RG1,aaaa,bbbb,cccc,dddd
RG2,eeee,ffff,gggg,hhhh