Hosting a WCF service endpoint for Azure Service Bus Relay inside an Azure WebSite

201 Views Asked by At

We're developing a solution that will be hosted as an Azure WebSite. We want to expose a service that can be called from an on-premise solution. Instead of having to deal with security for that service on the Web site, we're thinking that we could expose it as a service point as a Service Bus relay endpoint. Works fine when running locally on my dev machine. But running it in azure yields the following exception : "An address incompatible with the requested protocol was used"

I've tried with both IPV4 and IPV6 : net.tcp://localhost:1234/myservice net.tcp://[::1]:1234/myservice

1

There are 1 best solutions below

0
On BEST ANSWER

The answer to this is pretty simple - don't use localhost or IPV6 [::1] - get the IP address from the machine its running on with the following code:

var ip = Dns.GetHostEntry(Dns.GetHostName()).AddressList.Where(o => o.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork).First().ToString();