0
votes

I have a Cloud Service with a Worker role configured. The worker role basically listens on a port and performs actions as required. What I want to be able to do is configure that worker role to have multiple instances running but to have each instance configured to listen on a different port (input endpoint).

Is this possible in Microsoft Azure?

1

1 Answers

1
votes

Having each worker instance doing something different is against-the-grain for what cloud services are designed for. That is: It's designed for stateless scale-out: Each instance doing the same thing, but being able to scale for more traffic/capacity/cpu/whatever. In your case, that would mean having each worker instance listening in on all ports for all possible incoming traffic, and processing all traffic that comes in.

That said: You can configure an InstanceInputEndpoint to forward port-specific traffic to specific worker instances. The schema detail for configuring InstanceInputEndpoint is here. You might still need some decision-making logic in your worker instances, to determine what work it should be doing (and how you do this is specific to your app). And if you need to determine, inside an instance, the instance ID, you'd need to look at RoleEnvironment.CurrentRoleInstance.Id (assuming the Id doesn't change over time).