A have an azure webrole with a test page and a service in that role. After publishing the role it doesn\'t start automatically, only at first use. So if the role is shut down fo
A role is typically restarted about once a month, for OS maintenance of either the Guest or the underlying Host OS. What you're more likely to see is AppPool timeout due to inactivity, which will exhibit the same type of initial-hit delay. The default timeout is 20 minutes. You can change the timeout via elevated startup script, with something like:
%windir%\system32\inetsrv\appcmd set config -section:applicationPools -applicationPoolDefaults.processModel.idleTimeout:00:00:00
I discussed this in another SO question as well.
Check out the auto start feature of IIS 7.5. Make sure you set osFamily="2" for the webrole so that it uses the Windows 2008 R2 OS.
Edit: We're still stuck on osFamily="1" for technical reasons, so we haven't been able to implement auto start functionality yet. However, here are the steps that would be required to setup auto start:
Create your own auto start provider that implements the IProcessHostPreloadClient interface. There used to be a default provider called the Application Warm-Up Module, but it's not available for download anymore. You can use .Net Reflector to view the contents of the Microsoft.ApplicationServer.Hosting.AutoStart.ApplicationServerAutoStartProvider.dll as an example implementation. This dll is included in Windows Server (not Azure) AppFabric.
The next step is to specify the correct settings in your applicationHost.config. Some variation of the code listed here can be entered in your RoleEntryPoint class so that it's called when your Azure Role fires up.
Please let the community know if you successfully create your own auto start provider. At this point, there isn't a lot of information about implementing IProcessHostPreloadClient on the internet.