Friday, July 26, 2013

Upgrading Azure from 1.x to 2.x Gotcha

In June, Microsoft stopped supporting 1.x of the Azure framework which meant upgrading my development environment so that it could build 2.0 packages. Click here for more info about that.

 The upgrade itself went fairly well, but when I attempted to run the new package in the local Azure compute emulator, it crashed with an "Could not load file or assembly Microsoft.WindowsAzure.ServiceRuntime, Version=1.0.0.0." Despite upgrading, my project was still trying to load the 1.0 SDK assemblies.

This post reports a similar problem when upgrading from 1.0 to 1.8: http://stackoverflow.com/questions/14189071/could-not-load-file-or-assembly-microsoft-windowsazure-serviceruntime-version but the solution to my problem turned out to be different.

I took this article's advice and made sure references to Azure assemblies in my projects were upgraded.  I tried the binding redirect workaround.  Neither had any effect.  When I attempted to run in the local compute emulator, it would still look for the old assemblies.

For me at least, the issue was that, despite rebuilding the project, the local compute emulator was using an old build package which needed the old assemblies. I needed to "Clean" the Azure deployment project.   Rebuild does not update the working files used by the compute emulator.

When running in the local compute emulator, the working directory is in the "obj" folder under your project. It appears that this area is not refreshed when you rebuild the project.  Running "clean" removed all the old files and replaced them with the new, updated assembly references.

The lessons learned are "Rebuild" doesn't clean files used by the compute emulator and that you need to use the "Clean" option to be sure old files are removed.