Search code examples
azureazure-worker-roles

Able to access Internal endpoint of WorkerRole


I have a worker role. I have defined an input endpoint with public port 8080 and private port as 8081. I am unable to access 8080 which should redirect to private port, and I am able to access internal endpoint (private port) directly which should not be.

My worker role run method is overridden with.

HttpListener objHttpListener = new HttpListener();
            objHttpListener.Prefixes.Add("http://+:8081/");
            objHttpListener.Start();

and I am trying to access using http//localhost:8080 which is not working. http//localhost:8081 is working which is private port.


Solution

  • Endpoint mappings are specifically from a public port to a private port. The public port is only accessible if you go through the public endpoint.

    So, in your case, you mapped public port 8080 to private (local) port 8081. If you want to open a connection from within your role instance, you can either:

    • Connect to yourapp.cloudapp.net:8080 (which will actually connect to your VM's local port 8081)
    • Connect to localhost:8081

    You cannot connect to localhost:8080 and and expect traffic to be routed to port 8081. The port-mapping is done via an Azure load balancer, outside of the VM (the role instance) itself.