Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
jq Recipes
Azure
Copy Tags From src to dst resource-id
Ref: https://github.com/Azure/azure-cli/issues/13170#issuecomment-629005051
IFS=','
TAGS=($(az tag list --output json --resource-id <resource-id-src> | \
jq -r '.properties.tags|to_entries|map("\(.key)=\(.value|tostring)")|join(",")'))
az tag create --resource-id <resource-id-dst> --tags ${TAGS[@]}
IFS=' '
List the ID of Every Resource in a Group
az resource list --resource-group <rg-name> | jq -r '"\(.[].id)"'
Perform Action on Every ID in a Group
while read id; do <az action>; done <<<$(az resource list --resource-group <rg-name> | jq -r '"\(.[].id)"')
List the Name, Type and ID of Resources in a Group
az resource list --resource-group <rg-name> | jq 'map({name,type,id})'
List All Public IP Address Resources in a Tenant
az resource list | jq 'map(select(.type|endswith("publicIPAddresses"))|{name,type,id})'