Using new Windows Azure SDK 1.5 testing application in compute emulator is much closer to real cloud platform.
There are significant changes in Windows Azure SDK 1.5 compute emulator behavior with regard to load balancer related IP settings.
If you remember In SDK 1.4, multiple instances of role deployments were allocated the same IP address – 127.0.0.1, but different (increasing) port numbers. So if you have two instance for a single web role, you would get IP address for instance 1 as 127.0.0.1:81 and IP address for instance 2 as 127.0.0.1:82.
With Windows Azure SDK 1.5, multiple instances of your role deployments are allocated different IP addresses while trying to maintain the port specified in the service definition. Hence, two instances of same web role deployments would get two different IP Address as 127.0.0.1:81 and 127.0.0.2:81, if 81 is the port specified in service definition.
Here is an example:
In my web role I have set the instance count to 3 as below:
I have also added the following code in role on start function to print IP address and port in debug window:
public override bool OnStart()
Trace.WriteLine("IP Address: " + RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["Endpoint1"].IPEndpoint.Address.ToString());
Trace.WriteLine("Port: " + RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["Endpoint1"].IPEndpoint.Port);
Now when I run my application in compute Emulator I see all 3 instances get different IP address as below:
Instance #1 has IP address 127.255.0.0 and Port 82
Instance #2 has IP address 127.255.0.1 and Port 82
Instance #3 has IP address 127.255.0.2 and Port 82