Skip to content

Instantly share code, notes, and snippets.

@rgpower
Created October 19, 2022 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rgpower/6636e5790ebdb4ee33722086715f100d to your computer and use it in GitHub Desktop.
Save rgpower/6636e5790ebdb4ee33722086715f100d to your computer and use it in GitHub Desktop.
Fetch Azure Policy Metadata, following paged responses
#!/bin/bash
i=0
done=0
url="https://management.azure.com/providers/Microsoft.PolicyInsights/policyMetadata?api-version=2019-10-01"
while [ $done -ne 1 ]
do
echo az rest --output-file "pm-${i}.json" --url "$url"
az rest --output-file "pm-${i}.json" --url "$url"
url=$(jq -r '.nextLink' < pm-${i}.json)
if [ 'null' -eq $url ]
then
done=1
fi
i=$(($i+1))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment