Reputation: 3435
I've got an Azure Virtual Network setup and a VM setup within the network. I've installed the Hybrid Connection Manager app on the VM.
I also have an Azure App Service and I've created a hybrid connection between it and the VM and they are both claiming they are happily connected to each other.
Also on the VM I've installed an app that is listening on http://localhost:1234
Can someone tell me what IP I use from my app service to talk to http://localhost:1234 on the VM? e.g. Is it [VM internal IP]:1234 or [VM public IP]:1234, or something else. Nothing is talking at the moment so I want to make sure the IP address is not the problem.
Upvotes: 2
Views: 1412
Reputation: 26324
Just use the computer name of the VM. For example, call to SQLSRV009:1234
from your code in App Service. The Hybrid Connection definition in the portal should reflect the same name (same as computer name, same as what you're calling from your code).
Check out this well written guide for the full picture — https://learn.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
Also make your app listen on either 0.0.0.0
or the private IP since i'm not terribly sure localhost
will work with HC.
Why not use VNET integration for the Web App? All you need to do is create a route based (IKEv2) VPN gateway in the VNET, like so — https://learn.microsoft.com/en-us/azure/app-service/web-sites-integrate-with-vnet
Upvotes: 3
Reputation: 19195
You should use VM host name
, thanks for evilSnobu's link .
If you use an IP address, you may or may not reach the on-premises resource, depending on your client.
If you use VM public IP
, traffic packets are transmitted over the Internet to your VM not VPN tunnel. localhost
only could be used inside VM.
Also, if your app is listening on localhost(127.0.0.1)
, the service only could access inside your VM. As evilSnobu said, you need modify your service listening on 0.0.0.0
or private IP(like 10.0.0.4)
. You could check with following command.
For Linux
netstat -ant|grep 1234
For Windows
netstat -ant|findstr 1234
Upvotes: 2