Create a Xamarin.iOS app

Overview

This tutorial shows you how to add a cloud-based backend service to a Xamarin.iOS mobile app by using an Azure mobile app backend. You create both a new mobile app backend and a simple Todo list Xamarin.iOS app that stores app data in Azure.

Completing this tutorial is a prerequisite for all other Xamarin.iOS tutorials about using the Mobile Apps feature in Azure App Service.

Prerequisites

To complete this tutorial, you need the following prerequisites:

Create an Azure Mobile App backend

Follow these steps to create a Mobile App backend.

  1. Sign in to the Azure portal.

  2. Click Create a resource.

  3. In the search box, type Mobile Apps.

    Azure portal with Mobile Apps Quickstart highlighted

  4. In the results list, select Mobile Apps Quickstart, and then select Create.

  5. Choose a unique App name. This will also be part of the domain name for your App Service.

  6. Under Resource Group, select an existing resource group or create a new one (using the same name as your app).

  7. Click Create. Wait a few minutes for the service to be deployed successfully before proceeding. Watch the Notifications (bell) icon in the portal header for status updates.

Configure the server project

You have now provisioned an Azure Mobile App backend that can be used by your mobile client applications. Next, download a server project for a simple "todo list" backend and publish it to Azure.

Follow the following steps to configure the server project to use either the Node.js or .NET backend.

  1. Click the App Services button, select your Mobile Apps back end, select Quickstart, and then select your client platform (iOS, Android, Xamarin, Cordova).

    Azure portal with Mobile Apps Quickstart highlighted

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

    Azure portal with Mobile Apps Connect to database

    a. Create a new SQL database and server. You may need to leave the connection string name field to the default value of MS_TableConnectionString in order to complete step 3 below.

    Azure portal with Mobile Apps create new database and server

    b. Wait until the data connection is successfully created.

    Azure portal notification of successful creation of data connection

    c. Data connection must be successful.

    Azure portal notification, "You already have a data connection"

  3. Under 2. Create a table API, select Node.js for Backend language.

  4. 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.iOS app

  1. Open the Azure portal in a browser window.
  2. On the settings blade for your Mobile App, click Get Started > Xamarin.iOS. Under step 3, click Create a new app if it's not already selected. Next click the Download button.

    A client application that connects to your mobile backend is downloaded. Save the compressed project file to your local computer, and make a note of where you save it.

  3. Extract the project that you downloaded, and then open it in Xamarin Studio (or Visual Studio).

  4. Press the F5 key to build the project and start the app in the iPhone emulator.
  5. In the app, type meaningful text, such as Learn Xamarin, and then click the + button.

    Data from the request is inserted into the TodoItem table. Items stored in the table are returned by the mobile app backend, and the data is displayed in the list.

Note

You can review the code that accesses your mobile app backend to query and insert data in the QSTodoService.cs C# file.

Next steps