What is Azure Mobile Service and How does it work with NodeJS applications?

Hryhorii Sirenok
Project Manager at TRIARE
3 min read
What is Azure Mobile Service and How does it work with NodeJS applications?

The great programming skillset is the main prerequisite of a successful product. To implement our best knowledge and develop an excellent app, we must be choosing the most appropriate platform. Azure Mobile App Service gives us an opportunity to shine.

Intro to Azure Mobile App Service

Getting a highly scalable and universally available application development platform is no longer a challenge with Azure App Service from Microsoft Azure. With a combination of backend hosted services and specific development frameworks, it enables streamlining of the backend services integration. Moreover, Azure works with a variety of platforms, including Android, iOS, Windows apps, and cross-platforms such as Cordova and Xamarin.

The core of Azure Mobile Apps is combining a Web API mobile data access with a web application. Given Azure’s software development kit (SDK) capabilities, it is comparable with ASP.NET Framework and Node.js web applications. As for the latter, Node 6.x is supported and up to Node 12.x environments have been tested. In particular, Azure supports two Node.js database drivers: node-mssql and sqlite3.

Develop a Mobile App with Node.js

Start creating an Azure app with Node.js backend using Microsoft Visual Studio application. First of all, create a project directory:

Azure app with Node.js

Then run npm init to form the package structure:

package structure

The next step is installing libraries from the repository:

installing libraries

Finally, create an app.js to commence a basic mobile server:

basic mobile server

After the last step, you get a mobile-oriented app with an unauthenticated access to a data store powered by SQL. Starting from here, you may go for developing various application features with Azure, ranging from homepages to tables and setting authentications, as described by Microsoft’s developer manual.

For example, developers need to define a table before using it. It can be achieved by using a static schema with defined columns or dynamically with the software development kit that controls the schema based on incoming requests. Moreover, there is an option to control specific features of the Web API by adding JavaScript code to the definition.

To set a dynamic approach, you need to define each table in a JavaScript file in the tables directory, and then use the tables.import() method to import the tables. Extending the basic-app sample, you would adjust the app.js file:

basic-app sample

Alternatively, the columns may be defined to expose via the Web API. In this case, the Node.js mobile development kit adds extra columns, making the process static.

Customize API

Having basic features setup, developers may work on custom Azure’s application programming interfaces (API) with Node.js. They are enabled by the following actions:

  1. Creating an API directory.
  2. Making a definition file inside it.
  3. Importing the API directory.

A basic-app definition prototype looks this way:

definition prototype looks

For example, you may add a required authentication to the custom API. It is simply done by adding an access property:

authentication to the custom API

The authentication is available either for the entire app or specific operations.

Given its high propensity to customization, Azure Mobile App Service allows enhanced functionality, for example:

  1. Data access. Provides access to tabular data placed in Azure SQL Database or a local SQL Server through an automatically powered and mobile-friendly OData v3 data source.
  2. Authentication. Allows integration with identity providers such as Azure Active Directory, Microsoft, Google, Facebook, Twitter.
  3. Offline sync. Implements read as well as options to create, update, and delete activity that occurred against the supporting tables even when the network connection is unavailable, and coordinates the data sync between local and cloud stores as stated by the application algorithm.
  4. Push notifications. Provides an opportunity to send push notifications to app users through Azure Notifications Hubs, which supports sending notifications across popular push notification services for Google, Apple, Amazon, and Windows devices.

Conclusion

Azure Mobile App Service is an easy tool for application developers. Notably, Node.js programmers are given everything they need to create high-quality products within the Azure platform. Explore more app development tools, as TRIARE offers insights on reaching the maximum output of your effort.

Find out how we can help make your idea a reality 3
Hryhorii Sirenok
Project Manager at TRIARE