Overview
This tutorial shows you how to add a cloud-based back-end service to a Xamarin.Forms mobile app by using the Mobile Apps feature of Azure App Service as the back end. You create both a new Mobile Apps back end and a simple to-do list Xamarin.Forms app that stores app data in Azure.
Completing this tutorial is a prerequisite for all other Mobile Apps tutorials for Xamarin.Forms.
Prerequisites
To complete this tutorial, you need the following:
An active Azure account. If you don't have an account, you can sign up for an Azure trial and get up to 10 free mobile apps that you can keep using even after your trial ends. For more information, see Azure Free Trial.
Visual Studio with Xamarin. For information, see the Set up and install Visual Studio and Xamarin page.
A Mac with Xcode v7.0 or later and Xamarin Studio Community installed. For information, see Set up and install Visual Studio and Xamarin and Set up, install, and verify for Mac users (MSDN).
Create a new Mobile Apps back end
To create a new Mobile Apps back end, do the following:
Sign in to the Azure portal.
Click New.
In the search box, type Mobile Apps.

In the results list, select Mobile Apps Quickstart, and then select Create.
Under Resource Group, select an existing resource group or create a new one (using the same name as your app).
Click Create. Wait a few minutes for the service to be deployed successfully before proceeding.
You have now set up a Mobile Apps back end that your mobile client applications can use. Next, you download a server project for a simple to-do list back end and then publish it to Azure.
Configure the server project
To configure the server project to use either the Node.js or .NET back end, do the following:
Click the App Services button, select your Mobile Apps back end, select Quickstart, and then select your client platform (iOS, Android, Xamarin, Cordova).

If a database connection is not configured, create one by doing the following:

a. Create a new SQL database and server.

b. Wait until the data connection is successfully created.

c. Data connection must be successful.

Under 2. Create a table API, select Node.js for Backend language.
Accept the acknowledgment, and then select Create TodoItem table.
This action creates a new to-do item table in your database.Important
Switching an existing back end to Node.js overwrites all contents. To create a .NET back end instead, see Work with the .NET back-end server SDK for Mobile Apps.
Download and run the Xamarin.Forms solution
You can download the solution in either of two ways. Download it to a Mac and open it in Xamarin Studio, or download it to a Windows computer and open it in Visual Studio by using a networked Mac for building the iOS app. For more information, see Set up and install Visual Studio and Xamarin.
On a Mac or Windows computer, do the following:
Go to the Azure portal.
On the Settings blade for your mobile app, under Mobile, select Get Started > Xamarin.Forms. Under step 3, select Create a new app, and then select Download.
This action downloads a project that contains a client application that's connected to your mobile app. Save the compressed project file to your local computer, and make a note of where you save it.
Extract the project that you downloaded, and then open it in Xamarin Studio (Mac) or Visual Studio (Windows).


(Optional) Run the iOS project
In this section, you run the Xamarin iOS project for iOS devices. You can skip this section if you are not working with iOS devices.
In Xamarin Studio
Right-click the iOS project, and then select Set As Startup Project.
On the Run menu, select Start Debugging to build the project and start the app in the iPhone emulator.
In Visual Studio
Right-click the iOS project, and then select Set as StartUp Project.
On the Build menu, select Configuration Manager.
In the Configuration Manager dialog box, select the Build and Deploy check boxes next to the iOS project.
To build the project and start the app in the iPhone emulator, select the F5 key.
Note
If you have problems building the project, run the NuGet package manager and update to the latest version of the Xamarin support packages. Quickstart projects might be slow to update to the latest versions.
In the app, type meaningful text, such as Learn Xamarin, and then select the plus sign (+).

This action sends a post request to the new Mobile Apps back end that's hosted in Azure. Data from the request is inserted into the TodoItem table. Items that are stored in the table are returned by the Mobile Apps back end, and the data is displayed in the list.
Note
You'll find the code that accesses your Mobile Apps back end in the TodoItemManager.cs C# file of the portable class library project of your solution.
(Optional) Run the Android project
In this section, you run the Xamarin droid project for Android. You can skip this section if you are not working with Android devices.
In Xamarin Studio
Right-click the Android project, and then select Set As Startup Project.
To build the project and start the app in an Android emulator, on the Run menu, select Start Debugging.
In Visual Studio
Right-click the Android (Droid) project, and then select Set as StartUp Project.
On the Build menu, select Configuration Manager.
In the Configuration Manager dialog box, select the Build and Deploy check boxes next to the Android project.
To build the project and start the app in an Android emulator, select the F5 key.
Note
If you have problems building the project, run the NuGet package manager and update to the latest version of the Xamarin support packages. Quickstart projects might be slow to update to the latest versions.
In the app, type meaningful text, such as Learn Xamarin, and then select the plus sign (+).

This action sends a post request to the new Mobile Apps back end that's hosted in Azure. Data from the request is inserted into the TodoItem table. Items that are stored in the table are returned by the Mobile Apps back end, and the data is displayed in the list.
Note
You'll find the code that accesses your Mobile Apps back end in the TodoItemManager.cs C# file of the portable class library project of your solution.
(Optional) Run the Windows project
In this section, you run the Xamarin WinApp project for Windows devices. You can skip this section if you are not working with Windows devices.
In Visual Studio
Right-click any of the Windows projects, and then select Set as StartUp Project.
On the Build menu, select Configuration Manager.
In the Configuration Manager dialog box, select the Build and Deploy check boxes next to the Windows project that you chose.
To build the project and start the app in a Windows emulator, select the F5 key.
Note
If you have problems building the project, run the NuGet package manager and update to the latest version of the Xamarin support packages. Quickstart projects might be slow to update to the latest versions.
In the app, type meaningful text, such as Learn Xamarin, and then select the plus sign (+).
This action sends a post request to the new Mobile Apps back end that's hosted in Azure. Data from the request is inserted into the TodoItem table. Items that are stored in the table are returned by the Mobile Apps back end, and the data is displayed in the list.

Note
You'll find the code that accesses your Mobile Apps back end in the TodoItemManager.cs C# file of the portable class library project of your solution.
Next steps
Add authentication to your app
Learn how to authenticate users of your app with an identity provider.Add push notifications to your app
Learn how to add push notifications support to your app and configure your Mobile Apps back end to use Azure Notification Hubs to send the push notifications.Enable offline sync for your app
Learn how to add offline support for your app by using a Mobile Apps back end. With offline sync, you can view, add, or modify your mobile app's data, even when there is no network connection.Use the managed client for Mobile Apps
Learn how to work with the managed client SDK in your Xamarin app.




