Azure 虚拟网络混合连接
Azure virtual network hybrid connection
我在网络中设置了 Azure 虚拟网络和 VM。我已经在 VM 上安装了混合连接管理器应用程序。
我还有一个 Azure 应用服务,我在它和 VM 之间创建了一个混合连接,它们都声称它们很高兴地相互连接。
我还在虚拟机上安装了一个正在侦听 http://localhost:1234
的应用程序
谁能告诉我我使用应用服务中的哪个 IP 与 VM 上的 http://localhost:1234 通信?例如是 [VM 内部 IP]:1234 还是 [VM public IP]:1234,还是其他。目前没有任何对话,所以我想确保 IP 地址不是问题所在。
只需使用虚拟机的计算机名称即可。例如,从应用服务中的代码调用 SQLSRV009:1234
。门户中的混合连接定义应反映相同的名称(与计算机名称相同,与您从代码中调用的名称相同)。
查看这份写得很好的指南以了解全貌 —
https://docs.microsoft.com/en-us/azure/biztalk-services/integration-hybrid-connection-create-manage
It is possible to set a Hybrid Connection endpoint to an IP address. If you use an IP address, you may or may not reach the on-premises resource, depending on your client.
The Hybrid Connection depends on the client doing a DNS lookup. In most cases, the client is your application code. If the client does not perform a DNS lookup, (it does not try to resolve the IP address as if it were a domain name (x.x.x.x)), then traffic is not sent through the Hybrid Connection.
For example (pseudocode), you define 10.4.5.6 as your on-premises host:
The following scenario works:
Application code -> GetHostByName("10.4.5.6") -> Resolves to 127.0.0.3 -> Connect("127.0.0.3") -> Hybrid Connection -> on-prem host
The following scenario doesn't work:
Application code -> Connect("10.4.5.6") -> ?? -> No route to host
还要让您的应用监听 0.0.0.0
或私有 IP,因为我不太确定 localhost
是否可以与 HC 一起使用。
为什么不对 Web 应用程序使用 VNET 集成?您需要做的就是在 VNET 中创建一个基于路由的 (IKEv2) VPN 网关,就像这样 —
https://docs.microsoft.com/en-us/azure/app-service/web-sites-integrate-with-vnet
你应该使用 VM host name
,感谢 evilSnobu 的 link。
If you use an IP address, you may or may not reach the on-premises
resource, depending on your client.
如果您使用 VM public IP
,流量数据包将通过 Internet 传输到您的 VM,而不是 VPN 隧道。 localhost
只能在VM内部使用。
此外,如果您的应用正在侦听 localhost(127.0.0.1)
,该服务只能在您的 VM 内部访问。正如 evilSnobu 所说,您需要修改监听 0.0.0.0
或 private IP(like 10.0.0.4)
的服务。您可以使用以下命令进行检查。
对于Linux
netstat -ant|grep 1234
对于Windows
netstat -ant|findstr 1234
我在网络中设置了 Azure 虚拟网络和 VM。我已经在 VM 上安装了混合连接管理器应用程序。
我还有一个 Azure 应用服务,我在它和 VM 之间创建了一个混合连接,它们都声称它们很高兴地相互连接。
我还在虚拟机上安装了一个正在侦听 http://localhost:1234
的应用程序谁能告诉我我使用应用服务中的哪个 IP 与 VM 上的 http://localhost:1234 通信?例如是 [VM 内部 IP]:1234 还是 [VM public IP]:1234,还是其他。目前没有任何对话,所以我想确保 IP 地址不是问题所在。
只需使用虚拟机的计算机名称即可。例如,从应用服务中的代码调用 SQLSRV009:1234
。门户中的混合连接定义应反映相同的名称(与计算机名称相同,与您从代码中调用的名称相同)。
查看这份写得很好的指南以了解全貌 — https://docs.microsoft.com/en-us/azure/biztalk-services/integration-hybrid-connection-create-manage
It is possible to set a Hybrid Connection endpoint to an IP address. If you use an IP address, you may or may not reach the on-premises resource, depending on your client.
The Hybrid Connection depends on the client doing a DNS lookup. In most cases, the client is your application code. If the client does not perform a DNS lookup, (it does not try to resolve the IP address as if it were a domain name (x.x.x.x)), then traffic is not sent through the Hybrid Connection.
For example (pseudocode), you define 10.4.5.6 as your on-premises host: The following scenario works:
Application code -> GetHostByName("10.4.5.6") -> Resolves to 127.0.0.3 -> Connect("127.0.0.3") -> Hybrid Connection -> on-prem host
The following scenario doesn't work:
Application code -> Connect("10.4.5.6") -> ?? -> No route to host
还要让您的应用监听 0.0.0.0
或私有 IP,因为我不太确定 localhost
是否可以与 HC 一起使用。
为什么不对 Web 应用程序使用 VNET 集成?您需要做的就是在 VNET 中创建一个基于路由的 (IKEv2) VPN 网关,就像这样 — https://docs.microsoft.com/en-us/azure/app-service/web-sites-integrate-with-vnet
你应该使用 VM host name
,感谢 evilSnobu 的 link。
If you use an IP address, you may or may not reach the on-premises resource, depending on your client.
如果您使用 VM public IP
,流量数据包将通过 Internet 传输到您的 VM,而不是 VPN 隧道。 localhost
只能在VM内部使用。
此外,如果您的应用正在侦听 localhost(127.0.0.1)
,该服务只能在您的 VM 内部访问。正如 evilSnobu 所说,您需要修改监听 0.0.0.0
或 private IP(like 10.0.0.4)
的服务。您可以使用以下命令进行检查。
对于Linux
netstat -ant|grep 1234
对于Windows
netstat -ant|findstr 1234