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?
The
New-WebBinding
cmdlet parameterName
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.