0

I have an ASPNET .Core application running on a pod in Kubernetes in AKS. The pod's network is an Azure's private network that is linked to my company's on-premise network via VPN. The web application at runtime connects to different SQL Server DB instances that reside both on the Azure's private network and on the company's on-premise network (I cannot move those on the Azure's network).

The problem that I have is that the web application can access the SQL Server instances that reside on the Azure private network but cannot reach the on-premise's ones. To solve the problems I was thinking to enable a Squid SOCKS proxy on the Azure network that would proxy all the connections to the SQL Servers in the company network. I used this same method to let the application connect to some HTTP services that reside on the company's network using a Squid HTTP proxy, and it's working.

The question is, how to configure the .net core application in order to let it use the SOCKS proxy when using the SqlConnection class? This is how currently I connect to the DBs

using SqlConnection conn = new SqlConnection(connectionString);
conn.Open();
using (SqlCommand command = new SqlCommand(query, conn))
using (SqlDataReader reader = command.ExecuteReader())
{
    while (reader.Read())
    {
        results.Add(tupleHandler(reader));
    }
}
conn.Close();

Thank you

gvdm
  • 3,006
  • 5
  • 35
  • 73
  • I understand this is not directly answering your question, and is a pretty long shot. just wondering if you checked whether [gateway transit feature](https://learn.microsoft.com/en-us/azure/virtual-network/virtual-network-peering-overview#gateways-and-on-premises-connectivity) can help you establish connectivity – timur Nov 04 '20 at 23:59

1 Answers1

0

SQL Server works over tcp protocol, so solution over http-proxy will not work. As @timur said you need to expose your SQL endpoint over some hybrid VPN gateway. This answer should lead you in the right direction

Victor Fialkin
  • 165
  • 4
  • 7