/anomaly-detection

Serverless Anomaly Detection using Cognitive Services

Primary LanguageJavaScript

Serverless Anomaly Detection using Azure

Architecture

High Level Components

  • Simulated PLC

    • Generates sensor reading data and sends it to IoT Hub
  • Function App

  • Logic App

    • Fetches the email content from query string
    • Sends the email using Send Grid
  • (Optional) Real time Dashboard

High Level Deployment Steps

IoT Hub

  • Create a new IoT Hub Device and copy the connection string.

Logic App

  • Create a new Send Grid Account.
  • Create a logic app using logicapp\template.json as guidance

Anomaly Detector API

  • Create the Anomaly Detector cognitive service resource in Azure.
  • Copy the key and endpoint from the Quick Start section.

Function App

  • 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>
  • 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 in D:\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 in sendEmail method with the logic app workflow path

Simulated PLC

  • 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 .