06 Create an Azure Logic App - gloveboxes/AiPoweredPredictiveMaintenance GitHub Wiki

Create an Azure Logic App

This exercise assumes you have access to an Azure subscription. If not, you can create a free trial Azure subscription. If you are a student, you can create a free trial student Azure subscription, no credit card is required.

  1. Sign in to the Azure web portal.
  2. From the Search resources, services, and docs textbox, search for logic apps.
  3. Select Logic apps from the list of services.
  4. Select + Add.
  5. As appropriate, select or create a new resource group.
  6. Name your Logic app. It must be a globally unique name.
  7. Select the closest region.
  8. Select the Consumption plan type.
  9. Select Create and review.
  10. Select Create.

Azure will now deploy your Logic App, this will take about 1 minute.

  1. When the Logic app has been deployed, select Go to resource.
  2. Select the Workflows from the Logic app sidebar menu.
  3. Select + Add.
  4. Name the workflow PredictiveMaintenance.
  5. Select Stateless.
  6. Select Create.
  7. Select the newly created PredictiveMaintenance workflow.
  8. Select Get started, this will start the workflow designer.

Design a workflow

  1. From Search connectors and triggers, type request.

  2. Select Request

  3. Select theHTTP request.

  4. Select Use sample payload to generate schema.

  5. Paste the following sample payload.

    {
        "enqueuedTime": "2022-03-24T05:31:59.354Z",
        "enrichments": {
            "ContactName": "Jo Bloggs",
            "ContactNumber": 556565656,
            "DeviceDescription": "Contoso HVAC Model B Rev 1.1",
            "DeviceLocation": "Sydney Townhall",
            "DeviceName": "HVAC System (Mayor's office)",
            "FaultPrediction": "rattle"
        }
    }
    
  6. Select Save


Save the HTTP POST URL

The HTTP POST URL is generated when you save the workflow.

  1. Copy and paste the generated somewhere safe as you will need it when you connect IoT Central to the Logic app.

    The image shows the generated HTTP POST URL


Create a post to Microsoft Teams operation

  1. From the workflow designer, select + to add a new action.

  2. Select Add an action.

  3. Select Choose an operation.

  4. From Search connections and actions, type Microsoft Teams.

  5. Select the Azure tab in the search results.

    The image shows how to search for Microsoft Teams

  6. Select Microsoft Teams.

  7. From the list of Actions, select Post message in chat or channel.

  8. Sign in to create a connection to Microsoft Teams.

  9. When the Microsoft Teams connection has been created, select Channel from the Post in selection.

  10. Select the Predictive Maintenance team from the Team selection.

  11. Select General from the Channel selection.

  12. Paste the following text into Add message. This adds message text as well as dynamic content

    HVAC Maintenance Alert
    
    Fault prediction: @{triggerBody()?['enrichments']?['FaultPrediction']}
    
    HVAC Details
    
    HVAC ID: @{triggerBody()?['enrichments']?['DeviceName']}
    HVAC Description: @{triggerBody()?['enrichments']?['DeviceDescription']}
    
    Custom contact details
    
    Contact name: @{triggerBody()?['enrichments']?['ContactName']}
    Contact number: @{triggerBody()?['enrichments']?['ContactNumber']}
    Location: @{triggerBody()?['enrichments']?['DeviceLocation']}
    
  13. Select Save, to save the workflow.