After creating a new Azure SQL server using az sql server create
, how can I enable the following options through PowerShell(Azure CLI)?
Asked
Active
Viewed 5,020 times
8

Mason
- 1,007
- 1
- 13
- 31
5 Answers
14
It's in the documentation for Azure SQL somewhere, if you search for "azure sql firewall allow azure services", but here's what you need to do - create a rule with a start and end address of 0.0.0.0, like this:
az sql server firewall-rule create --resource-group <resource group name> --server <azure sql name> -n <any name> --start-ip-address 0.0.0.0 --end-ip-address 0.0.0.0

Scott Heath
- 830
- 7
- 5
-
This seems to enable that option. Thanks! – Mason Oct 18 '19 at 12:50
-
2It's in the API docs: https://learn.microsoft.com/en-us/rest/api/sql/firewallrules/createorupdate – Isaac Rosado Jan 02 '20 at 03:55
3
To expand on Scott answer, the equivalent way to do this in the Azure PowerShell module is:
New-AzSqlServerFirewallRule -FirewallRuleName <fw-rule-name> -StartIpAddress '0.0.0.0' -EndIpAddress '0.0.0.0' -ServerName <sql-server-name> -ResourceGroupName <resource-group-name>

Brandon Olin
- 322
- 3
- 11
-
1Do you know what to do when you have "Deny public access" to Yes. Then you can't configure firewall rules. – Piotr Perak Feb 12 '21 at 14:59
2
my small contribution here.
the below az command with the respective group and sqlservername sets "Allow Azure services and resources to access this server" to Yes
az sql server firewall-rule create -g -s -n AllowAllWindowsAzureIps --start-ip-address 0.0.0.0 --end-ip-address 0.0.0.0

Rom
- 21
- 1
1
Just add a new rule with specific name (AllowAllWindowsAzureIps);
New-AzSqlServerFirewallRule -ResourceGroupName <resourceGroup> -ServerName <serverName> -FirewallRuleName "AllowAllWindowsAzureIps" -StartIpAddress "0.0.0.0" -EndIpAddress "0.0.0.0"

user2708754
- 31
- 6
0
Just came across this and I believe it's doable via the following script now...
New-AzSqlServerFirewallRule -ResourceGroupName <ResourceGroup> -ServerName <SQLServerName> -AllowAllAzureIPs

ChrisGPT was on strike
- 127,765
- 105
- 273
- 257

Jon
- 1