Azure Compute Emulator: Can I manage the IP addresses of individual instances?

Working with the June 2012 Azure SDK, Visual Studio 2010 and IIS Express, I have a web application running on 127.255.0.2. I use ACS for authentication, and my application is configured as a relying party on this IP address. I added a new working role to my solution, and for some reason this caused my web application IP to return to 127.255.0.3. This is the third time that changes elsewhere in the solution have changed this IP address, and I'm a little tired of having to add new third-party settings and restart the STS wizard.

Is there any formal way to control which emulated role is associated with IP? And if not, then the start / bind order is the same as the order of projects in the Roles folder, and if so, will my web role be called something like Aardvark guarantee that it was always the first to bind?

+6
source share
2 answers

Why do you want to change this IP address? This is used only domestically to avoid IP / Port conflicts. All your roles are only available through 127.0.0.1:[port], and this is the address that you should use as the base address of your trusted application. The addresses 127.255.0.XX are internal addresses that live behind the emulated load balancer in the calculation emulator.

There is no formal or informal way to manage the instance IP address of an instance / role for Compute Emulator. Plus, even if there was a way to do this, I would not suggest using it!

You can always get the correct IP address and port of any endpoint configured in your cloud service using the RoleEnvironment.CurrentRoleInstance.InstanceEndpoints property.

Read the IP address and port location here .

UPDATE

Despite the fact that your application is tied to 127.255.0.XX (emulated direct IP address, aka DIP) in IIS Express, the actual call to your application must go through 127.0.0.1:81 (emulated virtual IP address, otherwise VIP) (where only the port changes). And this is the default download page when Visual Studio launches your application. The developer of Fabric (a Compute Emulator) emulates a Load Balancer that listens for 127.0.0.1:81 (emulated VIP) and redirects traffic to the corresponding instances, which are distributed through 127.255.0.XX (emulated DIP). That is why you should always use 127.0.0.1 when working with a computing emulator and when setting up the trusted side of ACS. Everything you do is incorrect and does not represent the Azure environment.

You can read this and what blog entries for understanding reminology and interacting with Windows Azure.

+4
source

I don’t know if my experience matches exactly the descriptive scenario, but I think that it can at least be an inspiration.

In my solution, I have four different cloud services, each of which has a web role, and everyone should know that the URLs of other services are working correctly. When I'm in production, I know exactly the URLs of all my services, and I can link to each service by its domain name. But when this time is debugging, it can be a nightmare, because there is no way to associate a cloud service with a specific IP address (and port), and DevFabric cannot guarantee that a particular cloud service supports the same address between two different debugging sessions.

I solved the problem with a simple technique:

In my WebRoles, I always refer to a domain name such as debug.myservice.com or debug.myotherservice.com .

The local IP address is resolved using the hosts file , which you can find in:

windows/system32/drivers/etc/hosts 

add some simple operators, for example:

 127.0.0.1 debug.myservice.com 127.0.0.2 debug.myotherservice.com 

This solves the problem, but can be very boring because you need to manually update the hosts file every time you start a new debugging session.

But there is a simple and powerful solution. You know that you can set up a simple script run that runs every time the cloud service is initialized, you can find here:

http://msdn.microsoft.com/en-us/library/windowsazure/hh180155.aspx

You can also run various scripts when you are working in the cloud or in the emulator.

I run a script that automatically updates the hosts file every time my cloud service is initialized in the emulator environment (and only in the emulator).

Here's the script:

 IF "%ComputeEmulatorRunning%" == "true" ( cd Startup UpdateDnsHostsOnDebugEnv.exe MyCompany.MyService.Site.WebRole debug.myservice.com cd.. ) 

and here is what you need to add to ServiceDefinition.csdef in order to run the script on startup:

 <Startup> <Task commandLine="Startup\UpdateDnsHosts.cmd" executionContext="elevated" taskType="foreground"> <Environment> <Variable name="ComputeEmulatorRunning"> <RoleInstanceValue xpath="/RoleEnvironment/Deployment/@emulated" /> </Variable> </Environment> </Task> </Startup> 

Pay attention to the use of the UpdateDnsHostsOnDebugEnv.exe program. This is a simple console application that I wrote, just run csrun.exe and analyze the result to extract the local endpoint address of this role and update the hosts file .

I hope for this help.

+6
source

Source: https://habr.com/ru/post/922924/


All Articles