Xamarin Forms using Azure SQL Database

Thomas Wierman 21 Reputation points
2021-08-17T16:35:53.58+00:00

I am trying to find a current tutorial on how to get a Xamarin Forms app to communicate with an Azure SQL Database.

On the Azure portal I clicked on "Create a Xamarin.Forms app with Azure". It takes me to a web page that has "We're no longer updating this content regularly." on top. The links to the quickstart Git pages give a 404 error.

I started this about 6 months ago, and had no luck getting it to work (using a Git that I got back then). I gave it another try this week and still no luck.

Is there a current tutorial available? The ones I have been able to see in my searching do not have the current Azure UI, and are very hard to follow.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,297 questions
Azure SQL Database
{count} votes

2 answers

Sort by: Most helpful
  1. Alberto Morillo 32,896 Reputation points MVP
    2021-08-18T04:03:50.503+00:00

    If you are trying to find a tutorial of a mobile app that consumes data sources directly, for example Azure SQL Database, then you won't find many as that scenario is not considered a good practice. You need to abstract that by creating an Azure API, the Xamarin app will use this REST API to interact with the database. If you don't use the API and you later want to change the data source of your application, then you will have to change many things to adapt to a new data source.

    Here you will find a sample app and a walkthrough 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.

    This readme document will guide you step-by-step. It shows how to spin up an API in Azure and contains the source code communicating between an API and a Xamarin app.

    Any questions you have, you can contact the author on Twitter, and he will be glad to assist you as he is a Developer Advocate at Microsoft.

    1 person found this answer helpful.

  2. Thomas Wierman 21 Reputation points
    2021-09-07T22:24:14.003+00:00

    Hi. I'm sorry it's taken a long time, this is kind of a hobby. I followed the readme on the XamList solution from GitHub. The connections are good. I got it to run, but nothing works.

    I does not get past the SQLIte db part. It never finds the TableMapping to ContactModel. Then it seems to succeed in the Init() Task (I get two table mappings, one with the correct columns and one with two columns.

    Then I try and add an entry, the isSaveSuccessful is false and the program bombs.