Connect to Azure SQL in another subscription - azure

I have an application running in Azure Batch which tries to connect to our customer's SQL Server also running in Azure. The connection fails, because the customer has default firewall on the SQL Server and the IP address of the Azure Batch node is not allowed in the firewall rules.
When I try to connect from the Azure Batch application to out SQL Server running in another subscription, the connection is successful.
Why in the first case the connection does not work and in the second case it works?
Is it possible to connect to the customer's SQL Server? I cannot give them an IP address to allow in the firewall, because the IP address of the Azure Batch is dynamic.

The solution is to set this switch to Yes in SQL Server → Security → Firewalls and virtual networks. With this setting, it is possible to connect from Azure Batch application to SQL in another subscription.

Related

Connect Azure SQL Server (PaaS) to a VM Scale set

How to connect Azure SQL Server (PaaS) to a VM Scale set. The Azure SQL Server has firewall and other network settings. I just want the common procedure like adding a VNet / subnet..
• With regards to network and firewall configuration, ensure that your Azure SQL Server has allowed inbound connections and traffic over SQL TCP port 1433 from the Azure VMSS if you are configuring this infrastructure in private, internal mode, i.e., within your specified virtual networks only.
• Connections between the same virtual network are allowed by default, thus if the Azure SQL server and the VMSS are in different virtual networks, then only the above connections are required. Also, ensure that outbound as well as the inbound traffic on the VMSS has been allowed on the above said TCP ports in the firewall and the NSG.
• Ensure that SQL Server allows connections over TCP ports, has enabled SQL Server authentication with a SQL login and password with permissions to access the hosted SQL database.
For more clarification, kindly refer the below documentation link for more details: -
https://learn.microsoft.com/en-us/azure/azure-sql/virtual-machines/windows/ways-to-connect-to-sql?view=azuresql#connect-to-sql-server-within-a-virtual-network
https://learn.microsoft.com/en-us/azure/azure-sql/managed-instance/connect-vm-instance-configure?view=azuresql
As above, you can configure a private endpoint for the Azure SQL Database server and then use the SQL Server Management Studio from the VMSS to access the SQL Database server from it using the private DNS FQDN of the private endpoint over the specified subnet only.
Similarly, as shown below in the snapshot, the virtual network subnet for the VMSS is also added as a rule in the selected networks section.

How to connect to Azure pass DB from a secure network

I would like to connect to Azure SQL server from a Window server via SSMS. In the “set server firewall” from Azure, I have given my server IP ( from the system I would like to connect). I need to know the destination IP adders of the Azure DB Server. From Azure portal the location is showing central US . To allow firewall I need to know the destination IP address.
My questions are:
1. As Central US could have multiple IP addresses, do I need to provide all IPs to my Firewall team?
2. How can I know the destination IP address ( i.e. Azure) so that I can provide that to my firewall team?
Note: From SQL server management studio, the tcp default port for SQL is enabled and services are running fine.
Hope I have explained it correctly.Thanks
No. You cannot get a static IP address assignment for your Azure SQL Database. Moreover, what you refer (mysqlserverdatabase.mysql.database.azure.com designates your Azure SQL Database Server, not a single Database. This is a logical server, in which you can put up to 149 Databases (150 with the Master DB).
You have to workaround your requirement for static IP address assingment to work with the DNS Name (mysqlserverdatabase.mysql.database.azure.com).
Otherwise if your company firewall can't work with the DNS Name ,you need to set the server connection policy to Proxy as documented in Azure SQL Connectivity Architecture. This allows the database gateway to proxy all traffic between the client and the DB server. The gateways all have static IP addresses, which are listed in the above document.
If you have setup a VNet in Azure, checkout VNet Service Endpoints to connect Azure SQL.
https://azure.microsoft.com/en-in/blog/vnet-service-endpoints-for-azure-sql-database-now-generally-available/

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.

unable to connect ms sql server from azure app

I have Azure app and SQL Database.SQL URL like jdbc:sqlserver://xxxxx.database.windows.net:1433;databaseName=xxxxx that one try connect my local tomcat,its successfully connected.but when try connected from Azure app,I am getting exception
[org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (JCA PoolFiller) IJ000610: Unable to fill pool: java:jboss/DB/DS: javax.resource.ResourceException: IJ031084: Unable to create connection
at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createLocalManagedConnection(LocalManagedConnectionFactory.java:345)
at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.getLocalManagedConnection(LocalManagedConnectionFactory.java:352)
at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:287)
at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.createConnectionEventListener(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:1320)
at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.fillTo(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:1136)
at org.jboss.jca.core.connectionmanager.pool.mcp.PoolFiller.run(PoolFiller.java:97)
at java.lang.Thread.run(Thread.java:748)
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Cannot open server "App-server" requested by the login. The login failed.
but i can't use from azure app server (VM) from sql Database
Do you mean you application hosting on Azure VM?
If I understand it correctly, you should add Azure VM's public IP address to sql server firewall.
Via Azure portal to add VM's IP address:
Also you should add port 1433 to VM's NSG inbound rules and OS firewall settings.
Please make sure you have set On the "Allow access to Azure services" setting on Azure portal for the Azure SQL database or its logical server. Please see below image.
You need to also specify the user#database on the connection string. Please read here for more details on how to build the connection string.

Restricting access to Azure SQL from Azure VM

Since Azure SQL have only DNS address and no IP , we can not enforce ACL's/NSG's on our Azure app VM as it needs to communicate with our Azure SQL..
ACL's/NSG's only have IP ranges restriction..no DNS restrictions..
So , potentially, a hacker who managed to sneak to our Azure App VM , can push its stolen data to what ever IP he wants as long as he is going out in port 1433.
Anyway we can restrict outbound communication from Azure VM only to our Azure SQL ?
You are correct, you can not place an Azure SQL Database within a Virtual Network (VNet). Also, you can only configure a NSG Outbound Security rule to use a Tag that restricts communication to Internet, Azure Load Balancer, or Azure Traffic Manager endpoint. So, unfortunately, it's currently not possible to restrict an Azure VM with NSG to only be able to communicate to a specific Azure SQL Database over Port 1433.
However, on the other side you can restrict the Azure SQL Database firewall rules to only allow your Azure VM to connect to the database by specifying it's IP Address in the SQL Database Firewall rules.

Resources