简体   繁体   English

从Azure Web应用连接到Prem SQL Server

[英]Connect to On Prem SQL server from Azure Web app

I have .Net application at on prim. 我在最初有.Net应用程序。 I want to host it at Azure but don't want to move database. 我想将其托管在Azure上,但不想移动数据库。 I publish the application on Azure but it is not able to connect to on prim database. 我在Azure上发布了该应用程序,但无法连接到主数据库。

SQL server is in private netwrok. SQL Server在专用netwrok中。

For POC purpose, I am using MSDN subscription. 出于POC目的,我正在使用MSDN订阅。 I am facing below error, 我面临以下错误,

A network-related or instance-specific error occurred while establishing a connection to SQL Server. 建立与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. 验证实例名称正确,并且已将SQL Server配置为允许远程连接。 (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (提供者:命名管道提供程序,错误:40-无法打开与SQL Server的连接)

Thanks, Umesh 谢谢,乌梅什

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. 由于本地数据库位于私有本地网络中,因此Azure服务找不到该数据库,因此您可以公开本地数据库的公共IP或将Azure Web应用程序服务VNetAzure VPN网关 集成以安全地访问Azure VNet或本地网络中的资源。

Another recommended method is to use an Azure App Service Hybrid Connections . 推荐的另一种方法是使用Azure App Service混合连接 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. 您将在数据库服务器或与本地数据库位于同一网络的另一台服务器中下载并安装代理(Hybrid Connection Manager)。

The main steps are as follows: 主要步骤如下:

  1. You configure a logical connection on your app service or web app. 您可以在应用程序服务或Web应用程序上配置逻辑连接。
  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. 将下载小型代理程序Hybrid Connection Manager,并将其安装在需要与之通信的远程网络(本地或任何地方)中运行的Windows Server(2012或更高版本)上。
  3. You log into your Azure subscription in the Hybrid Connection manager and select the logical connection in your app service. 您在混合连接管理器中登录Azure订阅,然后在应用程序服务中选择逻辑连接。
  4. The Hybrid Connection Manager will initiate a secure tunnel out (TCP 80/443) to your app service in Azure. Hybrid Connection Manager将启动到您的Azure应用服务的安全隧道(TCP 80/443)。
  5. Your app service can now communicate with TCP-based services, on Windows or Linux, in the remote network via the Hybrid Connection Manager. 您的应用程序服务现在可以通过Hybrid Connection Manager与Windows或Linux中远程网络中基于TCP的服务进行通信。

You could get more details on how to Connect Azure Web Apps To On-Premises . 您可以获得有关如何将Azure Web Apps连接到本地的更多详细信息。

Your on-premise SQL server must be hosted on public IP Address to connect from Azure Web APP. 您的本地SQL服务器必须托管在公共IP地址上,才能从Azure Web APP连接。 Once you will expose your SQL server on public IP, you should also apply firewall rules to ensure that only Azure Web App can access for security perspective. 一旦将SQL Server公开在公共IP上,还应该应用防火墙规则,以确保只有Azure Web App可以访问以获得安全性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM