Review broad Azure SQL firewall ranges

Narrow broad Azure SQL firewall ranges to required client addresses and review the access granted by all applicable rules.

Description

Choose SQL firewall ranges from the source addresses Azure sees for required clients. In Azure SQL Database, setting both ends to 0.0.0.0 allows connections from Azure resources, including other customers’ resources.

Potential impact

A broad public rule lets unwanted clients attempt sign-in. A range that omits a required source can cut off an application or administration tool. Database access also requires authentication and permissions.

Remediation

Set start_ip_address and end_ip_address to valid IPv4 addresses in ascending order. Check the combined server and database rules, including temporary rules. Splitting a range leaves the same sources allowed. For private-only access, test the private path before disabling public access. Verify that approved clients connect and others are blocked.

Examples

Use your actual resource names and client addresses. The tasks configure firewall rules only.

Broad address ranges

yaml
- name: Create Firewall Rule1
  azure_rm_sqlfirewallrule:
    resource_group: myResourceGroup1
    server_name: firewallrulecrudtest-6285
    name: firewallrulecrudtest-5370
    start_ip_address: 0.0.0.0
    end_ip_address: 172.28.11.138

- name: Create Firewall Rule2
  azure_rm_sqlfirewallrule:
    resource_group: myResourceGroup2
    server_name: firewallrulecrudtest-6285
    name: firewallrulecrudtest-5370
    start_ip_address: 172.28.10.136
    end_ip_address: 172.28.11.138

Three-address range

yaml
- name: Create Firewall Rule
  azure_rm_sqlfirewallrule:
    resource_group: myResourceGroup
    server_name: firewallrulecrudtest-6285
    name: firewallrulecrudtest-5370
    start_ip_address: 172.28.10.136
    end_ip_address: 172.28.10.138

Explanation:

  • First example: The two tasks target different resource groups. The first range starts at 0.0.0.0 and ends at 172.28.11.138. The second spans 259 addresses, including both endpoints.
  • Second example: This rule spans three private addresses, 172.28.10.136 through 172.28.10.138. A rule containing private addresses does not establish a private connection.

References