locked
Connect ASPNET Core web application to a Sql Server database through a SOCKS proxy RRS feed

  • Question

  • 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));
        }
    }

    Thank you

    Tuesday, October 27, 2020 1:39 PM

All replies

  • This forum is for C#-specific questions only. Please post questions related to ASP.NET in the ASP.NET forums. For questions related to Azure post in the Microsoft Q&A forums.

    Michael Taylor http://www.michaeltaylorp3.net

    Tuesday, October 27, 2020 3:28 PM