Get the IP from an Azure account for SQL Server - c++

I have created a Database using SQL Server in Visual Studio. I have an Azure account where I want to store my datasabe. The problem is that I need to get the IP Address from the Azure account to write it in the code line.
This is the line I am refering to
(SQLDriverConnect(SQLConnectionHandle, NULL, (SQLCHAR*)"DRIVER=(SQL Server); SERVER=, ; DATABASE= projectBD; UID= myID; PWD= myPW", SQL_NTS, retConString, 1024, NULL, SQL_DRIVER_NOPROMPT))
In the SERVER part I need to write the IP of the server but I do not really know how to get it.
Help is much appreciated

By default, you use the DNS Name for the SQL Server to connect to. That's something like yourservername.database.windows.net.
For more information on Azure SQL connectivity, see Azure SQL Connectivity Architecture.
Taken from that article:
Connection Policy Proxy: all connections are proxied via the Azure SQL Database gateways. To enable connectivity, the client must have outbound firewall rules that allow only the Azure SQL Database gateway IP addresses (usually two IP addresses per region).
And
If you are connecting from outside Azure, your connections have a connection policy of Proxy by default. A policy of Proxy means that the TCP session is established via the Azure SQL Database gateway and all subsequent packets flow via the gateway.
The article also holds a list of all Azure SQL Database gateway IP addresses you could use to determine the IP address to use.

Related

How do I connect to Google Cloud SQL from Google Cloud Run via TCP?

Based on my current understanding, when I enable a service connection to my Cloud SQL instance in one of my revisions, the path /cloudsql/[instance name]/.s.PGSQL.5432 becomes populated. This is a UNIX socket connection.
Unfortunately, a 3rd party application I'm using doesn't support UNIX socket connections and as such I'm required to connect via TCP.
Does the Google Cloud SQL Proxy also configure any way I can connect to Cloud SQL via something like localhost:5432, or other equivalent? Some of the documentation I'm reading suggests that I have to do elaborate networking configuration with private IPs just to enable TCP based Cloud SQL for my Cloud Run revisions, but I feel like the Cloud Proxy is already capable of giving me a TCP connection instead of a UNIX socket.
What is the right and most minimal way forward here, obviously assuming I do not have the ability to modify the code I'm running.
I've also cross posted this question to the Google Cloud SQL Proxy repo.
The most secure and easiest way is to use the private IP. It's not so long and so hard, you have 3 steps
Create a serverless VPC connector. Create it in the same region as your Cloud Run service. Note the VPC Network that you use (by default it's "default")
Add the serverless VPC Connector to Cloud Run service. Route only the private IPs through this connector
Add a private connection to your Cloud SQL database. Attached it in the same VPC Network as your serverless VPC Connector.
The Cloud configuration is over. Now you have to get the Cloud SQL private IP of your instance and to add it in parameters of your Cloud Run service to open a connection to this IP.

Unable to connect to SQL Server on AWS RDS

I created a new SQL Server Express with 'admin' username & password.
I added inbound rules in Security Groups to allow all traffic from my laptop's IP address & default gateway (Do I need to do both Ipv4 address & also the gateway for connectivity to go thru?)
When I tried to connect to the newly created SQL Server via SSMS using SQL Server authentication with username admin & password that I used while creating the Instance. The connection fails with the error message below. What am I doing wrong?
TITLE: Connect to Server
Cannot connect to sql-xxxxxxxxxxxxx.rds.amazonaws.com.
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 53)
Check Public access for RDS Instance: You are trying to access the RDS instance from your laptop - means trying to access RDS from outside VPC that is hosting the instance. In that case you must enable public access to the RDS instance. This would assign a public IP. You can modify this feature after creating the RDS instance too.
Security Group rules: Port 1433 must be opened for the IP address you would like to access from - your home/work IP address. You can select 'My IP' on source when creating Security Group rules, this will set your IP automatically as source.
PS: Please make sure the subnet where RDS instance is hosted does not have any blocks at NACL level and subnet's route table has route to internet traffic, through Internet Gateway.

RDS SQL server TLS/SSL encrytion from application servers

Need to encrypt data in transit from application severs to RDS SQL server with SSL/TLS?
I see aws gives the option to make force encryption = true in parameter group with self signed certs.
Is there a way to use customer certs to import into RDS?
Any configuration steps to do this at application server and on RDS?
Appreciate any info on this . Didn't find anything in AWS knowledge base.
Note: Application servers sit behind load balancer.
For RDS SQL Server you will need to use the PEM that AWS provides for TLS.
You have a choice of either:
Root certificate
Intermediary and root certificate
The application server will need to have access to this certificate before it can connect to the RDS instance.
Unfortunately at this time only Aurora supports uploading your own certificates (and then accessing via ACM), you will need to use the provided one.
For connecting and configuring the RDS there is a specific Using SSL with a Microsoft SQL Server DB Instance page.

How safe is it to use cloud proxy for connection between VM and Paas instance in Google cloud

As I came to know that cloud proxy uses the public IP in the background. So how safe is it to use cloud proxy and what is the background process and how safe it is if we are using public IP in google cloud.
If you use a PaaS-based client application, most likely it has an ephemeral IP address. In this situation, restricting access based on the range of source IP addresses may be ineffective.
In such a case using Cloud SQL Proxy is optimal. As with many services that use public IP address, Google Cloud Proxy protects traffic in public networks by encryption. Traffic between the proxy client and the proxy server process is passed through the secure tunnel encrypted using AES cipher.
Apart from that, The SQL Proxy requires authentication and uses IAM to restrict access to the SQL instance.
You can find more information in the documentation:
Cloud SQL > Doc > MySQL > Connecting to Cloud SQL from external applications
Cloud SQL > Doc > MySQL > About the Cloud SQL Proxy:
The Cloud SQL Proxy provides secure access to your instances
without the need for authorized networks or for configuring SSL. The
proxy automatically encrypts traffic to and from the database
using TLS 1.2 with a 128-bit AES cipher; SSL certificates are used to
verify client and server identities.
The proxy uses a secure
tunnel to communicate with its companion process running on the SQL
server.
The proxy requires authentication. When you use a service
account to provide the credentials for the proxy, you must create it
with sufficient permissions: a role that includes the
cloudsql.instances.connect permission.
Cloud SQL > Doc > MySQL > Connecting from App Engine standard environment to Cloud SQL:
App Engine provides a mechanism that connects using the Cloud SQL
Proxy.
Once correctly configured, you can connect your service to
your Cloud SQL instance's unix domain socket using the format:
/cloudsql/INSTANCE_CONNECTION_NAME.
These connections are
automatically encrypted without any additional configuration.
Also, you may configure your systems so that use Private IP as described here:
Cloud SQL > Doc > MySQL > Private IP

tunnel way between Cloud SQL and GCE wih cloud proxy process on gcp

I am wondering tunneling way during commnunication between Cloud SQL and Cloud Sql proxy process.
https://cloud.google.com/sql/docs/mysql/sql-proxy
I refer to this URL.
I can see "he proxy uses a secure tunnel to communicate with its companion process running on the server."
Could you know what way of tunnel it use during connection ?
ssh tunnel or PPTP, IPSec , L2TP ?
As per the Cloud SQL Proxy documentation it uses a TLS encrypted tunnel as explained below:
Secure connections: The proxy automatically encrypts traffic to and from the database using TLS 1.2 with a 128-bit AES cipher; SSL certificates are used to verify client and server identities.
Easier connection management: The proxy handles authentication with Cloud SQL, removing the need to provide static IP addresses.