All client applications need a backend. Using Azure’s easy tables feature it is possible to quickly create a backend for our applications. Basically we will need to create in Azure a database, with the appropriate data structure to store the data that our applications requires. Then we will be able to send, and read data via REST using the standard OData.

Creating the App service

1) Log into your Azure website. In your dashboard select New

azure_00

2) Select Web + Mobile, and in the following menu select Mobile App

Select Mobile App

3) Choose a name for your webapp service, and select a group resource. If you haven ‘t create a resource group yet, you can create a new one now: just give it a name, and select Create new. You have also to select one of your subscriptions. Finally click on Create.
Input the required values to create the web service

Your service will now be created. The process can take a few seconds, do not worry if it does not appear immediately. In the top bar at the dashboard you can see in the Notifications area what the system is doing. If, for example, you decided to create a resource group for your service in the previous step, you will see in the notifications area a message like the one below when the operation is completed.
creating resource group ...

4) Once the process is completed your newly created service will be visible, and selectable from the App Services menu.

App services

Creating a database connection

We have our App service, but now we need a database from where our mobile application can read data, and where it can send data to be stored. In other words we need to create a database connection associated to the service we have just created.

1) From the App services menu we have to select our service, and in the menu that unfolds to the right we must search for the Data connections entry. Select that entry and click Add.

Add a database connection

2) Select a name for your database. You will have also to create a server for your database, if you have not created one yet. You only need to fill a simple form specifying the server’s name, and login credentials (choose a login admin name, and a secure password).

Once you are ready click Select.
Input your database connection data

The database creation menu gets updated with the information of the created database, and associated server. Click Select to confirm the settings.

Confirm your settings

3) After a few seconds the system will have your database connection created, and ready to use.

Wait till your database connection is ready to use

Creating an Easy tables

So far we have created a database, and a service to serve the information stored in the database. The only thing left to do is to create some tables in the database, so that our client (a mobile application, for example) can start sending, and receiving information from the server.

1) Select your App service, and in the menu that unfolds at the right, search for an entry called Easy tables. Select that entry, and you will notice a message warning you that you need to configure Easy Tables: select Click here to continue to proceed to the indicated configuration process.
Select Easy tables

2) In the following screen select Initialize App.
Initialize app

3) Once initialized the App, you can Add a new table. For each table that you created, you need to specify a name, and set the access permissions.

Set permissions

Naturally we would want to restrict access to our database to authenticated users. But we can change that, if for some reason need to, and for example, open anonymous access to some operations like read, or insert:

For example, I created a test1 table, and restricted anonymous access to insert, and read operations. Meaning that anyone can read data from my test1 table, and anyone can add new entries to test1.  But anyone that wants to delete entries, or update existing entries will need to authenticate themselves.
easy tables_configuration
4) Finally we can select the test1 table, and modify its schema adding new columns to comply with the data model of our application. See, for example, how we can add a name column, of type String:
Add columns

Testing the web service

At this point we can test if our service is working correctly: lets try to access our test1 table using postman.

For starters we will connect to the table to retrieve all the entries:

Retrieve entries

Notice that we need to add the property ZUMO-API-VERSION to the header (set to 2.0.0) to get the request to work.

At this point, since the data is empty, the above petition will return an empty array; []

So we can post a new user as in the image below:

Post entries

After we click on Send a new entry will be added to our test1 table.

Advertisements