Albert Bori
Albert Bori

Reputation: 10002

Azure Cloud Emulator remaps ports

I have a solution that contains a website and a Windows Azure Cloud Service Project. Here is the ServiceDefinition.csdef:

...
<WebRole name="FrontEndWeb" vmsize="Small">
<Sites>
    <Site name="Web">
        <Bindings>
            <Binding name="Endpoint1" endpointName="Endpoint1" />
        </Bindings>
    </Site>
</Sites>
<Endpoints>
    <InputEndpoint name="Endpoint1" protocol="http" port="2996" />
</Endpoints>
...
</WebRole>
...

I have the web-debug settings set to: Visual Studio Development Server & Auto Assign Ports

When I run the Windows Azure Cloud Service Project, I get the following message in my General Output log: Windows Azure Tools: Warning: Remapping private port 2996 to 2997 in role 'FrontEndWeb' to avoid conflict during emulation.

It is imperative that the site run on port 2996 due to a host validation requirement.

Things I've tried:

Things I do NOT have:

Why is the Azure Cloud Emulator remapping the ports, and what can I do to prevent it from doing that?

Upvotes: 2

Views: 7570

Answers (6)

clozanne
clozanne

Reputation: 1

I struggled with this issue for some time and annoyingly the solution was to restart my computer.

Upvotes: 0

In my case i had my web application with the property SSL Enabled set to "True" and i didn't have a endpoint in my Web Role Cloud settings for Https.

Open your Web Role settings and in the left hand side menu click on the third menu called Endpoints and add an endpoint for Https. Now click on Configuration tab and you will see a section "Startup action". Uncheck HTTP endpoint and check HTTPS endpoint.

Upvotes: 0

CyberDude
CyberDude

Reputation: 8959

Without the intention of "digging old graves" but if it's for others' benefit. I found myself in the same situation and managed to get around it without "feeling gross".

I noticed that when MSBuild is applying the transformations to the ServiceDefinition.csdef file, this file was not really just copied from the solution folder to the output folder. Instead it was being parsed and re-emitted. This transformation was however not without subtle side effects. Notice this difference:

<!-- the .csdef file in the solution -->
<InputEndpoint name="Endpoint1" protocol="http" port="8080" />

<!-- the .csdef file after MSBuild -->
<InputEndpoint name="Endpoint1" protocol="http" port="8080" localport="8080" />

Notice the extra localport attribute. As you know web roles have an internal and a public endpoint (one in front, one after the load balancer) and these ports seem to be managed by these attributes. By default only the port attribute is generated when creating a new project - thus the confusion.

When deploying the package to the emulator, CSPack needs to avoid using the same port for these two endpoints, thus re-routing the internal one.

The simple fix is to manually add the localport attribute in the .csdef file and specify a port value different from the public (or any other) one.

Upvotes: 3

Sergey Kljopov
Sergey Kljopov

Reputation: 319

Have the same problem. But I don't have IIS installed, don't have Web Matrix and don't have anything listening the port 80 before. So when I start debugging, I see "remapping from port 80 to 81". However emulator starts my webrole listening on port 80. That wouldn't be problem, but in my code I have the following code for constructing links:

        int port = HttpContext.Current.Request.Url.Port;

        if (port != 80 && port != 443)
        {
            uri.Append(":");
            uri.Append(port.ToString());
        }

So when I start debugging and open my site in browser entering http:// localhost, strangely I have all my links pointing to the http://localhost:81. Again, webrole endpoint is on port 80. After the debugging start I see that DevFC listens on port 80, but System process (image path points to the ntoskrnl) listens port 81. What's happening?

Upvotes: 2

RyanCEI
RyanCEI

Reputation: 426

The Azure Compute Emulator simulates the entire Azure fabric, including the load balancer and multiple instances. Because of this, forcing specific IPs onto the Emulator is tricky business, as the Emulator will remap the VIP (virtual IP address) to simulate the Azure platform.

This article http://blogs.staykov.net/2013/05/windows-azure-basicscompute-emulator.html explains in detail the emulator environment.

It sounds like you need that port to satisfy an external requirement; have you considered running your app in debug mode outside the emulator? You can launch it in a standard IIS Express instance and control the endpoints using the IIS Express .config files, and then deploy normally to Azure for production.

Upvotes: 1

bhavesh lad
bhavesh lad

Reputation: 1292

It might be possible that some other application is already running on 2996. Try to run nestat command from dos prompt and see which applications are running on which port?

Upvotes: 3

Related Questions