A common question I am asked as a consultant when working with clients on creating mobile apps is, “How do I connect to the database?” There is a general amount of confusion around how developers are supposed to get the data that is in their relational database (think SQL, Oracle, MySQL, etc) to the screen of their mobile devices. In simple, the answer is to create a service that wraps around that relational data and exposes it externally of your organizations network. Simple answer, but there is a lot involved here that all organizations may not have the experience / expertise or the money to build the infrastructure to support. So… you may be asking yourself, “What are some other options?” Well, there are quite a few options we can choose from.
Azure is Microsoft’s cloud computing platform and provides two options for securely exposing your relational database to mobile devices: Azure Mobile Services and Azure Service Bus Relay.
For more information Azure, see below:
Mobile Services is a cloud-based backend service that can expose a SQL Azure or on-premise database to your mobile apps. Out of the box it’s much simpler to utilize SQL Azure to host your remote database, but this isn’t always an option when we want to work with databases that are on-premise. Luckily for us Azure provides a mechanism to create a mobile service that connects back to an on-premise database using what’s known as a Hybrid Connection.
For more information azure mobile services, see below:
For more technical information on setting up an on-premise mobile service, see below:
Service Bus Relay
Microsoft does a great job of explaining what Service Bus Relay is:
The Service Bus Relay service enables you to build hybrid applications that run in both an Azure datacenter and your own on-premises enterprise environment. The Service Bus relay facilitates this by enabling you to securely expose Windows Communication Foundation (WCF) services that reside within a corporate enterprise network to the public cloud, without having to open up a firewall connection or requiring intrusive changes to a corporate network infrastructure.
From the definition above 2 things are clear:
- This is really stinking easy to expose an existing service to be consumed by a mobile app
- You must use WCF or have an existing service layer built with WCF
All that is required to setup a Service Bus Relay is some Azure setup, usage of the Service Bus nuget package and a configuration change on your newly created WCF service or existing WCF service. That’s it, and you can use your WCF service externally of your organization within any platform that supports requests over HTTP.
For technical details on setting up a Service Bus Relay, see below:
Telerik Backend Services
Telerik Backend Services provide a “complete mobile app backend as a service for easy and scalable app development.” Within these backend services exists an application called Data Link Server which provides a generic web service that can be used to expose relational data externally. The beauty of the Data Link Server is the simplicity of installation and setup compared to the amount of functionality that it provides. Though there are some requirements for using this application:
- A windows based web server
- Ability to expose service externally of your environment
For more information on Telerik Backend Services, see below:
For technical details on Telerik Backend Services, see below:
Which path do I choose?
Well, it depends.
Azure Mobile Services will require some modifications to your on-premise server and firewall changes to allow for traffic to pass between the on-premise server and Azure.
Service Bus Relay requires that you build your own WCF service or utilize an existing one, but other than that configuration is really easy.
Telerik Backend Services requires you to deploy an additional web application to a web server and potential firewall changes to allow for HTTP traffic over the port they suggest.
- If you have an existing WCF service – Service Bus Relay will seem like a no brainer.
- If you have a web server that is already hosting externally facing applications Telerik Backend Services may be a good fit.
- If you just have a database server and no way to host externally facing applications Azure Mobile Services may be a good fit.
At the end of the day, it depends on your organizations situation and expertise. Please feel free to comment on any experience you may have on any of the above options or other options that have worked well for you.