This week, we’re unveiling updates that make Mobile Services a more robust and flexible backend for mobile apps, a free 20MB SQL database to be used with Mobile Services or Web Sites, and support for sending push notifications to Android devices through GCM in Notification Hubs.
Mobile Services makes it fast and easy to build dynamic and engaging mobile apps that scale. Today, we’re expanding its capabilities by adding support for Custom API and source control via local Git.
Since the initial preview launch, Mobile Services has enabled developers to add custom logic to Insert, Read, Update, and Delete operations on their SQL database tables through server scripts. One of the most popular feature requests on our uservoice page has been for Custom API endpoints that allow developers to write server-side scripts that aren’t associated with a SQL database table.
In this week’s release, we’ve not only done that, but also given developers additional control over the HTTP request and response so that they can receive types other than JSON and then detect and append their own HTTP headers.
The Windows Azure portal now contains an ‘API’ tab.
If you click API – Create a Custom API, you’ll find that you’re able to set permissions in a very similar fashion to how you would on your Mobile Services SQL database tables.
From there, you’ll be able to write scripts that leverage the Express.js API. With Custom API, you can send XML (which enables Windows Periodic Notifications), handle different HTTP methods from the same script (such as a GET and POST), perform some advanced routing, share code between Custom API scripts and more.
Source Control via Local Git
Another pressing customer request was for integrated source control to enable continuous integration. Today, we are releasing local Git support, which not only enables continuous integration, but also allows you to install your own node modules.
You can connect a local Git repository to you Mobile Service on the main dashboard and clicking ‘Set up source control.’
Once you click ‘Set up source control,’ you’ll be prompted to provide the credentials for your repo.
After you’ve done so, you’ll find a git URL on the ‘Configure’ tab that you can use to clone the repository locally.
The repository will contain a folder for your Mobile Service with subfolders for your Custom API scripts, table scripts and scheduled scripts. When you add a new script to your local repository then run git push from the command line, you’ll see those scripts appear in the portal.
Importantly, with source control, you can not only push updates to your Mobile Service, but also install your own node modules. Once you set up a local Git repository, npm install your own node modules into the repo. Then just run a git push and you’ll be able to use these modules from Custom API scripts with a standard node.js require.
Stable NuGet Package
When we introduced a new version of the Mobile Services C# client libraries based on portable class libraries (PCL), we enabled a number of new scenarios:
- Portable libraries that consolidate our Windows Store and Windows Phone 8 libraries on a single codebase. That consolidation allows developers to use Mobile Services with a variety of C# clients and call Mobile Services from an ASP.NET or .NET server backend.
- Turnkey Mobile Services functionality for Windows Phone 7.x
- Support for enum types that are automatically serialized into strings by the client, nullable types, contains queries on lists, a new MobileServicesCollection, HttpMessageHandlers, and improved unit-testing.
Free 20 MB SQL Database
We know that customers developing mobile and web apps need to store relational data in the cloud. We also understand that, during development and testing, it’s helpful to have a free data option. That’s why we’re happy to announce that every Windows Azure subscription will receive a free 20-MB Windows Azure SQL Database for 12 months that can be used with Windows Azure Mobile Services or Web Sites.
When you create a new Mobile Service or Web Site, you’ll find the option to a create a New Free 20 MB Windows Azure SQL Database in the database dropdown. (When you create a new Mobile Service, this will be automatic; when you create a new Web Site, you’ll need to choose ‘Custom Create.’)
If you select that option, you’ll be able to enjoy the free 20-MB SQL database for as long as your data needs do not exceed 20 MB.
You receive one free 20-MB SQL database per Windows Azure subscription, to be used with Mobile Services or Web Sites. Multiple Mobile Services or Web Sites can be associated with the same free 20-MB SQL database. If your data needs exceed 20 MB, lift the cap on the ‘SCALE’ tab and published rates will apply. The free 20-MB of SQL is only for new databases and is not a credit for existing databases.
Notification Hubs lets you broadcast push notifications to millions of devices across platforms from almost any backend hosted in Windows Azure. Notification Hubs are a great way to modernize existing apps hosted in Virtual Machines, Cloud Services or Web Sites by engaging users through push notifications; it’s also a great way to enrich the push notifications support available through Mobile Services by subscribing different subsets of users to different topics.
Today, in conjunction with Microsoft Open Technologies, we’re excited to add support for Android push notifications via Google Cloud Messaging (GCM) to the suite of supported platforms. With this release, developers can now broadcast push notifications to Windows Store, iOS and Android devices via WNS, APNS, and GCM, respectively.
- Once you create a Google API project and generate an API key on the Google APIs Console page, note the number after #project in your project URL. That is your GCM sender Id.
- After obtaining the GCM sender Id, head back to the main APIs console page, select Service, set Google Cloud Messaging to ‘On,’ accept the Terms of Service, and then select API Access. At this point, you’ll be prompted to create a new Server Key.
- Once you’ve registered with GCM, login to the Windows Azure portal, click App Services – Service Bus – Notification Hub – Quick Create.
- Choose a name for your Notification Hub, a region (remember to choose the same region as your application to cut down on latency), and a namespace.
- In the Service Bus tab in the left nav, you’ll see the namespace for you Notification Hub. After you click on that namespace, hit the Configure tab and copy in your GCM API Key. Don’t forget to save.
- Before you leave the portal, copy down the connection string with listen access from the main Dashboard under Connection Information.
- Next, you connect you Android application to the Notification Hub by going to the MainActivity class and adding the following private members (of course replace the sender Id the one you obtained above):
- After that, you’ll just update the OnCreate method and MainActivity.java file with your credentials and stand up a receiver that displays push notifications. You can find all the details here.
You can start building Mobile Services powered applications that leverage Custom API and local Git for source control today. You can also add Android broadcast push support to any app built on Windows Azure with Notification Hubs.
Visit the Mobile Developer Center and MSDN for more information regarding Mobile Services and Notification Hubs, respectively. Visit Scott Guthrie’s blog post for additional information regarding this release.
As always, the team is eager to hear what you’d like to see next. Let me know @MLunes90.