Reputation: 257
I want to disable firewall settings in the Azure SQL database? Most of the documentation shows how to enable? Can't able to find how to disable it?
Can anyone advise?
Upvotes: 5
Views: 4125
Reputation: 5165
• You cannot disable firewall in Azure SQL database by the toggling the ‘ON/OFF’ button, but you can surely disable the Azure SQL Database firewall through the firewall rules for sure by following the below steps: -
A) Create an Azure SQL Server level firewall rule to allow all IP addresses through the Azure portal by going to the Azure SQL Server created, select the SQL Database --> Settings --> Firewall --> Set Server Firewall --> Add the IP Address ‘0.0.0.0’ under Start IP and ‘255.255.255.255’ under End IP and give appropriate rule name to the rule --> Save. Also, ensure to check ‘Yes’ to the option for ‘Allow Azure Services and resources to access this server’ which will add a rule from ‘0.0.0.0’ to ‘0.0.0.0’ in rule space and gives access to everyone including the other Azure resources and services to the Azure SQL Server.
B) Secondly, after doing the above, configure the database level firewall rules for ensuring access to everyone thereby successfully proving the firewall useless and ultimately proving it as disabled.
EXECUTE sp_set_database_firewall_rule N'my_db_rule';
,'0.0.0.0'
,'255.255.255.255'
The first parameter is the rule name, followed by the first IP address that you wish to give access to. The third parameter is the last IP address in the range you wish to give access to. Setting the start IP address and the end IP address to the said IP address range will only provide access to that specific IP address range. But to execute the above command successfully, you will have to provide ‘CONTROL’ permissions on the required database. Once the command has been issued to change a rule, the change can take up to 5 minutes to take effect. Similarly, if you want to delete a firewall rule, execute the command below which will delete the said firewall rule thus once again activating the firewall rules to block or allow specific IP addresses.
EXECUTE sp_delete_database_firewall_rule N'my_db_rule';
C) Also, to view the existing firewall rules on a SQL database, execute the below transact-SQL query on the MASTER DB which will display all the rules that are in place currently on the Azure SQL DB and Server.
SELECT * FROM sys.firewall_rules
Upvotes: 8