Skip to content

Instantly share code, notes, and snippets.

@juusujanar
Last active January 22, 2020 14:24
Show Gist options
  • Save juusujanar/acaf871ca34243b14933ee3bf17dbd77 to your computer and use it in GitHub Desktop.
Save juusujanar/acaf871ca34243b14933ee3bf17dbd77 to your computer and use it in GitHub Desktop.
Convert Azure IP ranges to comma-separated list

Azure IP ranges

This script converts Azure IP ranges to a comma-separated list for use in firewall rules, e.g. gcloud compute firewall-rules. The given scripts looks up AzureCloud.eastus2 IP ranges, that are also used by GitHub Actions to connect to the outside, but you can easily change the name of the ranges you want to look up.

Unfortunately Microsoft does not seem to provide a static direct link to the JSON, so the link may need updating every now and then.

I pulled the link from https://www.microsoft.com/en-us/download/details.aspx?id=56519.

Requirements

  • curl
  • jq
  • Internet access

Contributing

Feel free to leave a comment if you find any improvements.

#!/bin/bash
curl https://download.microsoft.com/download/7/1/D/71D86715-5596-4529-9B13-DA13A5DE5B63/ServiceTags_Public_20200112.json | \
jq -r '.values[] | select( .name == "AzureCloud.eastus2" ) | .properties.addressPrefixes | join(",")'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment