azure-quickstart-templates icon indicating copy to clipboard operation
azure-quickstart-templates copied to clipboard

Alert to Slack with Logic App instructions outdated, doesn't work with new flow

Open SheaBelsky opened this issue 3 years ago • 4 comments

alert-to-slack-with-logic-app

Issue Details

  1. The instructions for this template are outdated. When associating the webhook URL with the alert, there's no option to provide a webhook URL in the exact format that is output from the Logic App deploy. Instead, it's possible to directly link the Logic App to be triggered when the Alert fires. This would be great, except for the fact that the Logic App itself doesn't work.
  2. When the Logic App fires, there is an error that gets encountered, stopping the Slack message from being sent.
InvalidTemplate. Unable to process template language expressions in action 'Http' inputs at line '1' and column '1773': 'The template language expression 'triggerBody()['context']['portalLink']' cannot be evaluated because property 'context' doesn't exist, available properties are 'schemaId, data'. Please see https://aka.ms/logicexpressions for usage details.'.

The error likely comes from here: https://github.com/Azure/azure-quickstart-templates/blob/86acf7c320c5df72ee97784be4a4a9c8315a5016/demos/alert-to-slack-with-logic-app/azuredeploy.json#L110

Repro steps

  1. Deploy the Logic App using the existing instructions (these are fine)
  2. Get the Output of the Logic App Deploy and copy the part of the URL with the listCallbackURL (which is what I assume is the intention here, but the instructions are not clear)
  3. Edit the Action Group and attempt to set up a Webhook using the URL from step 2. Observe how the provided URL does not work here.
  4. Rather than setting up a Webhook, we can specify a Logic App as a side effect of the Action Group. Configure that then fire the alert.
  5. Navigate to the logic app run history, and click into the failed run. Observe the error that is visible here.

SheaBelsky avatar Jan 07 '22 00:01 SheaBelsky

Potentially related issues:

  • https://github.com/Azure/azure-quickstart-templates/issues/3319
  • https://github.com/Azure/azure-quickstart-templates/issues/3813
  • https://github.com/Azure/azure-quickstart-templates/issues/2632

SheaBelsky avatar Jan 07 '22 00:01 SheaBelsky

I removed HTTP POST method (second step) and changed third step to: "text": "Azure Alert - '@{triggerBody()['body']['body']['data']['context']['name']}' @{triggerBody()?['body']?['body']?['data']?['status']} on '@{triggerBody()['body']['body']['data']['context']['resourceName']}'. Details: @{triggerBody()?['body']?['body']?['data']?['context']?['portalLink']}" and it works perfectly now: image

savkusamdetka23 avatar Aug 04 '22 17:08 savkusamdetka23

any update on this ?

rubber-ant avatar Dec 15 '22 15:12 rubber-ant

I have this same problem, the instructions really need to be updated

OP-Klaus avatar Sep 10 '23 22:09 OP-Klaus