We recently went through upgrading www.leansentry.com to the Windows Azure SDK version 1.7, and definitely hit a fair share of problems with building and publishing afterwards. It was a somewhat painful process taking me deep into the night, and I figured I’ll share some of the things I learned along the way to make it easier for others.
Here are the issues and what we had to do to fix them:
(Disclaimer: this is “what we did” information based on our experience with installing 1.7, rather than the official how-to)
1. Where can I download Windows Azure SDK 1.7?
Don’t go looking for Azure 1.7 in Web Platform Installer (if you have the 3.0 version). Suprisingly, its not there. You have to install Web Platform Installer 4.0 to get it.
Options:
A) Install automatically using Web PI 4.0 (option we used).
– Get Web Platform Installer 4.0: https://www.windowsazure.com/en-us/develop/net/
– Install the Windows Azure SDK 1.7 via WPI: https://www.windowsazure.com/en-us/develop/net/
(credit goes to Lars for his post about this here)
B) Download all the components individually (yeah right): http://www.microsoft.com/en-us/download/details.aspx?id=29988
Other installation notes:
– You need to uninstall old versions of Windows Appfabric Cache before installing, otherwise the installation of Windows Azure tools v1.7 will fail.
2. Upgrading your Visual Studio Azure projects to Azure SDK 1.7
The official way seems to be using Visual Studio project properties of your Windows Azure project after installing the Azure SDK 1.7. Here is an example.
This will also trigger a conversion of the project, and make changes to the .csdef files.
Now, I have to be honest and say we didnt find this button. We ended up making manual changes to the project files. If you need to make them, here they are:
1) Unload the project file (Right click on project, click “Unload project”)
2) Edit the project file (Right click on unloaded project, click “Edit X.csproj”)
3) Change the product version to 1.7
<ProductVersion>1.7</ProductVersion>
4) Change the Azure tools version to 1.7
<CloudExtensionsDir Condition=” ‘$(CloudExtensionsDir)’ == ” “>$(MSBuildExtensionsPath)MicrosoftVisualStudiov$(VisualStudioVersion)Windows Azure Tools1.7</CloudExtensionsDir>
5) Save the project file, and reload the project
6) This should activate the conversion wizard which will then make changes to your .csdef file, adding the following schema version attribute:
<ServiceDefinition name=”SentinelWebAzure” xmlns=”http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition” schemaVersion=”2012-05.1.7″>
NOTE: If you are getting a build error complaining about the schema version, that is because you dont have the right cloud extension dir setting applied. See step #4.
3. Azure referenced assemblies fail to load after upgrading to Azure SDK 1.7
By default, after you install the Windows Azure SDK 1.7, your solution will now build with the 1.7 version libraries. However, if you have project components that reference prevoous versions of the SDK, they will fail to resolve the assembly reference and fail at runtime.
This is the most likely cause of Azure roles continually recycling after upgrading to the v1.7 SDK. This will likely happen even if you have references to specific versions of the Azure DLLs in your source tree, because in our experience VS will always publish the 1.7 versions (its possible we didnt have the right combination of SpecificVersion settings in our 133 projects). Either way, you upgraded to 1.7, didnt you? Presumably because you want to use 1.7 DLLs.
If you are lucky enough to TS into the recycling instance and pull up the event log (or if you are using LeanSentry), you may see:
System.IO.FileLoadException was unhandled by user code Message=Could not load file or assembly ‘Microsoft.WindowsAzure.Diagnostics, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
System.IO.FileLoadException was unhandled by user code Message=Could not load file or assembly ‘Microsoft.WindowsAzure.StorageClient, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
and so on …
This is because you may have configuration or assembly references in your deployment that point to previous versions of the Azure assemblies via strong name signatures. You should go through your entire project and update your references to 1.7 versions. However, a fast fix may be to set up assembly binding redirection to point all references to Azure assemblies to the 1.7 versions.
Put this in your web.config for web role projects or app.config for worker role projects:
<runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <!-- Upgrade to Azure SDK 1.7 --> <dependentAssembly> <assemblyIdentity name="Microsoft.WindowsAzure.StorageClient" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="1.1.0.0" newVersion="1.7.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Microsoft.WindowsAzure.Diagnostics" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="1.1.0.0" newVersion="1.7.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Microsoft.WindowsAzure.ServiceRuntime" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="1.0.0.0" newVersion="1.7.0.0" /> </dependentAssembly> </assemblyBinding> </runtime>
This will cause the assembly loader to look for 1.7 assemblies when resolving references to previous versions of the Azure assemblies.
4. And the most important thing is: republish your Azure project!
Your deployment will need to be upgraded to v1.7 of the SDK. This happens when Visual Studio publishes your project.
That’s it. If you hit any other issues, comment below and we will do our best to help.
Best,
Mike
centur
Nice post, thank you for hints. Do I understand properly that when you upgrade your deployment with re-publishing – you won”t be able to upload old packages anymore ? So if you want to restore some older versions – you cant deploy it to upgraded cloud service instance, right ?
Does same upgrade could be “applied” to Azure Storage or SQL Azure instances, or only to Cloud Service ones?
Mike
Hi centur,
Re: uploading previous packages after upgrade. I havent tested this, but I would imagine so – since they specify an older version of the SDK. I dont know if Azure would downgrade your deployment when you upload your previous package – it might – or it might just fail it. I am pretty sure though that it will delete/recreate a deployment (instead of upgrading) when the SDK version changes.
Re: Azure Storage of SQL Azure – these are not instances you manage but Azure services Microsoft manages, so this upgrade is not “applied” to them. However, the new Azure DLLs you reference in your code do contain fixes/changes for how your code talks to Azure storage – as long as you reference the new StorageClient.dll assembly. Check out the azure storage blog for more on what they changed.
Best,
Mike
centur
Thanks. I understand what is Azure Storage and SQL Azure is, but I thought there could be some API fixes and changes, which could lead to some kind of upgrade to new api should be applied. Surely new DLLs send new Version header, but I think that it could be more complicated with all that geo-distribution and load balancing.
Could I ask few more questions:
Does deployment upgrade affects only concrete slot (ProductionStaging) or it affects entire Cloud Service?
Is there any option to upgrade deployment not using Visual Studio? Some kind of API call or Management Portal “upgrade” button ?
Will we still be able to use “Swap VIP” to switch from old 1.6 SDK deployment to new 1.7 one to avoid service downtime ?
The Morning Brew - Chris Alcock » The Morning Brew #1153
[…] Upgrading to Azure 1.7 SDK: Visual Studio build and publishing problems – Mike Volodarsky shares some of the problems he encountered in updating to the 1.7 version of the Windows Azure SDK and how he worked round them. […]
Ben
Thanks for this; seems to have fixed my problem, I only wish I”d found it before burning the midnight oil.
Dan
Thanks , I got my problem fixed. We had a common library that was shared via nuget. When we upgraded the sdk, one of the applications start throwing the error. This post helped me .
Deva Wijewickrema
Great post, we just upgraded, and in addition to your steps I also had to modify my .config”s as we had trace listeners defined that referenced
which we changed to
You probably coverd it in the upgrade your references line, but when I read that I am thinking of .csproj files, and the version in there, I had totally forgoten about the trace listener”s – so I thought I would leave a comment incase it helps the next person…
Thanks again for a great post.
-Deva
Session: Cloud-enabling ASP.NET MVC Applications - Gunnar Peipman's ASP.NET blog
[…] Upgrading to Azure 1.7 SDK: Visual Studio build and publishing problems Posted: Oct 20 2012, 08:59 AM by DigiMortal | with no comments […]
Adolfo
Thanks Mike for this great tutorial. Came across it when searching for a solution to a much similar problem. Mine is with version 1.8 of the SDK and although symptoms are all the same, the steps you propose did not completely work form me.
I keep investigating 🙂
dontwantToDisclose
Thanks , A lot it is really very usefull…
My problem was :-
“3. Azure referenced assemblies fail to load after upgrading to Azure SDK 1.7”