A Brief Tour of Azure IoT Hub

I’m preparing some material for a webinar on Azure IoT in mid-October (you are signed up, aren’t you?) and thought I’d do a quick intro to the basic concepts and moving parts.

Azure IoT Hub is a cloud-scale service for managing and securely communicating with large numbers of field devices (potentially millions at once); communication can occur from device to cloud, and also from cloud to device (for issuing commands or queries to devices). It’s standards-based so it works with many device types, a number of communications protocols and guest operating systems, and supports various network topologies. It also supports custom gateways for edge analytics, traffic optimization, etc. Finally, it integrates with a number of existing Azure services like Stream Analytics, Machine Learning, and Event Hubs to maximize scale and minimize time to insight.

Let’s walk through a sample Azure IoT Hub-based solution and see it in action. I live in Atlanta, GA USA and our public transit system provides geolocation and other metadata about buses and trains; we’ll use the bus data to simulate device activity in the field (each bus == a device) and use IoT Hubs, Stream Analytics, Azure Storage, DocumentDB, and some custom code to collect and present that data in a meaningful way.

Here’s a diagram of the high-level architecture we want to achieve:

architecture

To simulate data coming from multiple buses driving around in the city, a worker process will periodically poll the transit data, do some minor scrubbing, and push new values into the IoT Hub endpoint. The IoT hub itself is configured with three consumer groups (in essence, three copies of the incoming data). A permanent log of all raw incoming device activity is often useful for tracing, debugging, and downstream analytics; for this we’ll configure a Stream Analytics job to listen on the ‘history’ consumer group and forward all traffic to Azure blob storage:

blob-output

 

Then we’ll keep a copy of the most recent message from each device in “hot” storage (you’ll see why in a moment); for this we’ll configure another Stream Analytics job to listen on the ‘info’ consumer group and forward the messages to a DocumentDB collection:

docdb-output

Next, we’ll hook up some custom listener code to the third consumer group (‘location’) and forward a subset of that incoming data to a custom web app, which will continuously display the bus locations using an embedded Google map control and ASP.NET SignalR. This custom code uses the EventProcessorHost API and IoT Hubs built-in support for the Event Hub programming model to listen for incoming messages and POST them to the web app, like so:

https://gist.github.com/jplane/35fbe2a928948a6f75393e17859745f6

Finally, the web app will display the Google map with continuously updating markers for bus locations:

web

Clicking on a marker will pop up a small window with additional information about that bus; the information is queried on-demand from the DocumentDB store by bus ID and returned to the browser from an HTTP GET call:

https://gist.github.com/jplane/73b964dcaf79e63482bce67016b58b10

This is a very simple example of the power of Azure IoT Hub; check out the code on GitHub if you’d like to play around with it yourself:

https://github.com/jplane/IOTBus

There’s more to explore in Azure IoT… I haven’t touched on device management, cloud-to-device communication, or IoT gateways. Want to hear more? Attend my webinar on Thursday, October 13 at 11 AM EST and learn all about IoT in the Azure cloud!

Until then!

We deliver solutions that accelerate the value of Azure.

Ready to experience the full power of Microsoft Azure?

Start Today

Blog Home

Stay Connected

Upcoming Events

All Events