I am trying to use a bash variable (ID in the below script) in azure CLI command. but seems its not working and throwing below error:
usage error
--scope
: must be a fully qualified ARM ID.
The error is happening on line az policy assignment list --scope $ID
I have verified by echoing the ID variable and its outputting correctly which is:
"/providers/Microsoft.Management/managementGroups/test-management-group"
What i am doing wrong here?
Full script is here:
MGS=$(az account management-group list)
for (( i = 0; i < ${#MGS[@]}; i++ ))
do
ID=$(echo $MGS | jq .[$i].id)
echo $ID
az policy assignment list --scope $ID
done