Skip to content

Instantly share code, notes, and snippets.

@Laxman-SM
Forked from rgpower/fetch-azure-policy-meta.sh
Created November 15, 2022 06:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Laxman-SM/4913aa2b46ccb5a5eb49a15243abe4ad to your computer and use it in GitHub Desktop.
Save Laxman-SM/4913aa2b46ccb5a5eb49a15243abe4ad 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