Azure Mobile Services .NET Updates
Microsoft has announced updates to Azure Mobile Services .NET track. The details can be found at the blog post by Henrik Frystyk Nielsen (Principal Architect, Azure Mobile Services)
Azure Mobile Services .NET update includes:
- Support for CORS using ASP.NET Web API CORS enabling first class support for specifying CORS policy at a per-service, per-controller, or per-action level.
- An extensible authentication model enabling you to control which authentication mechanisms are available for your mobile service clients. For example, you can add your own authentication mechanisms in addition to or in place of the default support for Azure Active Directory, Twitter, Facebook, Google, and Microsoft Account.
- Support for Azure Active Directory Authentication using a server-side flow simplifying client authentication significantly.
Getting the Updates
Regardless of whether you start from a Mobile Service QuickStart or from a Visual Studio Project, you can you can get the updates (version 1.0.342) from NuGet. Simply go to the NuGet Package Manager in your Visual Studio project, select Updates, and type windowszure.mobileservices in the search window. It should look similar to this:
You can also install Nuget Package using the Package Manager Console by this command below:
PM> Install-Package WindowsAzure.MobileServices.Backend
Alternately, Install the Mobile Services updates by searching for windowsazure.mobileservices and you are ready to go. These packages will include whatever other updates they need so don’t update other packages manually.
First up is built-in support for CORS leveraging the support provided by the ASP.NET Web API CORS nuget package. For a great introduction to CORS in ASP.NET Web API including how to use the EnableCorsAttribute to control the settings, please see the blog CORS Support in ASP.NET Web API 2.
Extensible Authentication Model
Azure Mobile Services provides a common authentication model across Azure Active Directory, Twitter, Facebook, Google, and Microsoft Account. But in addition to these login providers, you can now add your own or even modify or remove the default ones.
For example, you can add support for Custom Authentication as described in the documentation Get started with custom authentication. You can also leverage other OWIN authentication providers to add support for additional identity providers such as LinkedIn, Twitter, Facebook, Google, and Microsoft Account.
Azure Active Directory Authentication
Azure Mobile Services .NET already supports authentication using Active Directory Authentication Library Single Sign-On but has not until now supported the server flow required for client platforms that aren’t currently supported by Active Directory Authentication Library.
The default Azure Active Directory LoginProvider supports the client side flow provided by Active Directory Authentication Library but this only works on client platforms where that library is supported.
To enable the server-side flow, which can work with any client supported by Azure Mobile Services, first install the Microsoft Azure Mobile Services .NET Backend Security Extension Nuget preview package into your server project.
The AzureActiveDirectoryExtendedLoginProvider class supports both the client and server flow allowing you to use whatever works best for your respective client platforms. To find out more about the general Mobile Services authentication model, please see the documentation topic Get started with authentication in Mobile Services.