Using Azure Maps with a Xamarin Forms app

This is the first in a three part series where I build a Xamarin Forms app that uses the Azure Maps service. You can check out the other parts here:

Part 1 – This post.  Basic text search
Part 2 – Search by category
Part 3 – Routing

The new Azure Maps service is available, offering APIs and services that enable several common scenarios for location aware apps, all in one convenient place.   This is actually an impressive set of services, namely Search, Maps, Geocoding, Traffic, Routing, and even time zones!

Azure Maps Offerings

 

As soon as I saw this I thought why not build a Xamarin Forms app and use the Maps API to get POI data based on your location and display the results on a map?  So that’s what I did.

Its a simple proof of concept, one screen mobile app for Android.  The screen contains a Map and a search bar.  I used Xamarin.Forms.Maps Nuget package to display the map.  When you enter a search term, I query the Azure Maps Fuzzy Search REST API endpoint to sesrch for Points of Interest using the term you enter into the search box.   To get results local to you, I pass in the Lat and Long of your current location which I obtain by using the Geolocator Plugin.  Since the results of the API can be returned as JSON, I parse the JSON into my model, which I created using QuickType IO.  Then I simply loop through the results and add each of them to the map as a map Pin.  When you tap on a map pin, it shows you the venue name and address.  So that’s it, it was actually pretty easy to get started!  Here’s a screenshot from my Android Emulator with a simulated location.

 

 

 

Clone build definitions across projects in Visual Studio Team Services

If you find yourself creating build definitions for multiple projects on at least semi regular occasion in Visual Studio Team Services, first have a congratulations.   Take a moment to be grateful in the fact that you have work to do.  You haven’t lost sight of that right?

Second, if your build definitions are mostly the same for each project, you can clone them instead of building them from scratch each time.  Cloning a build definition is easy from within the same team project.  Navigate to the main builds page and click the ellipse menu on the build you want to clone, and select clone.  It will create a new build with the same steps and configuration.

VSTS Build Clone or Export

But how would you do this across projects?  Its Easy with a couple extra steps.  In the same context menu as the clone operation, select export.  This produces a json formatted file download that defines your build.  Next, simply navigate to your other project and click the Import button.  Choose the json file you just downloaded and presto, your new build definition is created.

VSTS Build Import

Raspberry Pi Online Simulator for Azure IoT Hub

Have you thought about trying out Azure IoT Hub, but don’t have an IoT device?  Try the Raspberry Pi Online Simulator.  This is what it sounds like, a simulated Raspberry Pi device running a small NodeJS program that sends data to your IoT hub.  It sends simulated temperature data using a mock BME280 temperature sensor.  All you do is plug in the connection string to your IoT hub and hit ‘Run’.  Its even got a little led that blinks when sending data and receiving the callback.  Send data with this, and you can view it in near real time using the Device Explorer for IoT Hub Devices.  Happy coding!

 

 

 

 

 

Why Azure is so remarkable

Technology moves so fast these days its easy to take for granted the innovations in recent years,  combined with exponential accessibility of new technologies made available to developers at large.  Azure continues to usher in new possibilities of virtually unlimited scale, while removing the burden of overhead, giving us resources we could have only dreamed of just a short time ago.  In that sense, Azure is the Robin Hood of technology, giving the common developer what only those with lots of resources enjoyed previously!  What I’m referring to here transcends the technical.  It’s about empowerment.   In keeping of Microsoft’s every person and every organization on the planet to achieve more,  Azure levels the playing field by giving us the power of super computers, AI, and internet of things, all with global scale and ease of accessibility.

This ushers in a new approach to architecture.  No longer is it necessary to write from scratch some of the traditional models like pub sub, you can stand up services for that.  Take event hubs as an example.  A globally ready,  event ingestion service that can scale to millions of messages per second.    Aha!  You just did it didn’t you?  That last sentence blew past and perhaps it wasn’t as astonishing as it would have been to you a few years ago.  But today, it has become more commonplace and acceptable.  Its worth repeating, millions of messages per second.  Try standing up your own servers 10 years ago that could handle this volume of data, and at an affordable price.  This alone makes possible solutions for consultants such as myself to offer to small and medium size businesses with virtually no overhead and investment.  Where I would have (and have before) struggled by provisioning servers and/or hosting together with writing my own message based distributed system, I can now just spin up a hub and I’m good to go.

Indeed the inspiring Microsoft commercials featuring Common speak truth to the times we currently enjoy.  The future we look forward to.  The possibilities available to us.  We’re experiencing a time unlike I’ve ever seen before.  Its a great time to be a developer.

Monitor your API’s with Postman

Do you write and maintain APIs?  Do you know how they’re performing?  If any of your endpoints are returning data, are you sure the schema of the data returned is correct?  You could write your own monitoring solution from scratch, but who has time to do that?   I’ve found Postman to be a great solution for monitoring my APIs. Granted, using it is like a car mechanic taking their car to a service center to get their oil changed, but for me its about saving time.  Tons of time.

Postman has so many features, it would be tough to write about all of them in one blog entry.  I’ll tackle my favorites for now.   First, with Postman, you can fire off scheduled, automated requests to your APIs which are grouped into collections,  with monitors.   Monitors not only let you call your endpoints with optional data parameters, but you can check the results of each call with configurable tests.  Postman can also automatically generate API docs for you, complete with a curl endpoint call ready to copy and paste into your shell.  You can even publish these docs with a paid tier subscription.

Postman has an online dashboard as well as a desktop app component. Here’s my dashboard containing a couple monitors I have set up.

Postman online dashboard

With the desktop app you can set up, configure and call any of your endpoints, set collections and monitors, then sync them to the cloud.  Collections between the online dashboard and desktop component are synchronized when you are signed in.  This is a great feature if you want to check things on the go, or are switching between computers.   Here’s a view from the online dash of a call history from a monitor I have set up.

Postman Collection History

There are several usage plans available, including a free tier, Pro and Enterprise tier, each with features you can read about.

Another amazing feature is the API Network.  This allows you to pull in ready made API client configurations from published third parties right  into your desktop app.  Here’s an example from the Bing Cognitive Services API.  You can see my query is all set up for me, I just have to obtain a key and replace the placeholder value with it.  This is super cool.

Postman Bing API

But wait, there’s more.  You can also set up mock servers for your endpoints before they are even live!  This is great for when you want to simulate a response from a call before you’ve written the code.    Full disclosure, this is not a paid endorsement of Postman, its just that neat of a tool.