How to specify which ports my Worker Role needs?

376 views Asked by At

How to tell Azure I want my worker role to accept external (from the Internet) connections on port x?

Do I have to RDP in and modify the Windows Firewall to allow incoming connections on port x?

Will the IP address of my Worker Role VM change?

1

There are 1 answers

0
David Makogon On BEST ANSWER

You don't need to RDP to set up anything. In your worker role properties, you'll see a tab called Endpoints. Define a tcp "input endpoint" by giving it a name and port number to expose. Then, from within your code, you can call RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["endpointname"].IPEndpoint.Port. Then, just listen on this port. Note that you can set up the endpoint to be on a specific port internally (e.g. what faces your code vs the outside world) OR... let the load balancer assign a port dynamically. Either way, the call above returns the assigned port.

And no, your service IP address will never change unless you actually delete and redeploy your service. If you do an in-place upgrade (add/remove role, add/remove endpoint, change VM sizes, add local storage resources), you keep your IP address.