3
votes

My aim is to develop a web app and a mobile app that share data from the same database. What is the best way to achieve this (using azure)?

I think I should:

  • Create a Web App from Azure Portal with a SQL Database
  • Create a Mobile App from Azure Portal with an existing Database (the one I created before)

Then I'll develop my ASP.net MVC project, using Entity Framework to create the db Schema and I'll publish it in Azure. Finally I'll develope my mobile app (in this case I would like to use Xamarin) and I'll access to the database (created before) using the code for Easy Tables.

Is it right? Or I'm thinking wrong and this isn't the best architecture to share the same database between a web app and a mobile app using Azure?

3

3 Answers

2
votes

This should be fine. Keep in mind that the Azure Mobile Apps server will automatically add some system columns to your database tables (createdAt, updatedAt, deleted and version). Also, a limitation of Mobile Apps is that the primary key name must be called id.

0
votes

If you want to develop the web site and mobile app share the same database, it is a good choice.

0
votes

Azure Mobile Apps is a plain old ASP.NET application or Node.js application. Easy Tables is simply a projection of data from the Node.js version. If you are using ASP.NET, then you don't get Easy Tables.

That being said, it is relatively easy to add Azure Mobile Apps SDK to an EXISTING web app.

1) Copy the code from App_Start\Startup.MobileApp.cs and Startup.cs from a sample app to your ASP.NET app

2) Ensure all your models inherit from EntityData so that they are "mobile ready". If your models already have an auto-incrementing Id column, then see https://shellmonger.com/2016/05/11/30-days-of-zumo-v2-azure-mobile-apps-day-19-asp-net-table-controllers/ for a workaround

3) Scaffold Azure Mobile Apps Table Controllers for your mobile database table projections.

You can use the same models across both MVC controllers and Mobile controllers. If your app uses AJAX calls for getting data, you can replace those AJAX calls with the JavaScript SDK for Azure Mobile Apps so you don't have to duplicate things.

The main place you are going to have to work on is integration of auth. Most MVC applications use an Identity database because they have grown it from one of the existing MVC templates. You are going to need to implement a custom mobile auth mechanism to re-use the database. You can find information about this on the azure.com HOWTO documentation.