Creating And Connecting Azure Mobile App Service To Xamarin Android

Overview

This tutorial shows how to configure the Mobile backend using Azure Mobile App Serice with the Xamarin.Forms app to store the data and we can connect the Azure mobile app using Visual Studio 2017 RC too. Follow the steps to create Azure mobile app.

Requirements
  1. Active Azure Account
  2. Visual Studio RC 2017
  3. Xamarin Studio must be installed 

Step 1

Log on to the Azure portal and create a new mobile app from Web+Mobile.

Note

You must have an active Azure account.

 

Step 2

And then, it will ask for App name and Resource Group name, along with subscription for usage. Fill all the required fields and press "Create our App". I have named my app as Demo381.

 

Note

App name must be unique.

Step 3

Once deployment has been successful, it will show the overview of Demo381 Mobile App. Here, we can create and manipulate our mobile app in this Azure App Service.



Step 4

Then, go to Visual Studio and create a Xamarin.Forms application. Once the project is created successfully, open Solution Explorer and  right click the "Connected Services" to add the required Mobile Service.

Note

You need to add active Azure account to Visual Studio.

 

Step 6

Select Mobile Azure Back-end Services as the Services to be added to our Project and then, select the services we have created in Azure Mobiles Service. It will automaticaly show the created Service and once we have added it, the required files willl be installed in our project to write our back-end code for accesing the data.

 
 
 
 
Step 7

Thus, add the following code in ConnectedService.json to add the Table API. We have created the project succesfully. Just run and debug it.

  1. using System;  
  2. using Microsoft.WindowsAzure.MobileServices;  
  3. using Newtonsoft.Json;  
  4.   
  5. namespace Demo381  
  6. {  
  7.     public class TodoItem  
  8.     {  
  9.         string id;  
  10.         string name;  
  11.         bool done;  
  12.   
  13.         [JsonProperty(PropertyName = "id")]  
  14.         public string Id  
  15.         {  
  16.             get { return id; }  
  17.             set { id = value;}  
  18.         }  
  19.   
  20.         [JsonProperty(PropertyName = "text")]  
  21.         public string Name  
  22.         {  
  23.             get { return name; }  
  24.             set { name = value;}  
  25.         }  
  26.   
  27.         [JsonProperty(PropertyName = "complete")]  
  28.         public bool Done  
  29.         {  
  30.             get { return done; }  
  31.             set { done = value;}  
  32.         }  
  33.   
  34.         [Version]  
  35.         public string Version { get; set; }  
  36.     }  
  37. }  
Output:

This is our output of the project. We can see that it has been succesfully created and connected with Azure App Service.

 
 
Conclusion

Finally, you have learned how to add mobile back-end services to Xamarin.Forms. In upcoming articles, I am going to show Azure Web+Mobile Services tutorials. Thank you for reading!!!

Up Next
    Ebook Download
    View all
    Learn
    View all