Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable "Allow Azure services and resources to access this server" through PowerShell (Azure CLI)?

After creating a new Azure SQL server using az sql server create, how can I enable the following options through PowerShell(Azure CLI)?

enter image description here

like image 718
Mason Avatar asked Dec 08 '22 11:12

Mason


2 Answers

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
like image 119
Scott Heath Avatar answered Jan 10 '23 10:01

Scott Heath


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>
like image 44
Brandon Olin Avatar answered Jan 10 '23 09:01

Brandon Olin