Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Setting Up Easy Tables in Azure App Service Mobile Apps

DZone's Guide to

Setting Up Easy Tables in Azure App Service Mobile Apps

Here's a simple guide for setting up tables in Azure.

· Mobile Zone
Free Resource

Download this comprehensive Mobile Testing Reference Guide to help prioritize which mobile devices and OSs to test against, brought to you in partnership with Sauce Labs.

App Service is the newest offering from Microsoft Azure. It encompasses 4 main application types. Namely – Web Apps, Mobile Apps, API Apps and Logic Apps. With one container you can create any or all of the services. Prior to App Service we had Azure WebSites and Azure Mobile Services. WebSites & Mobile Services would create 2 completely different containers.

About Azure App Service:

Who can explain this better that the guru himself. Well, I am talking about Scott Guthrie or Gu as we call him. Here is his blog post explaining what exactly is Azure App. Service: http://weblogs.asp.net/scottgu/announcing-the-new-azure-app-service

Azure App Service

Azure App Service

About Mobile Apps:

Mobile Apps are nothing but what we had as Mobile Services. Mobile Apps provide you the option of creating a Mobile backend for your Mobile Apps. Apart from the features from Mobile Services, Mobile Apps also provide the following benefits:

  • Built in Auto Scale support
  • CI/CD support with VSO/GitHub/BitBucket
  • Staged Deployments
  • WebJob support
  • Traffic Manager Support

About Easy Tables:

By now, you may be wondering what this “Easy Table” is. Let me explain that for you. Easy Table is also known as “No-Code Table or API”. We say so because you literally write zero code to create a backend for your mobile app using Azure App Service Mobile Apps. Typically with any backend you need a table and table will contain columns. When we had Mobile Services – it supported dual development modes i.e. I could create the tables using no-code way or using C# code. When App Service Mobile App was first introduced, it only supported the code way. You had to create a File > New Project using Visual Studio and deploy it. Microsoft released the support of Easy Tables within Mobile Apps in an update which was rolled out during Nov 2015. In this blog post we will walkthrough how to create an Easy Table in your Mobile App backend.

These Easy Tables are mobile friendly (dah … it is a mobile app after all), ODATA friendly and are backed by SQL Azure. Easy Tables support is still in preview and is limited to apps which are created from within the portal.

Create a New Azure Mobile App Backend:

Follow the below steps to create a new Mobile App Backend.

  1. Log into the new Azure Portal – http://portal.azure.com
  2. Click the +New button which is found on top left of the window. Select Web + Mobile > Mobile App. Create New Mobile Appq Create New Mobile App
  3. In the Mobile App create window provide a name for your Mobile App backend. Subscription will be auto selected. Leave that as is. Mobile App Creation Blade Mobile App Creation Blade
  4. Next, you need to select a Resource Group for your app. You can select an existing resource group of yours or create a new resource group. In order to create a new resource group, click on New button which is available in Resource Group section. I will create a new resource group with the name “EasyTableMobAppRG” for this excercise.
  5. Next you need to select App Service Plan/Location. You can use the default app service plan or create a new plan. Click Create when done.

This will now create a Mobil App Backend. Provisioning of the Mobile App backend can take several minutes. You can monitor the progress using the notification area. Once the deployment succeeds, the settings blade of the newly create Mobile App will open automatically.

Mobile App Details Blade

Mobile App Details Blade


 

Create a Data Connection to Your Mobile App Backend:

Before we can do anything with our Mobile App backend – it needs a data store. Follow the steps below to create a data store.

  1. In the Settings blade, click on Data This will launch Data Connections blade. Since we don’t have any data connections defined yet, Add data connection blade will be opened automatically. Mobile App > Data Connections Blade Mobile App > Data Connections Blade
  2. In Add data connection blade, click SQL Database > Create a new database, type the database Name, choose the pricing tier and then click Server. In the New Server blade, type a unique name in the Server name field, provide a secure Server admin login & password. Make sure that you check the checkbox “Allow azure services to access server”. Then click Ok twice. This create a new database and a new server. Add Data Connection Blade Add Data Connection Blade
  3. Next, back in the Add data connection blade, click Connection string. Type the login & password for your database. Then click OK

Creation of database & server takes some time. You can monitor the progress using the notification area.

Enabling Easy Tables:

Now that we have a Mobile App backend and database created, it’s time to enable Easy Tables. Follow the steps below.

  1. In the Settings blade of your mobile app, click on Easy Tables In the Easy Tables blade, you will see a notification which says “Need to configure Easy Tables/Easy APIs – Click here to continue”. Click on that notification. Easy Tables Blade Easy Tables Blade
  2. In the Easy Tables blade, it will detect that we already have a data connection. In order to initialize Easy Tables, we need to check the checkbox provided in section 2 and click on the button Initialize App. Easy Table Initialization Easy Table Initialization

It will take some time for the Easy Tables feature to be enabled. You can monitor the progress using the Notification area. Once the Easy Tables feature has been enabled, you can then add new table to your mobile app.

Adding New Table to Your Mobile App:

Follow the steps below to create new Tables in your Mobile App backend.

  1. From Settings blade, select Easy Tables node.
  2. In Easy Tables blade, select +Add button which is found at the top of the blade. Easy Tables > Add New Table Easy Tables > Add New Table
  3. In Add a Table blade, enter a Name for your table. Then set permission for Insert, Update, Delete, Read and Undelete operation. You can also decide if you need Soft delete by clicking the checkbox Enable soft delete. Click OK to create the table. New Table Creation Blade New Table Creation Blade
  4. Once the table has been created, Click on the table name in Easy Tables blade. This will open up a blade where you can manage the Table. You will be able to Change permissionEdit the underlying server side script, Manage schemaDelete tableClear tableDelete rows and view the Streaming logs. Easy Table Listing Blade Easy Table Listing Blade
  5. By default only Audit columns will be created in the table. We can now add columns that we want in our table. Click on Manage schema to add new columns.
  6. In Schema blade, Existing columns will be displayed in a grid. To add new column, click on +Add button on the top of the blade. In Add a column blade, provide the Column name and select the Data type. Click OK to create the column. Add a Column blade Add a Column blade

You can add as many column as you want depending on your project needs. With this now we have created our Mobile App backend which contains a Table and we have not written any code till this point. This is Easy Table for you.

You can now connect to your Mobile App backend from any apps using any of the available Client SDK. At the moment for Mobile Apps we have .NET/iOS/Android SDK available for download. Mobile App team is working towards bringing the JavaScript client SDK soon. Once the JS SDK is out you can connect to your Mobile App backend even from a Hybrid App. In the meantime if you want to connect to your Mobile App backend tables from a Hybrid Mobile App, you can do so by connecting to the REST endpoints that are exposed by the tables and make HTTP calls accordingly. 

That’s it for this blog post. Hope you now have the information to get started with Azure App Service Mobile App and Easy Tables.

Till next time – Happy Coding. Code with Passion, Decode with Patience.

Analysts agree that a mix of emulators/simulators and real devices are necessary to optimize your mobile app testing - learn more in this white paper, brought to you in partnership with Sauce Labs.

Topics:
mobile ,azure

Published at DZone with permission of Lohith Nagaraj, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}