Guest blog by Microsoft Student Partner Isaac Hutt
I am a First (soon to be Second) Year student at Imperial College London studying Computing. I have a passion for open source technologies and Android development, specifically brining information from sources such as Wikipedia to remote communities. I love trying out new technologies, reading articles on them and sharing them with others.
Azure Mobile App Services
Android Development with Azure Mobile App Services
Mobile app development is becoming easier and easier to get into. A multitude of online guides and example projects will talk you through how to set up a UI and link it to a simple web service providing data such as the weather. What these guides fail to explain is the much more complicated procedure of setting up your own web service let alone one which is both scalable and cost effective.
Having developed Android apps in the past using a self-written PHP wrappers around a database to provide a basic API, I knew there had to be a better way. I heard about Azure Mobile App Services and decided to give it a go. I took a basic chat app that I had developed and migrated it to Azure Mobile App Services. The process was much smoother than I anticipated and the libraries provided were intuitive to use and intelligently designed.
The first challenge that I faced was navigating the Azure cloud portal: portal.azure.com. I found it well designed and unique in the number of technologies available on one site. Creating a mobile app was trivial and the online setup was easy using the quick start guide. All the necessary Microsoft libraries are hosted on jcenter and can be installed with a single line in your gradle.build file. (There could be conflicting dependencies so be sure to exclude them if they occur). All the relevant libraries are on GitHub under the Apache 2.0 license and I found this allowed me to get a feel for them.
After setting up the SQL server, database and app service I set about setting up my first table to hold user information. This can be done easily on a NodeJS server using a tool called Easy Tables. Once your table is created you can easily add columns, then a simple object in the client with an id field and any extra fields added, will be populated with its row data in just a few lines of code that execute a remote SQL query. This is much easier than fiddling around with HTTP requests and JSON parsing.
After transferring my code to use the remote SQL server, I looked at other features Azure Mobile App Services provides. Two that particularly stood out to me were authentication and push notifications. I read the documentation and set out to implement them.
Previously users had been trusted to choose any name they desired. The powerful authentication service provided by Azure allows users to identify themselves with a variety of accounts including Microsoft, Google and Facebook. The process involves setting up the respective API and giving Microsoft the keys required to interface with it. This allows all authentication to be carried out by Microsoft with almost one click and no storing of keys in the app. In fact, the API set-up means that there is no need for any private keys to be stored on the device at all. To enforce database write protection a simple dropdown can be selected although this trusts the client. For a real production setup users should only be able to read/write data pertinent to them and this can be configured in the backend language.
Next, I set-up push notifications to send near instant messages to active clients. On the client, this is handled via Google Cloud Messaging and Firebase to save resources. Azure provides an excellent wrapper over this as well as integrations with other push messaging services. Adding a simple script in backend language is powerful enough to push a message to all active devices in a very elegant solution. The payload is a JSON object that is passed to Android as a bundle to be easily parsed. The notification can also be targeted by instance ids or tags.
Costs of Cloud Services
Many people think that cloud services are expensive, seeing some large hourly prices and assuming poor value. In reality, everything scales with growth. Azure Mobile App Services offers a free app plan and you can get fully usable cloud SQL server for as cheap as $4.99 a month. Combined they are everything you need to start building your app.
Overall, implementing Azure Mobile App Services was far easier than I initial expected, providing an all in one solution for the backend of any app with great scaling options. After spending a considerable amount of time with Azure Mobile App Services, I can say that it is well worth using.
Demo of the App
Here is the Java source code for the app: https://github.com/mhutti1/chat
This post first appeared on MSDN Blogs | Get The Latest Information, Insights, Announcements, And News From Microsoft Experts And Developers In The MSDN Blogs., please read the originial post: here