How to disable firewall in Azure SQL database? - azure-sql-database

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?

• 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

Related

How to connect Azure SQL database to ASP.NET website hosted on a different server

I have created Sql database from Azure using my subscription. I copied the connection string supplied with my credentials correctly into my code and it work in visual studio but when I deployed to my hosting server for my website it displays connection error. I have set IP range to accept all IP yet not working.
By default, (when you create a new DB), Azure blocks ALL traffic to your database. In order to allow traffic to your database either you need to whitelist all the IP address or the best suggestion in your case is to enable 'Allow access to Azure Services' on the SQL Server settings. Find more details here

Does Azure SQL Database firewall automatically allow VM's in the same Resource Group?

Using Azure Resource Manager.
I have an Azure SQL Database resource, and even when I delete all "allow" firewall (on the sql server's blade) rules, my VM is still able to query the SQL DB.
EVEN when I set "Allow Access" to no for the ip address of the VM, I can still query the DB. How??
Is this because Azure automatically allows resources in the same Resource Group to access it? Even without explicit Firewall allow rules?
Under the Firewall section of the SQL Server blade, there's a switch called "Allow access to Azure services". Having this on will allow any Azure resource to access get through the firewall (they will still need your username and password of course to actually access the server). This includes Azure resources on other people's subscriptions. See this answer.
I had this turned on and that's why my firewall settings made no difference for my VM's.
Not exactly sure what's happening with your specific situation, security-wise, but Resource Groups have nothing to do with it. Resource Groups help organize resources within a single container, where you can manage those resources better (e.g. add users to the Resource Group without adding them to the rest of your subscription). They don't play a role in communication between Azure services.

deploying website doesn't work the database access

I have a website that access a sql database in localhost and it works, but when published in an Azure website, can't reach the database. I've changed the connection string with visual studio on line pointing to a new database created in Azure, but can't reach the database.
There is a way to track the error? because the application only returns to the same webpage (this is the caondition when the connection to the database fails.
Any suggestion?
Check that the Azure firewall has a rule for the IP address of the machine hosting the website. You can do that by either of two methods:
Navigating to your Azure Portal using a browser that is on the same machine that is trying to access your database.
Go to the 'SQL Databases' section and click on the database.
In the 'Design your SQL database' section, click on 'Set up Windows Azure firewall rules for this IP address'.
If the machine already has a rule the portal will indicate that. Otherwise a new rule will be added.
The other way:
From the Management Portal, click SQL Databases. All databases and their corresponding servers are listed here.
Click Servers at the top of the page.
Click the arrow beside the server for which you want to manage firewall rules.
Click Configure at the top of the page.
To add the current computer, click Add to the Allowed IP Addresses.
To add additional IP addresses, type in the Rule Name, Start IP Address, and End IP Address.
To modify an existing rule, click any of the fields in the rule and modify.
Click Save at the bottom of the page to save the changes.
How to: Configure Firewall Settings (Azure SQL Database)

Connection string for a localhost SQL Server instance on a different machine in the same network?

I'd like to connect to a local instance of SQL Server on another machine within the same network, and am wondering if it's even possible.
For example, say we have Machine01 and Machine02, both on the same internal network. I have several IIS websites setup on Machine01. If I log onto Machine02 and query the URL of one of the websites on Machine01 in in internet browser (say http://Machine01:9000), the website will load just fine. This has me thinking that it might be possible to construct a connection string to access the local database on Machine01 from Machine02. Is this possible?
I have Allow remote connections to this server checked in SSMS.
I've tried this connection string:
Server=Machine01;trusted_connection=true;Database=MyDB;Persist Security Info=True
Your connection string is correct in that the Server is the target computer name, and the premise of what you're trying to do is certainly correct and quite possible.
However make sure that the firewall on Machine01 is set to allow inbound traffic on the LAN from the SQL Server port (by default, 1433).
Also, the trusted_connection bit may not work, depending on how you have your users set up. If the user account on Machine02 a trusted user account on Machine01? If in any doubt, set up a SQL Server user account on your Machine01 SQL server, make sure you have SQL connections enabled (Server properties -> Security -> SQL Server and Windows Authentication mode), and pass across the SQL user name and password in the connection string instead...
You might try setting up a linked server, I find it to make the queries much easier. Here is some information on how to set it up.

SQL Server database access EC2

I have 4 servers in an EC2 (amazon cloud services), one of them contains SQL Server 2008.
I want to restrict the access to the database to be just from the other servers I have running.
I wanted to do that using the EC2 security groups but all my instances use the same security groups and as far as i know once the instance is created the security group is constant.
I know there is something that is relevant to the "Protocols for DBNAME" in the SQL Server network configuration (in the SQL Server Configuration Manager) but I have no idea how to use it.
Right now it defines that IPAll TCP Port is 1433 ... and the rest (from what I checked) is not relevant ...
Any ideas?
You can define inbound rules recursively. If your security group is named "default" and has an id of "sg-123456789", you can add a rule to the security group that says "let sg-123456788 access port x to y". You can make changes to your security group while it is in use. Of course, all this can be done through the management console.