Unable to access a self-hosted WCF service on azur

2019-08-19 02:56发布

问题:

I have self-hosted a WCF service on base adress new Uri("http://" + Environment.MachineName + ":1235/myService") on an Azure Virtual Machine. I have printed this address and I get it as http://TRIALVM:1235/IRChatbotService. The DNS name of my virtual machine is trialvm.cloudapp.net.

As I have hosted this service on port 1235, I have added the inbound rule with following properties:

Still the created service is not accessible from outside VM. I am able to get service page when I go to the service URL http://TRIALVM:1235/IRChatbotService on the same virtual machine, but not from my local computer.

回答1:

Have you opened the endpoint on the Azure portal. By default the machine is firewalled from Azure as well...not just your VM.

https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-set-up-endpoints/



回答2:

If you're using http://TRIALVM:1235/IRChatbotService to access the web service from outside the VM it won't work. TRAILVM is the hostname which is resolvable within the cloud service but from the outside world you need the domain name of the cloud service/load balancer, in this case both the VM and the cloud service are called trialvm but they can be different as you can have many vms in a cloud service. In this case the domain name looks to be trialvm.cloudapp.net.

Hth, Gareth