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...servicefabriciothubdemo
IoT Sample with Service Fabric and IoT Hub
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:
- DeviceManagementWebService: 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.
- EventProcessorHostService: this is a stateless service that creates an EventProcessorHost listener to receive messages from the IoT Hub. The ProcessEventsAsync method of the EventProcessor class uses an ActorProxy to send individual events to the proper actor, one for each device.
- DeviceActorService: 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 MinThreshold and MaxThreshold properties. Alerts are sent to an output Event Hub.
Now let's look into the Observer pattern...
Service Fabric Observer Sample
This project contains a framework that provides an implementation of the Observer design pattern for Service Fabric stateful services and actors.
The Service Fabric Observer Framework provides the base classes and services to implement the Observer design pattern in a Service Fabric application.
The following diagram shows the architecture design of the demo:
The following picture depicts the message flow implemented by the sample.
Check out the samples! Head here for all the Azure CAT Europe samples:
Keep your head in the clouds!
- Ninja Ed