Created
October 2, 2020 15:23
-
-
Save alwalker/e1c0f7e79d64220f3556f426970a1664 to your computer and use it in GitHub Desktop.
One liner for adding your current IP to a Azure SQL Server firewall. Used in ADO.
This file contains 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
MYIP=$(curl -s http://ipinfo.io/json | jq -r '.ip') && \ | |
MATCH="^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$" && \ | |
if [[ $MYIP =~ $MATCH ]]; then \ | |
echo "Adding $MYIP to $(SERVER_NAME) firewall"; \ | |
az sql server firewall-rule create -g $(RESOURCE_GROUP) -s $(SERVER_NAME) -n ALLOW_ADO --start-ip-address $MYIP --end-ip-address $MYIP; \ | |
else \ | |
echo "$MYIP is not a valid IP address."; \ | |
exit 1; \ | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment