Reputation: 443
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
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:
Sign in Azure portal, Create an Azure Mobile App backend
Add your data connection and link to your SQL Azure DB, for more details you could refer to Configure the server project
Download and run the Xamarin.Android app working with your SQL Azure DB
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
Reputation: 15322
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.
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