Scope
The purpose of this article is 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 creates 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.
Image 1 Creating the Azure Mobile Service
The default package files will be something such as the following:
- <?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.
Image 2 Manage Nuget Packages - Available Updates
The first thing we can try to do is to click the “Update All” button, that will make sense for developers, but then we will get something as we can see in Image 3.
Image 3 Error updating all
And here are 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 it is not so easy to understand the dependencies among the various Nuget packages and if we start updating them one by one we will get errors as in the following in Image 4. So with this it 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.
Image 4 Azure Mobile Service with errors
In other words the reference added to the project is not the same version used by any Nuget and it can be hard to understand which is the 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.
- <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" />
In the Nuget website we found
- Microsoft Azure Mobile Services .NET Backend 1.0.405
Has the dependencies:
- Newtonsoft.Json (≥ 6.0.4)
- Microsoft.Owin (≥ 3.0.0)
- Autofac (≥ 3.5.2)
- Microsoft.AspNet.Identity.Owin (≥ 2.0.1)
- Microsoft.AspNet.WebApi.Cors (≥ 5.2.2)
- Microsoft.AspNet.WebApi.Owin (≥ 5.2.2)
- Microsoft.AspNet.WebApi.Tracing (≥ 5.2.2)
- Microsoft.Owin.Security.ActiveDirectory (≥ 2.1.0)
- Microsoft.Owin.Security.Facebook (≥ 2.1.0)
- Microsoft.Owin.Security.Google (≥ 2.1.0)
- Microsoft.Owin.Security.MicrosoftAccount (≥ 2.1.0)
- Microsoft.Owin.Security.Twitter (≥ 2.1.0)
- RazorEngine (≥ 3.4.1)
- WindowsAzure.ServiceBus (≥ 2.3.4.0)
- Microsoft Azure Mobile Services .NET Backend Tables 1.0.405
Has the dependencies:
- WindowsAzure.MobileServices.Backend (≥ 1.0.405)
- Microsoft.Data.OData (≥ 5.6.2)
- Autofac (≥ 3.5.2)
- Microsoft.AspNet.WebApi.OData (≥ 5.2.2)
- Microsoft.AspNet.WebApi.Tracing (≥ 5.2.2)
- Microsoft.Owin.Security.OAuth (≥ 2.1.0)
- Microsoft Azure Mobile Services .NET Backend Entity Framework Extension 1.0.405.
Has the dependencies.
- WindowsAzure.MobileServices.Backend.Tables (≥ 1.0.405)
- Autofac (≥ 3.5.2)
- AutoMapper (≥ 3.2.1)
- EntityFramework (≥ 6.1.1)
- Microsoft.AspNet.WebApi.OData (≥ 5.2.2)
- Microsoft.AspNet.WebApi.Tracing (≥ 5.2.2)
- Microsoft.Owin.Security.OAuth (≥ 2.1.0)
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 depends on the WindowsAzure.MobileServices.Backend Nuget. This means if we update the Microsoft Azure Mobile Services .NET Backend Entity Framework Extension Nuget the references related to Azure Mobile Services 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 Image 5:
Image 5 Updating Nuget
And then, click “I Accept”.
Image 6 License
At the end, we will get:
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 answered by uninstalling the Microsoft Azure Mobile Services .NET Backend Entity Framework Extension Nuget, as in the Image 8:
Image 8 Uninstall Nuget
Uninstalling this Nuget will request a confirmation to uninstall all the dependencies, as in the Image 9, where we will click in “Yes”.
Image 9 Nuget packages to remove
The result will be:
Image 10 the service running in localhost
And the package file updated to:
- <?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 following Nuget packages that we can update, but for the reasons we saw, it is not possible to update all.
Image 11 Manage Nuget Packages
Conclusion
In conclusion, each developer should be aware of the dependencies among Nuget packages and that more than one package can depend on the same Nuget package but for different versions, this mean it is necessary to keep the versions used by each one.