DEV Community

loading...
Cover image for using jq to handle az graph output

using jq to handle az graph output

Antoine
mainly .Net but looking for great stuff about anything
・1 min read

Photo by Raphael Renter on Unsplash

I had to improve the az graph query due to a change in tsv format provided by az graph to a csv produced by jq.

Reminder:

IFS_old=$IFS;
IFS=$'\n';
az graph query -q "where type =~ 'Microsoft.Web/sites' and kind=~'$type' | project name, resourceGroup" | jq '.data[] | [.name, .resourceGroup] | @csv' -r | for i in ` awk -F ',' '{print " --name " $1 " --resource-group " $2 }' ` ; do eval "az webapp config appsettings set $i --settings WEBSITE_RUN_FROM_PACKAGE='$PackageLink' " ;done;
IFS=$IFS_old;
Enter fullscreen mode Exit fullscreen mode

Useful Links:

Hope this helps

Discussion (0)