Skip to content

Instantly share code, notes, and snippets.

@ttamminen
Created December 4, 2017 06:02
Show Gist options
  • Save ttamminen/6c40084339d1c2f010d3d86e5c36bc52 to your computer and use it in GitHub Desktop.
Save ttamminen/6c40084339d1c2f010d3d86e5c36bc52 to your computer and use it in GitHub Desktop.
Set Azure SQL Server firewall using Azure CLI 2.x
$rulename = ''
$servername = ''
$resourcegroup = ''
$currentip = Invoke-WebRequest 'http://ipv4.icanhazip.com' | Select -Expand Content
$currentip = $currentip.Trim()
az sql server firewall-rule delete --name $rulename --resource-group $resourcegroup --server $servername
az sql server firewall-rule create --debug -n $rulename --resource-group $resourcegroup --server $servername --start-ip-address "$currentip" --end-ip-address "$currentip"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment