Handling "System.ServiceModel.AddressAlreadyInUseException: HTTP could not register URL" Exception in Compute Emulator with Windows Azure SDK 1.5

Using Windows Azure SDK 1.5, if you create a worker role with HTTP internal endpoint and you have weak wildcard binding (https://+:<port_number>) setting you may encounter the following error while running your application in compute emulator.

 

System.ServiceModel.AddressAlreadyInUseException: HTTP could not register URL https://+:<port_number>/. Another application has already registered this URL with HTTP.SYS. ---> System.Net.HttpListenerException: Failed to listen on prefix 'https://+:<port_number>/' because it conflicts with an existing registration on the machine.

 

Up to Windows Azure SDK 1.4 when you have multiple instances based Windows Azure application running in Compute Emulator, all instances had same IP address but different port however with SDK 1.5, not all instances will have different IP address & port for each instance. (Click here for more info). This is the reason having weak wildcard binding will cause above error.

 

To solve this problem In SDK 1.5, you can bind to the specific IP rather than using the weak wildcard "+" so when you run your multiple instances based Windows Azure application in compute emulator it will not cause the above described error.