Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
26 lines (22 sloc) 1.1 KB
#!/bin/bash
###########################################################################################
# Azure CLI Kung-Fu - Blog post
# Dan Patrick - @deltadan
#
#Script Purpose
# - load the output of a az query command into a variable named $listFoo
# - load the output of a az aeury command into a file in the current directory named property.txt
###########################################################################################
#listFoo using a configured query value of a resource property
#example list all disks in an RG that are Unattached and formated listFoo style file and variable
rg=resourceGroupName
property=diskState
value=Unattached
#load a variable with the list based on the property and value
listFoo=$(az disk list -g $rg \
--query "[?$property=='$value']".id \
-o tsv | sed "s/.*/& /" | tr -d '\n' | rev | cut -c 2- | rev)
#load a file with the list based on the property and value
az disk list -g $rg \
--query "[?$property=='$value']".id \
-o tsv | sed "s/.*/& /" | tr -d '\n' | rev | cut -c 2- | rev>>$property.txt
You can’t perform that action at this time.