Cross Platforms - Creating Mobile Apps With Backend Using Azure - Part Three

In this article you will learn Cross Platforms - creating mobile apps with backend using Azure.

Introduction

This article is a continuation of my previous writings on Cross Platforms, here I will be dealing with creating mobile apps in Azure with backend and REST API’s.

Creating Mobile Service from Visual Studio 2015

Keep your Visual Studio 2015 running now and click on New Project, move to Cloud and select Mobile Service of Azure.

Visual Studio

This will take you to a window where you can select the new project by configuring as per your need.

Click on Cloud - Azure Mobile Service - Name your project. Select the location where you want to save this project and click on OK

Visual Studio

You will see another window as shown below. 

Visual Studio

Azure Mobile services supports only for Web API so let's select Web API, and we need this to be hosted in the cloud, but Microsoft Azure has recently stopped mobile service and to access this we have to work from the Azure Mobile Apps. So let's open a browser and we will move to the Azure portal.

Azure Portal Link - www.portal.azure.com

Click on New - Web + Mobile - Mobile App.

Visual Studio

Give the app a name, select the Subscription, Resource Group, App Service Plan/Location with Application Insight here. After it is configured click on create.

And now the Mobile App gets deployed in the Azure portal.

Visual Studio

And now that the mobile app, namely the Mobile Service, has been created, move to Visual Studio 2015 and click on Server Explorer. You can find the Resource group and mobile app over there.

Visual Studio

Here in the solution explorer you can find the Web API using the entity framework as the data backend, you can find DataObjectsToDoItem.cs here.

Visual Studio

You can find the base class named Entity Data which is used by the Mobile Services framework. This will help us with the unique ID’s and features, etc.,

Visual Studio

You can also find MobileServiceContext or the Database Context which is a entity framework and helps to manages the data in the back end.

Visual Studio

It also has TodoItems which has been already set here.

Visual Studio

You should also find something called Controllers which is a Web API controller which derives the table controller. This is a REST API which contains code to get data from ToDoItems, post and add new ones, perform changes, or delete an item.

Visual Studio

Visual Studio

Visual Studio

And now you can run this project by selecting Crossplatformx.Backend in Solution Explorer and setting it as a Startup Project.

Visual Studio

Now you can run this project by selecting the browser that you need and by just running the project.

Visual Studio

Here I will be selecting Internet Explorer and will run the project. And when you build a project you will get  an output pane with the status of the project as shown below

Visual Studio

Visual Studio

Now you can find the output in a Web Browser as shown below

Visual Studio

You can click on the Try it Out option to get some help with the Web APIs which will take you to the Help tutorial page as shown below

Visual Studio

This displays the Jobs and Todoitem. Let's click on the GET tables/TodoItem, this will display the response information of JSON format. Now let's click on Try this out to check what happens with this GET table.

Visual Studio

Click on Send in the below window.

Visual Studio

This will display two different IDs for you now as shown below

Visual Studio

We can also use tools like Fiddler or any other tool to access this REST API. Now let's close this window, we will move to the Web Browser and select the below URL address.

Existing URL - http//localhost61731/help/Api/GET-tables-TodoItem

Replace with new URL - http//localhost61731/tables/TodoItem

Visual Studio

And now we get the same JSON response here, which is a file gets downloaded now and opened in Visual Studio 2015 automatically, so you just hit the REST API and get response from here using Azure Mobile Apps.

Keynotes in Short

  1. Creating Mobile Apps in Azure.
  2. About Data Objects in Solution Explorer.
  3. About Models in Solution Explorer.
  4. About Controllers in Solution Explorer.
  5. Build project in Visual Studio 2015.
  6. Accessing JSON response GET Tables.
  7. REST API access for Mobile Apps in Azure.