There is another common reason that will cause your role to stuck into that loop when you deploy it on Windows Azure. And it is common for Web and Worker Roles.
You will most probably encounter this error if you are using latest Windows Azure Tools (as you should to) and you are creating a new project (rather than upgrading your existing one).
The new project template comes with enabled and started DiagnosticsMonitor. In order for this Monitor to work properly and collect and store data it needs a Windows Azure Storage account. The account configuration is saved as Role Configuration Entry in the .CSCFG file. The default “Connection string” is this one:
1 <Setting name="DiagnosticsConnectionString" value="UseDevelopmentStorage=true" />
Note the “UseDevelopmentStorage=true” in the value for our DiagnosticsConnectionString. If you just make a “Hello World” Web Role and you upload it to Azure environment, that role will never start. It will go a Initializing/Busy/Stopping/Stopped loop. You need to either stop the DiagnosticsMonitor or change the connection string.
Lest first see how the connection string should look like:
7 <Setting name="StorageClientAccount"
8 value="DefaultEndpointsProtocol=[https|http];AccountName=[your_account_name];AccountKey=[your_account_key]" />
In this “Connection string” setting for Diagnostics monitor you need to provide:
- DefaultEndpointsProtocol – http or https
- AccountName – your storage account name (endpoints are automatically built up)
- AccountKey – the authentication key that is generated at Storage management part of the portal.
Without specifying these settings your role will not run on Azure environment.
How about disabling DiagnosticsMonitor? Sure you can do so. If you have a WebRole there will be a single file defining a Class (usually called WebRole.cs) that derives from RoleEntryPoint. This class looks something like this:
24 public class WebRole : RoleEntryPoint
26 public override bool OnStart()
30 // For information on handling configuration changes
31 // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
32 RoleEnvironment.Changing += RoleEnvironmentChanging;
It is important to note line 28, on which there is a call: DiagnosticMonitor.Start("DiagnosticsConnectionString");
If want to remove the DiagnosticsMonitor just strip the entire OnStart() method. However I suggest not to do so, because you will loose all logging functionalities of Windows Azure.
I hope that this eliminates most common reasons for headaches of Windows Azure Role stuck in Initializing/Busy/Stopping/Stopped loops.