c# - 从 Azure Web 应用程序连接到 On Prem SQL 服务器

标签 c# sql-server azure azure-hybrid-connections

我在 prim 上有 .Net 应用程序。我想将其托管在 Azure,但不想移动数据库。我在 Azure 上发布应用程序,但它无法连接到 prim 数据库。

SQL Server 位于专用网络中。

出于 POC 目的,我正在使用 MSDN 订阅。我遇到以下错误,

建立与 SQL Server 的连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称是否正确以及 SQL Server 是否配置为允许远程连接。 (提供程序:命名管道提供程序,错误:40 - 无法打开与 SQL Server 的连接)

谢谢, 乌梅什

最佳答案

由于您的本地数据库位于私有(private)本地网络中,Azure 服务无法找到它,您可以为本地数据库公开公共(public) IP 或使用 Azure Web 应用服务 VNet integrationAzure VPN gateway安全地访问 Azure VNet 或本地网络中的资源。

另一种推荐的方法是使用 Azure App Service Hybrid Connections 。为此,您需要 add and create Hybrid Connections in your app 。您将在数据库服务器或与本地数据库位于同一网络的其他服务器中下载并安装代理(混合连接管理器)。

主要步骤如下:

  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.

您可以通过 how to Connect Azure Web Apps To On-Premises 获取更多详细信息.

关于c# - 从 Azure Web 应用程序连接到 On Prem SQL 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54821962/

相关文章:

azure - 使用 for_each 资源 block 中的资源 ID

c# - 如何使用 XPATH 解析以下具有命名空间的内容?

c# - 服务结构中的配置转换?

azure - 从 Azure 中的虚拟机连接到集群服务

sql-server - Azure 本地数据网关 - 是正确的选择,还是矫枉过正?

SQL:在 1 列上选择不同

azure - 如何更改Azure虚拟机中的时区?

c# - 用霍纳方案简化算法

c# - 我是否干净地编写了这个异常处理?

java - 查找从一个表到另一个表的连接路径