Click here to Skip to main content
15,881,757 members
Articles / Hosted Services / Azure
Tip/Trick

Avoid nightmares updating Azure Mobile Services projects

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
15 Jan 2015CPOL4 min read 8.5K   2   1
This article has the goal to show how to update a .Net Backend project from Azure Mobile Services, this mean we will update the references added to the project using Nuget packages.

Scope

This article has the goal to show how to update a .Net Backend project from Azure Mobile Services, this mean we will update the references added to the project using Nuget packages.

Introduction

Microsoft Azure Mobile Services is an Azure service offering designed to make it easy to create highly-functional mobile apps using Azure. Mobile Services brings together a set of Azure services that enable backend capabilities for your apps.
When a developer create a .Net Backend project from Azure Mobile Services, it has several Nuget packages installed, for example, if the project is created in Visual Studio 2013 – Update 4, like we can see in the Image 1

Creating the Azure Mobile Service

Image 1 Creating the Azure Mobile Service

The default package files will something like as following:

XML
<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Autofac" version="3.5.2" targetFramework="net45" />
  <package id="AutoMapper" version="3.2.1" targetFramework="net45" />
  <package id="EntityFramework" version="6.1.1" targetFramework="net45" />
  <package id="Microsoft.AspNet.Cors" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.Identity.Core" version="2.0.1" targetFramework="net45" />
  <package id="Microsoft.AspNet.Identity.Owin" version="2.0.1" targetFramework="net45" />
  <package id="Microsoft.AspNet.Razor" version="3.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Client" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Core" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Cors" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.OData" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Owin" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Tracing" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.Data.Edm" version="5.6.2" targetFramework="net45" />
  <package id="Microsoft.Data.OData" version="5.6.2" targetFramework="net45" />
  <package id="Microsoft.Owin" version="3.0.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Host.SystemWeb" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.ActiveDirectory" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.Cookies" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.Facebook" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.Google" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.Jwt" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.MicrosoftAccount" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.OAuth" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.Twitter" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net45" />
  <package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
  <package id="Owin" version="1.0" targetFramework="net45" />
  <package id="RazorEngine" version="3.4.1" targetFramework="net45" />
  <package id="System.IdentityModel.Tokens.Jwt" version="3.0.2" targetFramework="net45" />
  <package id="System.Spatial" version="5.6.2" targetFramework="net45" />
  <package id="WindowsAzure.MobileServices.Backend" version="1.0.405" targetFramework="net45" />
  <package id="WindowsAzure.MobileServices.Backend.Entity" version="1.0.405" targetFramework="net45" />
  <package id="WindowsAzure.MobileServices.Backend.Tables" version="1.0.405" targetFramework="net45" />
  <package id="WindowsAzure.ServiceBus" version="2.3.4.0" targetFramework="net45" />
</packages>

 

But if we “Manage Nuget Packages” and select “Updates”, the windows will show that there are updates that we can do, like we can see in the Image 2

Manage Nuget Packages - Available updates

Image 2 Manage Nuget Packages - Available Updates

First thing we can try to do is to click in the “Update All” button, that will make sense for the developers, but then we will get something as we can see in the Image 3

Error updating all
Image 3 Error updating all

And is here the nightmares about updating the Nuget packages from Azure Mobile Services start, because, like we can see in the package file, we have 36 Nuget packages installed in the project and is not so easy to understand the dependencies between the different Nuget packages and if we start updating one by one we will get errors as following in the Image 4, with this is not possible to update one by one, but the main Nuget packages and in this article we will see how to avoid this problem.

Azure Mobile Service with errors

Image 4 Azure Mobile Service with errors

It means the reference added to the project is not the same version used by any Nuget and can be hard to understand which is right version.

Description

To understand the Nuget packages and because our project is an Azure Mobile Service project, we can start by analyzing the packages

In the Nuget website we found

• Microsoft Azure Mobile Services .NET Backend 1.0.405

