Adding Firewall Rules to SQL Server Database

  • Firewall rules can give access to single databases, and elastic pools and their databases.

  • Firewall rules are also needed to connect on-premises and other Azure resources to databases.

  • Azure SQL Database creates a firewall at the server level for single and pooled databases.

  • This firewall blocks connections from IP addresses that do not have permission.

  • To connect to an Azure SQL database from an IP address outside of Azure, you need to create a firewall rule. You can use rules to open a firewall for a specific IP address or for a range of IP addresses.

  • Go to database and click on Set server firewall.

  • To allow certain public internet IP addresses to access the sql resource, click on Add a firewall rule.

  • Assign a rule name, and valid IPv4 address range in start and end IP columns or IP address, from which the resource is to be accessed and click OK.

  • Additionally, there is an option to enable access or allow any traffic from resources/services hosted in Azure (not just Azure subscription) to access the SQL server. When enabled, there is no need to add any firewall rules.

  • After adding required changes, click Save.