Part 5: Azure Mobile Service: What you need to know about Backend Server Scripts and Scheduling

This tutorial series takes you through how Azure Mobile Services provides Mobile-Backend-As-A-Service by discussing various features and basics of how to get started.

Part 1: How Azure Mobile Services enable your Cloud First Mobile First World
Part 2: Azure Mobile Services: What you need to know to get started with Storage Services
Part 3: Azure Mobile Services: What you need to know to get started with Notification Hub

Part 4: Azure Mobile Services: What you need to know to get started with Authentication and Authorization



Till now we have covered some of the key functionalities of Azure Mobile Services. We looked into Storage services, Notification Hub and Authentication. One of the key features that we still need to cover in this final section is backend service scripting and scheduling of scripts. So let us have a look at what each of these have to offer.

Server Scripts

One of the most powerful features of Azure Mobile Services is that it allows you to code backend server logic, right in the portal. Depending upon whether you use a .NET backend or a JavaScript backend, table manipulation differs accordingly. The CRUD (create, read, delete and update) functionality is very easily incorporated in your business logic.

For .NET backend, business logic operations are written using ASP .Net Web Api using NuGet packages available for client SDKs for Windows, iOS and Android. Table operations are abstracted using a universal table which represents a CRUD based HTTP API for data storage. The TableController class is customized for CRUD data access pattern.

For JavaScript backend, the customized business logic can be coded and stored in the server itself.


Once you click on the Data tab, create and click on the table, you will see the tab called scripts where you can customize your business logic for Insert, Update, Delete and Read operations. imageFor each of the operations, you can define or customize the script as per your business logic. Some of the commonly used operations are validation of data, read and writing data, authorizing user, sending push notifications, error handling, etc. All of these example server scripts and more can be found here.


Yes, the functionality of writing server scripts does serve the purpose of customizing business logic in the backend. However, there are instances when a scheduled operation is required and is key to the business logic of an app. For example, you may need to ping a website on a recurrent basis to see if it is up and running. You may need to do some cleanup activity on a daily basis or you may need to poll an endpoint recurrently, archiving old or duplicate records. There are many such scenarios for which scheduling is essential. This functionality is served by the Scheduler in Azure Mobile Services.

Let us have a look at how we can use the scheduler in Azure Mobile Services. Once you create your mobile service, click on Scheduler as shown below. image

Now, when you are creating the scheduler, you will notice that you have an option to execute it on minute, daily or monthly schedule. If you just want to keep a script for ad hoc execution, you can select the On demand option.

imageOnce the scheduler is created,  you have options to either change the configuration or you could click on the scripts section and have fun with writing scripts as per your business logic and requirement.

image Now that the job is created, the scripts can be written using JavaScript just like you write the scripts as you would write for the CRUD operations. If you want to have a look at a particular scenario how the scheduler is used, you can have a look at this blogpost which details how to use the scheduler to read tweets at regular intervals.


Overall, through this tutorial series we have gone through the various functionality that Azure Mobile Services have to offer. The various services cover all the needs for Mobile Backend as a Service (M-B-a-a-S) and provides a platform to develop  scalable apps across the various platforms of Windows, iOS, Android, Xamarin and PhoneGap. I strongly urge you to try out Azure Mobile Services to develop your Cloud Apps. Reach out and share your stories with me @AdarshaDatta.

Comments (0)

Skip to main content