如何通过 VPN 网关使用专用终结点连接到 Azure SQL 数据库

How do I connect to Azure SQL Database using Private Endpoint trough VPN gateway

问题:

我可以使用私有 link 从虚拟网络中的 VM 连接到 Azure SQL 数据库,但不能通过虚拟网络网关从我的电脑连接

  1. 在 sqlserver1 防火墙中,我拒绝public网络访问
  2. 从 myvnet 中的 MyVM,我能够使用 FQDN 连接到 sqlserver1。 nslookup 正确显示私有地址 10.0.0.4
  3. 我使用网关将我的电脑连接到 vnet。 我可以使用私有地址 10.0.0.5 ping MyVM。
  4. 当我尝试使用 FQDN 连接到 sqlserver1 时,出现错误:

    An instance-specific error occurred while establishing a connection to SQL Server. The public network interface on this server is not accessible. To connect to this server, use the Private Endpoint from inside your virtual network. (Microsoft SQL Server, Error: 47073)

所以看起来它使用的是 public dns 记录,而不是我使用专用端点创建的专用 dns 区域。如何连接到数据库?

在这种情况下,您可以在 PC 上使用 NSLOOKUP FQDN 来验证私有 DNS 区域是否有问题。

您需要正确配置您的 DNS 设置以解析分配的私有 IP 地址。您可以关注 On-premises workloads using a DNS forwarder and this blog 关于 Azure SQL DB Private Link / Private Endpoint - Connectivity Troubleshooting.

It's not recommended to override a zone that is actively in use to resolve public endpoints. Connections to resources won't be able to resolve correctly without DNS forwarding to the public DNS. To avoid issues, create a different domain name or follow the suggested name for each service below.

要正确配置,您需要以下资源:

  • On-premises 网络
  • 虚拟网络连接到 on-premises
  • DNS 转发器 部署在 Azure
  • 私有 DNS 区域 privatelink.database.windows.net,记录类型 A
  • 私有终结点信息(FQDN 记录名称和私有 IP 地址)