0

I have the following application deployed in an Azure app service

static void Main(string[] args)
{
            SqlConnection con;
            try
            {
                con = new SqlConnection(args[0]);
                con.Open();
                Console.WriteLine("Connection opened");
                con.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
}

The webapp is connected to a VNET that has a gateway to the an external network where the database is connected.

If I run this app against the database in the external DB, that it can not be reachable.

The connection string is OK.

The DB is working.

If I run this app in a VM also connected to the same VNET, it can reach the DB without problem.

tcpping works correclty.

Any idea about this? Some missing configuration?

1 Answers1

0

If you want to connect to the database in vnet, there are two ways as far as I know that you can follow.

One is that you can create the web app and the database in the same vnet through the ASE. For more details, see App Service Environments.

Another one is that you can create a P2S VPN between the Web App and the Vnet which the database in. For more details, see Integrate your app with an Azure Virtual Network.

Hope this will help you!

Charles Xu
  • 29,862
  • 2
  • 22
  • 39