Saturday April 27th, 2013 was the day of the Global Windows Azure Bootcamp (GWAB). With more than 90 locations all around the world, GWAB was THE world-wide event about Windows Azure. Thanks to @RobinDotNet I had the chance to give a 15 minute presentation on how I use Windows Azure Mobile Services in my application Earthquakes for Windows Phone. Today I’m going to share with you, on this blog, my presentation and at the same time, add some details and answer some questions I received after the talk.
I am using the Mobile Services backend for two features in my Earthquakes application. The first one is to save the channel that allows me to update the tiles if the user pin the application on the main screen of the phone. The second one is the manual registration to an alert system, in case an earthquake happens in a define range you will receive a toast notification.
Let’s see now what’s stored on Azure Mobile Services. As you can see, if you want to be alerted when an earthquake happens close to you, I’ll need to know your geo-location and other information like the range and the minimal magnitude of the event and the channel URI that allows me to send the toast notification to your device. To update the tiles on your phone, I don’t need that much information, I store only the channel URI. All the data are write-only for the devices. Nobody, beside me can access them.
Here is the result of the work on the server side. When you pin the application on the main screen you can see the tiles start moving after a few minutes. Also, if an earthquake happens in the range you defined, you’ll receive a toast notification to alert you. I am working on a future version that will allow you to define a geo position, other than your position to track the earthquakes. In other words, if your wife, kids or friends are traveling in California 🙂 (or somewhere else in the world) you’ll be able to know if something happen.
First of all, I have a Worker Role hosted on Azure that is pulling the earthquakes data from the USGS web site and store them into a storage.
On another side, I have the devices downloading and using the application. The application registers on Mobile Services using the SDK, so no much code to write.
My worker role needs to know the list of devices registered and to do so I’m using the REST API Framework I’ve build to retrieve the list of devices and their geo-location.
Then, every 15 – 20 minutes, I’ll get the last “strongest” earthquakes and send a tile notification to all devices to ask them to update their tiles. In a next update I’ll try to use Windows Azure Notification Hubs.
In case an event happens close to someone I’ll send a toast notification to the device to display an alert.
Access Mobile Services
To summarize, I am using two ways to contact Windows Azure Mobile Services.
From a device you can very easily use the Mobile Services SDK provided for Windows Store, Windows Phone 8, iOS, Android and now from HTML 5 applications!
From other platform there is no SDK for Windows applications (like Console, WPF…) so you will need to build your own “framework”. However it is very easy because you only need to build a REST APIs wrapper on top of your service. You can check my other articles about Mobile Services and use the few methods I’m providing to start building your apps against Windows Azure Mobile Services.
Pros and Cons
Pros Mobile Services is free, up to 10 services. Then you’ll have to pay. Check the pricing and the limits. Because it is based on the architecture of Windows Azure Web Sites (Mobile Services is basically a NodeJs application) you can scale your service up to 10 instances. As I said earlier, you can use the SDK for Windows Store app, Windows Phone 8, iOS, Android and HTML 5 apps. And if there is no SDK, you can also write contact Mobile Services using the REST APIs and because of that it makes things very easy to use.
Thanks a lot for reading and I hope to see you at my next presentation. In the meantime, please download my free application Earthquakes for Windows Phone.