-
Simulated PLC
- Generates sensor reading data and sends it to IoT Hub
-
Function App
- Triggers when IoT Hub receives a new message
- Sends the message to Anomaly Detector API (Cognitive Services)
- If Anomaly is detected, calls a Logic App
-
Logic App
- Fetches the email content from query string
- Sends the email using Send Grid
-
(Optional) Real time Dashboard
- Create a new IoT Hub Device and copy the connection string.
- Create a new Send Grid Account.
- Create a logic app using
logicapp\template.json
as guidance
- Create the Anomaly Detector cognitive service resource in Azure.
- Copy the key and endpoint from the Quick Start section.
- Create a NodeJS Function App.
- Add following Application Settings:
- Name:
anomalydetector_endpoint
| Value:<Anomaly Detector API key>
- Name:
anomalydetector_key
| Value:<Anomaly Detector API endpoint>
- Name:
- Create a new Function with IoT Hub as trigger and connect it to the IoT Hub created above.
- Use the function
Console
to install following npm packages inD:\home\site\wwwroot
directory:npm install @azure/cognitiveservices-anomalydetector
npm install @azure/ms-rest-js
- Update the index.js file code with
function\index.js
- Update the
logicAppWorkflowPath
variable insendEmail
method with the logic app workflow path
- Clone the repo
- Install Nodejs
- Goto
simulated-plc
folder in command line - Run
npm install
- Create
.env
file and add following variables:deviceConnectionString='<Your IoT Hub Device Connection String>'
- Run
node .