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.
- Sign in to the Azure web portal.
- From the Search resources, services, and docs textbox, search for logic apps.
- Select Logic apps from the list of services.
- Select + Add.
- As appropriate, select or create a new resource group.
- Name your Logic app. It must be a globally unique name.
- Select the closest region.
- Select the Consumption plan type.
- Select Create and review.
- Select Create.
Azure will now deploy your Logic App, this will take about 1 minute.
- When the Logic app has been deployed, select Go to resource.
- Select the Workflows from the Logic app sidebar menu.
- Select + Add.
- Name the workflow PredictiveMaintenance.
- Select Stateless.
- Select Create.
- Select the newly created PredictiveMaintenance workflow.
- Select Get started, this will start the workflow designer.
Design a workflow
-
From Search connectors and triggers, type request.
-
Select Request
-
Select theHTTP request.
-
Select Use sample payload to generate schema.
-
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" } }
-
Select Save
Save the HTTP POST URL
The HTTP POST URL is generated when you save the workflow.
-
Copy and paste the generated somewhere safe as you will need it when you connect IoT Central to the Logic app.
Create a post to Microsoft Teams operation
-
From the workflow designer, select + to add a new action.
-
Select Add an action.
-
Select Choose an operation.
-
From Search connections and actions, type Microsoft Teams.
-
Select the Azure tab in the search results.
-
Select Microsoft Teams.
-
From the list of Actions, select Post message in chat or channel.
-
Sign in to create a connection to Microsoft Teams.
-
When the Microsoft Teams connection has been created, select Channel from the Post in selection.
-
Select the Predictive Maintenance team from the Team selection.
-
Select General from the Channel selection.
-
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']}
-
Select Save, to save the workflow.