darkThoughts
darkThoughts

Reputation: 443

How to connect a Xamarin app to a SQL Azure DB

I have created an SQL Azure DB and I want to connect a new Xamarin app that's supposed to run on Android, to it. I am new to Xamarin an I couldn't figure out a simple way to do it from the tutorials online.

What's the simplest way to fetch data from a SQL DB in Azure, using Xamarin app?

Upvotes: 3

Views: 9721

Answers (2)

Bruce Chen
Bruce Chen

Reputation: 18465

Per my understanding, you could leverage the Data access and Client SDKs features provided by Mobile Apps in Azure App Service for a simple way to achieve your purpose. You could follow the tutorials below for getting started with the Azure mobile app:

Additionally, you could refer to Adrian hall's book develop-mobile-apps-with-csharp-and-azure for a better understanding of Azure mobile apps.

Upvotes: 2

Brandon Minnick
Brandon Minnick

Reputation: 15322

Answer

You'll need to create an Azure API App. The Xamarin app will use this REST API to interact with the database.

Never connect a mobile app directly to a remote database using the database's connection string, because this opens up the potential for database corruption. For example, if the mobile app user has a poor internet connection, and they are connecting directly to the database, the app may not be able to finish executing a database query. An API will ensure that no database corruption happens due to a poor internet connection.

Sample Code + Walkthrough

I have a sample app and a walkthrough here that shows how to create an Azure API App, connect it to an Azure SQL Database and how to have the mobile app communicate with the REST API.

https://github.com/brminnick/XamList

Upvotes: 4

Related Questions