Created
December 15, 2025 10:57
-
-
Save AaronSadlerUK/b161a9416c3296b5abb2f835b0b3c3d3 to your computer and use it in GitHub Desktop.
Uptime robot to Azure Web App network management
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| RESOURCE_GROUP="your-rg" | |
| APP_NAME="your-app" | |
| PRIORITY_START=200 | |
| priority=$PRIORITY_START | |
| curl -s https://cdn.uptimerobot.com/api/IPv4andIPv6.txt | while read -r ip; do | |
| [[ -z "$ip" ]] && continue | |
| # Detect IPv4 vs IPv6 for naming and CIDR | |
| if [[ "$ip" == *:* ]]; then | |
| rule_name="UptimeRobot-v6-$priority" | |
| cidr="$ip/128" | |
| else | |
| rule_name="UptimeRobot-v4-${ip//./-}" | |
| cidr="$ip/32" | |
| fi | |
| echo "Adding $ip..." | |
| az webapp config access-restriction add \ | |
| --resource-group "$RESOURCE_GROUP" \ | |
| --name "$APP_NAME" \ | |
| --rule-name "$rule_name" \ | |
| --priority $priority \ | |
| --ip-address "$cidr" \ | |
| --action Allow \ | |
| --output none | |
| ((priority++)) | |
| done | |
| echo "Done. Added $((priority - PRIORITY_START)) rules" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| az webapp config access-restriction show -g "$RESOURCE_GROUP" -n "$APP_NAME" \ | |
| --query "ipSecurityRestrictions[?starts_with(name, 'UptimeRobot')].name" -o tsv | \ | |
| xargs -I {} az webapp config access-restriction remove -g "$RESOURCE_GROUP" -n "$APP_NAME" --rule-name {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment