Search code examples
azureinstanceresetwebroleiisreset

Web Role on Windows Azure and iisreset side effects


I noticed that when you RDP to a Web Role instance on Windows Azure to make an iisreset, the World Wide Web Publishing Service shuts down, and the only way to get your role up and running again is either by restarting the aforementioned service or re-roll/restart your instance.

For reasons unknown to me, Windows Azure default the start mode of World Wide Web Publishing Service to Manual, why an iisreset sort a leave your Web Role unavailable to the WWW.

I found a solution to this - IMO - odd behavior, and answered it to the original question of this post.

However, is there an alternative to iisreset on Windows Azure - maybe programmatically where I can pinpoint the exact instance? Because that is another issue; now I have to use RDP to each instance .. it would be nice if it was possible to do a pinpoint each instance.

Think about it; i have a CNAME to www.awesome-azure.com; this is hosted by 3 instances in round-robin, and I want to reset/monitor/diagnose/heartbeat each one through a REST API (ir similiar), and not like now - through RDP.

Can this be achieved.

EDIT

Tried to make it more clear what the challenge is as well as the goal to achieve.

EDIT 2

Provided a solution to the iisreset challenge; updated the question to pinpoint instances over the Internet if possible.


Solution

  • Well, I still don't know why Microsoft Azure decides to set World Wide Web Publishing Service to start mode Manual, but I found a way to change it.

    To the second part of the original question I still hoping for an answer, but until then, please find my solution for the first part to fix the (IMO) iisreset problem with Startup Task:

    In your startup.cmd (or what ever you have named it) which I have placed in a startup folder in the root of my application, include this line of text:

    powershell -ExecutionPolicy Unrestricted .\startup\w3svc.ps1

    In the same folder, create a PowerShell file named w3svc.ps1 with the following content:

    Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\W3SVC -Name Start -Value 2

    Voila; your IIS now works as expected - World Wide Web Publishing Service is now set to start mode Automatically.

    Note: for the above to work, you need to have your osFamily property set to 2 in you ServiceConfiguration.cscfg file.