Paolo Salvatori from my team, Azure CAT (Customer Advisory Team), has two great samples that show you how to leverage Azure Service Fabric and IoT Hub! Check out this
sample IoT application
and an example of
the Observer pattern
His Twitter is @babosbird. Let's dig into the first sample...
This demo demonstrates how to build an IoT application for anomaly detection using Service Fabric, IoT Hubs, Event Hubs, OWIN and ASP.NET Web API.
The following picture shows the architecture design of the application.
The Service Fabric application ingests events from the input Event Hub, processes sensor readings and generates an alert whenever a value outside of the tolerance range is received. The application is composed of three services:
: this is a stateless service hosting OWIN and exposing a REST management service. This service can be used to get or set metadata on devices actors.
: this is a stateless service that creates an
listener to receive messages from the IoT Hub. The
method of the
class uses an
to send individual events to the proper actor, one for each device.
: a stateful device actor is used to process incoming events at the device level. Each actor processes incoming sensor readings and generates an alert whenever the actual value is outside of the tolerance range identified by the
properties. Alerts are sent to an output Event Hub.