azureumbracoazure-web-rolesumbraco5azure-configuration

Can a WebRole be "recycled" programmatically?


IIS7 application pools can be recycled programmatically. Is there an equivalent concept for the web role in Azure?

That is the basic question, but for background on why I ask, I include the following...

We are attempting to get Umbraco installed in Azure, and the Umbraco installation wizard writes it's configuration information and then manually restarts the application pool (in IIS) to reread the configuration it just wrote. It needs to work the same way in Azure, but at this point we are not able to get it to reinitialize itself from scratch (as it does in IIS7).


Solution

  • You can call RoleEnvironment.RequestRecycle() for a given role instance. This effectively has the Windows Server VM restart, which re-executes your startup scripts, OnStart() method, and Run() method. When doing this, you may want to consider some type of breadcrumb to leave yourself: If you find something installed upon restart, just skip the install process; otherwise, install and request a recycle.