It’s been about two years since I had to set up a Hybrid Connection for one of my App Services. Last time and this time the use cases are basically the same. I have a Web API hosted on two on-prem boxes. One is the production box and the other is the testing box. Likewise, I have two App Services, one for production and one for testing. The production App Service needs to utilize the Web API on the production on-prem box, and the testing App Service needs to access the Web API on the testing on-prem box.
Last time, I set up a Hybrid Connection for each on-prem box. For both, I used the Endpoint Host "localhost" and the same port number (e.g. 3000). On the testing box, I used Hybrid Connection Manager to set up a connection to the testing Hybrid Connection, and vice versa for production.
The beauty of this is that the codebase that gets deployed to the App Services just calls the on-prem API using http://localhost:3000
. Because each App Service uses a different Hybrid Connection, the prod App Service uses the prod on-prem box and the testing App Service uses the testing on-prem box. There’s no need to determine the environment and use a different machine name to make the API calls.
Well, that’s all fine and dandy, except when I went to replicate this setup today for another API we need to expose, the Azure Portal would not let me use localhost as the Endpoint Host.
Did they change something, or am I just forgetting how to do this? Am I now forced to use the actual machine’s name, and make my codebase detect the environment and make API calls to different hosts based on that? The old ones are still using localhost and work just fine.
I’d really prefer to just use localhost if possible.
2
Answers
As explained in another answer, Azure no longer allows the use of localhost in this way. I was able to get past this issue while still keeping just one URL to use in all of my environments. What I did was:
my-hybrid-connection
) and set it to point at127.0.0.1
(which is localhost).3000
).my-hybrid-connection:3000
.As mentioned in the MSDoc, do not use
localhost
if your App is deployed onWindows App Service
.I have tried in both
Windows
andLinux
App Service but getting the same issue.In other words, the error indicates that the name
localhost
is already in use.Make sure it is not used before.
I have tried to use the
IP Address
without any issue,Thanks @devblogs for the explanation.
As per the Developer Support Doc, it clearly says not to use
localhost
.May be Azure has made changes in the existing configuration.