Skip to content

Instantly share code, notes, and snippets.

@jsakamoto
Created Jan 26, 2017
Embed
What would you like to do?
Create/Delete Azure Database server firewall rule by Microsoft Azure CLI 2.0 ("az" command)
$serverName = "<server name>"
$resourceGroupName = "<resource group name>"
$ruleName = "<rule name>"
$globalIPAddress = curl.exe -s http://inet-ip.info
echo "Global IP Address of this site: $globalIPAddress"
az sql server firewall create --firewall-rule-name $ruleName --server-name $serverName -g $resourceGroupName --start-ip-address $globalIPAddress --end-ip-address $globalIPAddress > $null
az sql server firewall list --server-name $serverName -g $resourceGroupName -o table
pause
$serverName = "<server name>"
$resourceGroupName = "<resource group name>"
$ruleName = "<rule name>"
az sql server firewall delete --firewall-rule-name $ruleName --server-name $serverName -g $resourceGroupName > $null
az sql server firewall list --server-name $serverName -g $resourceGroupName -o table
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment