{ "definition": { "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", "actions": { "For_each": { "actions": { "Condition": { "actions": { "Send_email_(V2)": { "inputs": { "body": { "Body": "

Dear Team
\n
\nHealth Status Alert threshold value of 0.50 was triggered.
\nThe turbochargers details as follow:
\nTurbo ID: @{body('Parse_JSON')?['turbo_id']}
\nHealth Score: @{body('Parse_JSON')?['healthscore']}
\nDate Time: @{body('Parse_JSON')?['datetime']}
\n
\nPlease investigate the issue.
\nThank you!

", "Subject": "Health Status Alert Triggered", "To": "leeys2@artc.a-star.edu.sg" }, "host": { "connection": { "name": "@parameters('$connections')['gmail_1']['connectionId']" } }, "method": "post", "path": "/v2/Mail" }, "runAfter": {}, "type": "ApiConnection" } }, "expression": { "and": [ { "less": [ "@float(body('Parse_JSON')?['healthscore'])", 0.5 ] } ] }, "runAfter": { "Parse_JSON": [ "Succeeded" ] }, "type": "If" }, "Parse_JSON": { "inputs": { "content": "@items('For_each')", "schema": { "properties": { "datetime": { "type": "string" }, "healthscore": { "type": "number" }, "turbo_id": { "type": "integer" } }, "type": "object" } }, "runAfter": {}, "type": "ParseJson" } }, "foreach": "@body('Query_documents_V3_2')?['value']", "runAfter": { "Query_documents_V3_2": [ "Succeeded" ] }, "type": "Foreach" }, "Query_documents_V3_2": { "inputs": { "host": { "connection": { "name": "@parameters('$connections')['documentdb']['connectionId']" } }, "method": "get", "path": "/v3/dbs/@{encodeURIComponent('aztruconnect')}/colls/@{encodeURIComponent('turbo_health')}/query", "queries": { "queryText": "SELECT TOP 8 c.healthscore,c.turbo_id,c.datetime from c ORDER BY c.datetime DESC" } }, "runAfter": {}, "type": "ApiConnection" } }, "contentVersion": "1.0.0.0", "outputs": {}, "parameters": { "$connections": { "defaultValue": {}, "type": "Object" } }, "triggers": { "Recurrence": { "recurrence": { "frequency": "Minute", "interval": 5 }, "type": "Recurrence" } } }, "parameters": { "$connections": { "value": { "documentdb": { "connectionId": "/subscriptions/xxxxxxxxxxxxxxxxxx/resourceGroups/xxxxxxxxxxxxxxxxxxxx/providers/Microsoft.Web/connections/documentdb", "connectionName": "documentdb", "id": "/subscriptions/xxxxxxxxxxxxxxxxxxxxxxx/providers/Microsoft.Web/locations/westus/managedApis/documentdb" }, "gmail_1": { "connectionId": "/subscriptions/xxxxxxxxxxxxxxxxxxxxxxxxxxxxx/resourceGroups/xxxxxxxxxxxxxxxxxxxxxxx/providers/Microsoft.Web/connections/gmail-1", "connectionName": "gmail-1", "id": "/subscriptions/xxxxxxxxxxxxxxxxxxxxxxxx/providers/Microsoft.Web/locations/southeastasia/managedApis/gmail" } } } } }