'How to enable "Allow Azure services and resources to access this server" through PowerShell (Azure CLI)?
Solution 1:[1]
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
Solution 2:[2]
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>
Solution 3:[3]
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
Solution 4:[4]
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"
Solution 5:[5]
Just came across this and I believe it's doable via the following script now...
New-AzSqlServerFirewallRule -ResourceGroupName <ResourceGroup> -ServerName <SQLServerName> -AllowAllAzureIPs
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Scott Heath |
Solution 2 | Brandon Olin |
Solution 3 | Rom |
Solution 4 | user2708754 |
Solution 5 | Chris |