Has the dependencies

• Microsoft Azure Mobile Services .NET Backend Tables 1.0.405

Has the dependencies

• Microsoft Azure Mobile Services .NET Backend Entity Framework Extension 1.0.405

Has the dependencies

This way, we can conclude the Microsoft Azure Mobile Services .NET Backend Entity Framework Extension 1.0.405 Nuget depends on the WindowsAzure.MobileServices.Backend.Tables Nuget and this depend on the WindowsAzure.MobileServices.Backend Nuget. This mean if we update the Microsoft Azure Mobile Services .NET Backend Entity Framework Extension Nuget the references related with Azure Mobile Service will be updated.

In the “Manage Nuget Package” click in update the Microsoft Azure Mobile Services .NET Backend Entity Framework Extension Nuget, as we can see in the Image 5:

Udpdating Nuget
Image 5 Updating Nuget

And then, click “I Accept”

License

Image 6 License

At the end, we will get

Nuget packages updated

Image 7 Nuget packages updated

With this another question can be raised, “Did we update all Nuget packages we can?” and this question can be find by uninstall the Microsoft Azure Mobile Services .NET Backend Entity Framework Extension Nuget, as in the Image 8

Uninstall Nuget
Image 8 Uninstall Nuget

Uninstall this Nuget will request a confirmation to uninstall all dependencies, as in the Image 9, where we will click in “Yes”.

Nuget packages to remove
Image 9 Nuget packages to remove

The result will beThe service running in localhostImage 10 The service running in localhost

And the package file updated to:

XML
<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Autofac" version="3.5.2" targetFramework="net45" />
  <package id="AutoMapper" version="3.2.1" targetFramework="net45" />
  <package id="EntityFramework" version="6.1.1" targetFramework="net45" />
  <package id="Microsoft.AspNet.Cors" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.Identity.Core" version="2.0.1" targetFramework="net45" />
  <package id="Microsoft.AspNet.Identity.Owin" version="2.0.1" targetFramework="net45" />
  <package id="Microsoft.AspNet.Razor" version="3.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Client" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Core" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Cors" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.OData" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Owin" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Tracing" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.Data.Edm" version="5.6.2" targetFramework="net45" />
  <package id="Microsoft.Data.OData" version="5.6.2" targetFramework="net45" />
  <package id="Microsoft.Owin" version="3.0.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Host.SystemWeb" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.ActiveDirectory" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.Cookies" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.Facebook" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.Google" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.Jwt" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.MicrosoftAccount" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.OAuth" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.Twitter" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net45" />
  <package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
  <package id="Owin" version="1.0" targetFramework="net45" />
  <package id="RazorEngine" version="3.4.1" targetFramework="net45" />
  <package id="System.IdentityModel.Tokens.Jwt" version="3.0.2" targetFramework="net45" />
  <package id="System.Spatial" version="5.6.2" targetFramework="net45" />
  <package id="WindowsAzure.MobileServices.Backend" version="1.0.447" targetFramework="net45" />
  <package id="WindowsAzure.MobileServices.Backend.Entity" version="1.0.447" targetFramework="net45" />
  <package id="WindowsAzure.MobileServices.Backend.Tables" version="1.0.447" targetFramework="net45" />
  <package id="WindowsAzure.ServiceBus" version="2.3.4.0" targetFramework="net45" />
</packages>

Returning back to the “Updates”, we will see the Nuget packages, in the Image 11 that we can update, but for the reasons we saw, it is not possible to update all.

Manage Nuget Packages
Image 11 Manage Nuget Packages

Conclusion

In conclusion, each developer should be aware about the dependencies between Nuget packages and more than one package can depend from the same Nuget package but for different versions, this mean is required to keep the versions used by each one.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Comments and Discussions

 
QuestionRazor Engine Pin
Member 86107777-Apr-15 1:39
Member 86107777-Apr-15 1:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.