Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
649 views
in Technique[技术] by (71.8m points)

c# - Connect to On Prem SQL server from Azure Web app

I have .Net application at on prim. I want to host it at Azure but don't want to move database. I publish the application on Azure but it is not able to connect to on prim database.

SQL server is in private netwrok.

For POC purpose, I am using MSDN subscription. I am facing below error,

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)

Thanks, Umesh

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Since your on-premise database is in your private on-premise network, Azure service could not find it, you could expose a public IP for the on-premise database or use Azure web app service VNet integration with Azure VPN gateway to securely access the resource in an Azure VNet or on-premise network.

Another recommended method is to use an Azure App Service Hybrid Connections. To do this, you need to add and create Hybrid Connections in your app. You will download and install an agent (the Hybrid Connection Manager) in the database server or another server which is in the same network as the on-premise database.

The main steps are as follows:

  1. You configure a logical connection on your app service or web app.
  2. A small agent, the Hybrid Connection Manager, is downloaded and installed on a Windows Server (2012 or later) running in the remote network (on-premises or anywhere) that you need to communicate with.
  3. You log into your Azure subscription in the Hybrid Connection manager and select the logical connection in your app service.
  4. The Hybrid Connection Manager will initiate a secure tunnel out (TCP 80/443) to your app service in Azure.
  5. Your app service can now communicate with TCP-based services, on Windows or Linux, in the remote network via the Hybrid Connection Manager.

You could get more details on how to Connect Azure Web Apps To On-Premises.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...