This sample project demonstrates a multi-tenant IoT solution using Azure IoT Hub for device message ingress and Azure Service Fabric for device message access and processing.
Microsoft-Iot.Ingestion.RouterService Microsoft-IoT.Admin.WebService Microsoft-IoT.Tenant.WebService Microsoft-IoT.Tenant.DataService Microsoft-ServiceFabric-Services
http://localhost:8081/iotin a web browser to access the admin web UI.
In this example, the system allows an adminstrator to add any number of "tenants" to the system to consume messages from device field gateways through any number of IoT Hub instances. Tenants can view their devices and device messages through a Web UI. Messages sent from devices are expected to include a tenant name and device ID for the message ingestion application to determine which tenant to send the message to.
This example makes use of several Azure products: - IoT Hub for device management and device message ingress. - Service Fabric hosts the message processing applications. - Azure Storage (optional) can optionally be used for long-term message storage, but is not shown in this example.
The solution is composed of three separate Service Fabric applications, each with their own set of services:
Used by an adminstrator to create instances of the Ingestion Application and Tenant Application. - Web Service: The only service in this application, the web service is a stateless ASP.NET Core service that presents a management UI. API controllers perform Service Fabric management operations using
An instance of this application connects to an IoT Hub, reads device events, and forwards data to the tenant identified in the device event message. - Router Service: The only service in this application, the router service is the stateful partitioned service that connects to IoT Hub and forwards device messages to the appropriate tenant application.
#### Tenant Application A tenant is a user of the system. The system can have multiple tenants. Device event data flows into tenant applications for viewing and processing. - Data Service: A stateful service that holds the most recent device message for a tenant. This service is partitioned so that tenants with a large number of devices can scale horizontally to meet their requirements. - Web Service: A stateless ASP.NET Core service that presents a UI for the tenant to see devices and their most recent messages.
This sample project does not create instances of each application during deployment time. The project is designed to create new application instances at runtime through the Admin UI. In order to create application instances at runtime, the application types must be registered at deployment time. A fresh deployment of this sample looks like this:
Note that only the IoTAdminApplicationType has a named instance running. The other two application types are registered, but no named application instances are created by default. The web UI in the admin application is used to dynamicall create named instances of the other two applications.