16. april 2011 16:34
I discovered something ord with Azure deployments. 99% of developers and Azure deployments will probably never encounter. To put it short if discovered that if the website you deploy to Azure does not have a reference to the assembly Microsoft.WindowsAzure.StorageClient.dll, the assembly can not be used by the website at all. In other words, this assembly is not in the GAC. Many will probably find this scenario strange. But I encountered this issue when I was working with the CMS Composite C1. C1 is deployed to Azure buy the WebRole.OnStart method that downloads a zip file and unzipping it to the website. Why? Well, there are many reasons, but one of them is that this allows developers deploying existing C1 sites to Azure with the same Azure deployment package (no need to rebuild the package). They just zips the site and points to it from the ServiceConfiguration.cscfg file.
I wanted to share this, so I have found an easy way to reproduce it. Here is the steps to reproduce it (A zipped version can be downloaded Here):
- Create new windows azure project.
- Add a ASP.NET WebRole (Clean the site so only WebRole.cs and web.config are left).
- Add Empty ASP.NET website.
- Add the physicalDirectory=”../Website” to the Site element in the ServiceDefinition.csdef file.
- Add a Default.aspx to the website (Not the WebRole) with the code below.
- Deploy to Azure.
- Note that the CloudBlob type is not found!
- Add a Default.aspx with the same code to the WebRole project.
- Change the physicalDirectory to “../WebRole” in the ServiceDefinition.csdef file.
- Deploy to Azure.
- Now the types can be found! (WebRole having a reference to the needed assembly)
Here is ths code I added to the Default.aspx.cs files:
protected void Page_Load(object sender, EventArgs e)
Type cloudBlobType = Type.GetType("Microsoft.WindowsAzure.StorageClient.CloudBlob, " +
if (cloudBlobType != null)
PlaceHolder.Controls.Add(new LiteralControl("Type found! <br />"));
PlaceHolder.Controls.Add(new LiteralControl("Type NOT found! <br />"));
I used Type.GetType here only to do the reproduction. This could also happen, as it did with C1, if an assembly is added to the website from the WebRole.OnStart, that have a reference to Microsoft.WindowsAzure.StorageClient.dll and used in the code. In this case the site is totaly dead.
The fix is easy, just add needed references to the website. The reason that the WebRole in this reproduction works is that it has a reference to the needed assembly and this results in that the assembly is in the bin folder.