3
votes

I try to publish a demo application to Windows Azure using Cloud Service and Azure SDK 2.9. In my service I have a Web Role and a Worker Role. Both use Azure Storage. Everything works fine on local hosting (Emulator) but when I try to publish the app I get the following error on Web Role:

Unhandled Exception: System.Runtime.Serialization.SerializationException,
Details: Exception: Unable to find assembly 'Microsoft.WindowsAzure.Storage, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf385)

In the Worker Role project everything is OK, it's using Storage too.

I tried to convert the Web Role to a standard Web Application and everything works fine but I want to resolve this problem on Cloud Application.

What I've tried:

  • set local copy in references to true
  • changed .Net Framework to 4.5.1 and 4.6 (default 4.5)
  • removed and added reference to Storage again
  • reinstalled all libraries by nuget
  • published with Storage 7.0 and 6.2
  • published by VS and by portal (package)
  • added dependentAssembly to web.config

On my VM I checked the bin folder, Microsoft.WindowsAzure.Storage exists.

Any ideas what is wrong?

1
I see an issue with same problem on Github: github.com/Azure/azure-storage-net/issues/269. It seems other folks are also running into similar problem. You may want to raise an issue there. HTH. - Gaurav Mantri

1 Answers

1
votes

After two days I found a solution for that problem. In my WebRole.cs I had this:

public override bool OnStart()
{
    var csa = CloudStorageAccount.Parse(RoleEnvironment
        .GetConfigurationSettingValue("Credentials"));
    var cqc = csa.CreateCloudQueueClient();
    var inputQueue = cqc.GetQueueReference("inputqueue");
    inputQueue.CreateIfNotExists();
    var outputQueue = cqc.GetQueueReference("outputqueue");
    outputQueue.CreateIfNotExists();
    var ctc = csa.CreateCloudTableClient();
    var ct = ctc.GetTableReference("last");
    ct.CreateIfNotExists();
    return base.OnStart();
}

When I moved this initialization to other place e.g. to RouteConfig.cs everything works perfect. I don't know why but every references to Storage from WebRole throws errors after publishing to Azure. I hope this solution helps.