简体   繁体   English

Azure 应用服务 (ASE) SQL Azure 连接

[英]Azure app service (ASE) SQL Azure connection

I have an app service located inside the app service environment(ASE).我有一个位于应用服务环境 (ASE) 内的应用服务。 I have a virtual network which I have put ASE into the subnet in the Vnet.我有一个虚拟网络,我已将 ASE 放入 Vnet 的子网中。

What I am trying to do is, I am trying to connect SQL Azure endpoint which is not in Vnet or my azure tenant.我想要做的是,我正在尝试连接不在 Vnet 或我的 azure 租户中的 SQL Azure 端点。 ASE has an outbound IP address and when I try to tcpping to azure SQL endpoint, it is responding me without any issue. ASE 有一个出站 IP 地址,当我尝试 tcpping 到 azure SQL 端点时,它可以毫无问题地响应我。

The problem is when I try to connect SQL endpoint inside the application, I am getting "Cannot open server" error.问题是当我尝试在应用程序内部连接 ​​SQL 端点时,出现“无法打开服务器”错误。 It usually happens when there is firewall in SQL Azure endpoint.当 SQL Azure 端点中有防火墙时,通常会发生这种情况。 I have checked log analytics (in target SQL endpoint) and saw my app connection is blocked but when I check the client IP, it shows me private IP of ASE.我检查了日志分析(在目标 SQL 端点中)并看到我的应用程序连接被阻止,但是当我检查客户端 IP 时,它显示了我的 ASE 私有 IP。 I really don't understand how it can be possible?我真的不明白这怎么可能? I would see my public ip in there, since ASE is external ASE.我会在那里看到我的公共 IP,因为 ASE 是外部 ASE。

Do you have any idea how that can be possible?你知道这怎么可能吗?

If you have enabled the virtual network service endpoint for Microsoft.Sql in the ASE subnet, When you connect to your Azure SQL server with service endpoints turned on, the source IP of SQL connections will switch to the private IP space of your VNet.如果在 ASE 子网中为Microsoft.Sql启用了虚拟网络服务终结点,当你连接到 Azure SQL 服务器并打开服务终结点时,SQL 连接的源 IP 将切换到 VNet 的私有 IP 空间

If so, you need to allow the given VNet/subnet by specifying it in the VNet firewall rules of the SQL server.如果是这样,您需要通过在 SQL 服务器的 VNet 防火墙规则中指定来允许给定的 VNet/子网。 If you do not want to use a virtual network service endpoint, you can whitelist the outbound IP address of the application in the firewall of the SQL server.如果您不想使用虚拟网络服务端点,您可以在 SQL 服务器的防火墙中将应用程序的出站 IP 地址列入白名单。 在此处输入图片说明

For more information, you could read the blog1 and blog2 .有关更多信息,您可以阅读blog1blog2

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

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