0
votes

If you create SQL Server by Azure Management Portal, it is possible to allow Azure services to connect by a switch in Configure panel on a server page. I want to do that by requesting Service Management API. Is it possible?

I searched in Operations for Azure SQL Databases and Azure SQL Database REST API Reference.

Update: code block with example

internal string CreateFirewallRule(string serverName)
{
    var firewallParameters = new FirewallRuleCreateParameters();
    firewallParameters.Name = "AllowAll";
    firewallParameters.StartIPAddress = "0.0.0.0";
    firewallParameters.EndIPAddress = "0.0.0.0";
    var response = _sqlMgmtClient.FirewallRules.Create(serverName, firewallParameters);
    return response.StatusCode.ToString();
}
1

1 Answers

1
votes

To allow other Azure Services to connect to your Azure SQL Database Server, you will need to set firewalls accordingly. In Portal.Azure.com, if you go to the server, then settings and select Firewall Rules you can enable other Azure services to connect to the server. This will set up a firewall rule for the range 0.0.0.0 to 0.0.0.0.

If you would like to do this via REST APIs you can use the Create Firewall Rule API. You will need to specify the range of 0.0.0.0 to 0.0.0.0 to allow other Azure Services to connect to the server. You can also use Azure PowerShell to do this with New Firewall Rule cmdlet.

Update: code block with example

internal string CreateFirewallRule(string serverName)
{
    var firewallParameters = new FirewallRuleCreateParameters();
    firewallParameters.Name = "AllowAll";
    firewallParameters.StartIPAddress = "0.0.0.0";
    firewallParameters.EndIPAddress = "0.0.0.0";
    var response = _sqlMgmtClient.FirewallRules.Create(serverName, firewallParameters);
    return response.StatusCode.ToString();
}