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:
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:
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:
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:
Finally, the web app will display the Google map with continuously updating markers for bus locations:
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:
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:
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!