5
votes

I've read many articles and tutorials that demonstrate how to use the Azure mobile service however I'm left unclear with many things.

I have an existing web app that uses Azure SQL database and is published with Azure. I'm trying to integrate the already created database into the Xamarin Android App I'm developing.

I'm confused with the following things.

  1. Do I need to change the .Net back end to be able to use the database tables in the Xamarin app? The way I see it, I shouldn't need to since the Xamarin app communicates with the SQL database, not the .Net app.

  2. How does the data get stored into the SQL table? Do I just reference the Mobile service inside my Xamarin app and it will create a bridge between the SQL database and my application or do I need to first create the tables or import the existing tables from the database?

  3. The web app is currently deployed to Azure Web service. Does it need to be deployed to Mobile App service?

I would really appreciate if someone can help me out with these questions.

1

1 Answers

13
votes

Your mobile app is not communicating directly with your SQL database. It is likely going through an Azure App Service - this is a web-enabled piece of middleware that projects tables within the SQL database to an OData feed. So you have three pieces - the SQL database, the Azure App Service and your client.

1) Yes, you need to update the ASP.NET backend to support your database tables. If this is an existing database, then you also need to update your database to support the mobile projection. I wrote a blog on this: https://shellmonger.com/2016/05/11/30-days-of-zumo-v2-azure-mobile-apps-day-19-asp-net-table-controllers/ but you may want to start earlier in the series that that.

2) You add the Azure Mobile client to your Xamarin app - this coordinates the transfer of data between your client and the backend. You can find a tutorial on this that I recommend walking through here: https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-xamarin-android-get-started/ - you can also read the HOWTO here: https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-dotnet-how-to-use-client-library/ - the tutorial and HOWTO cover both offline and online data access scenarios.

3) If you are using the new portal (portal.azure.com), then there is really no difference between a Mobile App and a Web App. The Mobile App is simply a web app with a specific SDK deployed within your ASP.NET (or Node.js) backend code and with a connected database. The minor difference is that if you create a Mobile App then clicking on Quickstarts (within Settings) will get you a mobile quick start; if you do the same with a Web App, then clicking on Quickstarts will get you a web quick start.