With Microsoft Azure – the cloud computing service provided by Microsoft, it is easier than ever before to build a back-end to power your Xamarin mobile application. Moreover, Microsoft Azure provides simple no-code backends with Azure Easy Tables to help everyone make it even more do-able. Let’s start!
Register Microsoft Azure
– Go to https://azure.microsoft.com to buy or register for a 30-day trial Microsoft Azure.
– After filling out all the required information, you are now ready to play with it.
– You can also sign up a free Azure account with Dreamspark (only available for students) and with MSDN subscription.
Start a new Xamarin Project
– If you are using Windows, then download Microsoft Visual Studio with Xamarin extension. If you are using MacOS, then download Xamarin Studio.
– Open it up, start a new project or you can download sample solutions from Xamarin.
Create an Azure Mobile App (Back-end)
You can simply create a no-code Azure Easy Tables backend in less than a minute with Mobile App Quickstart template.
– Log in to portal.azure.com
– Create a new Mobile Apps Quickstart, then follow the instruction to deploy it.
– After that, select Easy Tables to upload or create your own data.
Now, your backend is ready to go!!!
Implement Azure backend to Xamarin Mobile App
We will use Azure App Service Helpers library to add an Azure backend to our mobile app in just four lines of code.
Just simply add the App Service Helpers NuGet, initialize the library, pass in your Azure mobile app’s URL, register a data model as a table, and finalize the schema. Add these lines of code to App.cs in your project.
// 1. Create a new EasyMobileServiceClient.
AzureClient = EasyMobileServiceClient.Create();
// 2. Initialize the library with the URL of the Azure Mobile App you created in Step #1.
// 3. Register a model with the EasyMobileServiceClient to create a table
// 4. Finalize the schema for our database. All table registrations must be done before this step.
Be sure to update YOUR-APP-NAME-HERE with the app name you just specified.
Now, we have implemented all of the code we need in our app! Amazing isn’t it! That’s it! App Service Helpers will automatically handle all communication with your Azure backend for you, do online/offline synchronization so your app works even when it’s not connected, and even automatic conflict resolution.