Sunday, December 13, 2009

Another common reason for Windows Azure role to stuck in Initializing/Busy/Stopping

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

   25 {

   26     public override bool OnStart()

   27     {

   28         DiagnosticMonitor.Start("DiagnosticsConnectionString");


   30         // For information on handling configuration changes

   31         // see the MSDN topic at

   32         RoleEnvironment.Changing += RoleEnvironmentChanging;

   33         ...

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.


Marcus said...

Where exactly do you find the account name? There is a bunch of things it could be, and none is very clear if it is the account name.

Anton Staykov said...

Hello Marcus,
When you login to Windows Azure portal ( and you have created a Storage Service, you are defining an account name for your storage service. Once you have it, if you go to settings you will see 3 endpoint URIs along with 2 access keys (the access key is a long hash). The URIs are in the form of:

I hope you get it now what is the account name for the storage account.

lavi said...

THANKS ANTON... ur post helped me solve my problem...

Greg Oliver said...

The account name for the storage account is case sensitive. If there are any caps in the config file, it won't work.