0

Out of the box Azure Web Role seems to bind the website to specific IP Address. As a part of deployment, we need to bind the website to listen to localhost or 127.0.0.1.

I've configured my service definition as below:

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

On Starup.cmd file I've line below:

eventcreate /ID 1 /L APPLICATION /T INFORMATION /SO AzureRoleStartup /D "Executing: BindIISSite.ps1" powershell -NoProfile -ExecutionPolicy unrestricted -Command ".\BindIISSite.ps1"

On BinIISite.ps1 I've PS script below:

import-module WebAdministration
New-WebBinding -Name "*MyWebsite*" -IPAddress "*" -Port 8089 

With all setting above, I noticed that "MyWebSite" is not bound to * for port 8089.

But when I run the startup.cmd manually in Azure VM, it seems to bind correctly. Any idea what may be wrong above?

Nil Pun
  • 17,035
  • 39
  • 172
  • 294

1 Answers1

0

The New-WebBinding cmdlet parameter Name does not accept wildcard characters, so in your script, it is looking for a site with the literal name *MyWebSite*, and that could cause the binding to fail.

Joseph Alcorn
  • 2,322
  • 17
  • 23
  • Interesting, why does it work when I RDP to VM and manually run startup.cmd. – Nil Pun Dec 10 '13 at 06:03
  • I think we are missing some information. What are the exact circumstances when the script does not work? Are you attempting to run this command from a workstation against resources on the VM? – Joseph Alcorn Dec 10 '13 at 06:16
  • From startup script as part of azure deploy – Nil Pun Dec 10 '13 at 11:41
  • I am not really familiar with azure. My last idea would be that maybe, the website does not exist at the time the script is run during the azure deploy – Joseph Alcorn Dec 11 '13 at 05:50