Creating a Firewall rule in Microsoft Azure [duplicate] - azure

I'm trying to manage firewall settings for my SQL Server database. But there is no firewall option in database settings. The goal of this operation is to allow my IP.
I have a free trial subscription.

The firewall settings are on the "SqlServer." When creating a new Azure SQL db instance a SQL server is also created.
Go to Browse>SQL Servers> pick the server that the database is on.
THe Settings on the SQL Server blade will have a Firewall option.
Hope that helps

Just posted this screengrab for a different (unrelated) question, but: You'll find the firewall settings on the Server blade for your given SQL Database:
Here, you'll be able to add your IP (or IP ranges).
Note that you can easily get to the server blade from your database blade, by clicking the linked server name:

Related

I can't seem to connect to my Azure Database for MySQL server from my Azure Linux VM

I have a Linux Virtual Machine (Debian 9) deployed in Azure with Service Endpoints for Sql enabled and properly added -if I navigate the portal towards the VNet and enter the Service Endpoints tab, I can clearly see the Sql Service Endpoint listed. Just FYI, the reason for the Service Endpoint is that the VM has a dynamic IP, so I can't just whitelist it in the DB resource's configuration.
On the other hand, I have an 'Azure Database for MySQL server' deployed in the same resource group, same location and whatnot, but I can't seem to connect to it.
The steps I take when I try to connect are as follow:
I connect to the VM through SSH.
In my VM I have mysql-server installed
I write mysql --host <fully qualified server name> --user <server admin login name>#<server name> -p
I get the following error: "ERROR 9002 (28000): Server is not ready for incoming connections."
I've been reading the documentation and searching in forums for a reason why this might be happening, but I simply cannot seem to make it work. I have tried changing the status of the "Allow access to Azure services" option in the Connection security tab of the DB resource, but it doesn't seem to matter.
Could anyone have any idea of how I might go about solving this??
You said you enabled the SQL endpoint on the virtual network, but did you add a VNET rule to the instance (Attach an existing VNET)? You can find this in Azure Database for MySQL server -> Connection Security -> VNET Rules -> Attach existing VNET.
If you can't see your VNET listed then there is a mismatch between the regions of your SQL server and your VNET: They must be deployed to the same one. Additionally check that you have a General Purpose or Memory Optimized server, this feature is not available in Basic tier.
If all of this is in place, try enabling Diagnostics on the SQL Server, try logging in again a few times, then view the log file and post anything strange.

Error trying to connect to Azure SQL DB using Azure Query Editor (preview)...firewall settings already made

I have been searching for an answer on this one most of the day. I am working to deploy an Azure SQL database. I have followed a tutorial to create a new DB along with the associated resource group and server. I then followed an additional tutorial to add both my local desktop IP and turn on "Allow Azure Services" in the SQL server's firewall. When I try to connect with the Azure Query Editor (preview) it tries for about 20 seconds and then I get an error "A connection to the server 'myserver.database.windows.net' could not be established. This may indicate an issue with your network connection or firewall configuration. Please check your network connection and try again." I have double and triple checked the firewall settings and since I am using an Azure Query Editor I wouldn't think my local computer's firewall would be causing any issues but just in case I tried turning off all my local firewall and antivirus, no difference. As an aside I also cannot connect using SSMS but I know that adds additional client-side issues so I would be happy for now just to have Query Editor work. Any ideas would be appreciated.
slimmorama
After much messing around I found 2 issues that were causing my problem:
I had opened the SQL ports in my Windows firewall but it turns out they were also being blocked by my ISP router firewall, after fixing that I got a different error, which was fixed by...
It turns out I have a dynamic IP so every so often I need to check and replace the "allow my local IP" setting in the Azure firewall rules to account for the changed IP.
After fixing both of these I was finally successful in using both Azure Query Editor AND SSMS from my local machine to access the Azure SQL DB.
slimmorama

connect to azure sql server through datacenter ip address

I trying connect to azure sql server (xxxx.database.windows.net) through datacenter ip addres, i changed connect policy by proxy, but now i don't know how connect to instance the sql server.
https://learn.microsoft.com/en-us/azure/sql-database/sql-database-connectivity-architecture
You may have to add the datacenter IP range as a rule on the Azure SQL Database firewall rule. Please download and read this document to know the current IP range of the datacenter where your database resides.
Alternatively you can also set "Allow Access to Azure Services" to On (see image below), although this option configures the firewall to allow all connections from Azure including connections from the subscriptions of other customers.
In addition to configure the firewall, for security reasons make sure your login and user permissions limit access to only authorized users.
This guide may provide you additional valuable information to connect to your Azure SQL databases.

Azure Site-To-Site connectivity and SQL IaaS

If I create a VNet named mySiteToSitevNet and configure it for Site-To-Site connectivity. I create a Virtual Machine assign it to use mySiteToSiteVNet as its network. I Install SQL Server on it.
Do i get Public IP to connect to that SQL Server from my WebApp which does not have VNet associated to it?
If not, how do I make my WebApp connect to that SQL Server and use the database?
There are 2 options:
Since you already have a Sign to Site VPN then you can VPN in from your website's box to enable it to access the SQL and that's the most secure way.
If for some reason you don’t want to VPN in, first you need to figure out why you don’t want to do this. If there’s a really good reason to not VPN in, then continue with setting up direct Internet access to the SQL Server.
To open an endpoint browse to the VM in the Azure portal. Open the properties of the VM in the Azure Portal, then click the “All Settings” option. Then select “Endpoints”. It’ll look something like this.
If you see a “SQL Server” endpoint with 0 ACL Rules then the work is half done (shown above). If there are ACL rules then you should be finished unless you need to add more ACL Rules.
If there is no SQL Server endpoint click the “Add” button at the top of the Endpoints blade. Name the endpoint “SQL Server”, select the protocol TCP, then set the ports to 1433 (or whatever TCP ports you want to use, but 1433 is the default). Select to setup access rules for whoever needs access and block any subnets that don’t need access and then OK back to the VM’s properties.
At this point you can connect to the SQL Server instance through whichever method you’ve setup. If you are using either VPN option you can just connect to the Virtual Machine’s network name. If you are going through the public endpoint (again this is REALLY NOT recommended) you’ll need to connect to the machines full DNS name.
Any VM deployed in a Virtual network can also be exposed through public Internet, so the answer to your question is Yes, it can be given a instance lvel public IP address (https://azure.microsoft.com/en-us/documentation/articles/virtual-networks-instance-level-public-ip/) or port behind the public load balancer (https://azure.microsoft.com/en-us/documentation/services/load-balancer/)

How can I allow unknown users to access my SQL (Azure) DB?

Apparently one must explicitly specify (whitelist) the IP addresses that will be allowed access to a SQL Azure DB. I want, though, to have N-gazillion* users that will access these tables for data specific to them.
delusions of grandeur/megalomania
Will these need to first provide me with their IP address so that I can add it as a valid entry, or is there a programmatic way to do it, or some other workaround?
It would be advisable to have some sort of middle ware access the db and not your clients directly.
However if you want any IP to be able to connect to the db just add this entry to the firewall list:
Azure Portal -> Databases -> Servers -> Configure and add the following rule:
How will your users be accessing the DB, via a Web App (front end) or directly (I assume you won't give users direct access to your DB?), if its via a Web App (presentation layer) then all you need todo is grant access to this IP address of the presentation layer/service layer (and if hosted in Azure its beside it).
SQL DB Azure has two types of access restrictions (more info here) "Windows Azure SQL Database Firewall"
Server-level firewall rules:
Database-level firewall rules
You could either open up all IP address 0.0.0.0 - 255.255.255.255 (not very secure) or come up with more finer grained policies based on the above Database firewall rules.
The only way is to do it is via SQL query. Azure shows only Firewall Server rules to be visible only on the portal but on database level the only way is via SQL.
-- Enable Allconnections.
EXECUTE sp_set_database_firewall_rule N'Allow All', '0.0.0.0', '255.255.255.255';
Login to azure Portal
select your database subscription
click on Tools
Now there is option 'Open in VisualStudio' (click on it)
You can see "Configure Firewall" click on it.
Add you new IP.
Done :)
If you let them talk directly to your database (for example via SSMS) you need to enter their IP (or you can just whitelist the whole range). Usually they will use your database via your own API, then it's not needed to whitelist their IP addresses.

Resources