Azure Service Health Notifications with SlackBot (LogicApps)

Before logic apps, the code I would generally use would involve me writting some code ( ensure I have to right payload of request to format content. Then, based on the message, post into slack.

With Logic Apps the time of “glue-ing” the interaction together has dramatically decreased.

What are Logic Apps

Logic apps can easily help integrate data, applications events, triggers, and services with other systems and interfaces. At core of logicapps are a large set of pre-developed “connectors.” Think of connectors are as predeveloped web-apis (or “hooks”) that reduce coding if any that need to occur.

Now with service hooks, I can easily integrate with one of the prebuilt connectors to handle the data schema and post into slack

Azure Health Service Slack Alert Pre-Steps

In order to complete this you will need

  • Azure Subscription with at least Contributor role for the subscription or resource group
  • Slack Workspace to allow the Logic app to post into a channel

Getting Started

Create the LogicApp

In this first step we’re going to create a new logic app.

Login in the Azure Portal (link) and Click Create a resource

For the resource type “Logic App”

… I’m using the following settings but feel free to use your own

  • Name: logic2slack
  • Resource Group: rglogic2slack
  • Location: East US

Then click Create

I. Navigate to your new logic app

Click the resource group blade->rglogic2slack then the logic app resource we created

Type “when a http request is received” in the connectors and triggers

Important: Get the sample ServiceHealth Alert Schema from Microsoft

Copy the data schema from the common alert schema from Microsoft (link). Copy and paste it would be the easiest

Clicking “Use Sample Payload to Generate Schema” and pasting in the raw sample service health payload from microsoft

Paste the sample payload into schema from Microsoft 

Logic Apps will create a schema from the raw payload the result will look like this

Click “Done”

II. Click Add a Step

Search for Slack and choose post a message

to your slack workspace with your credentials.

Note: You will be prompted to allow LogicApps access to your slack

Select the channel you want to use in my case on going to use a test channel

Note you can pick dynamic contact

Click Save

At this point we’ve essentially create a restful reg that will be called by an Alert (which we will later wire up to work)

Wiring the LogicApp to Health Alerts

At this point we have alert apps

I. Navigate to Health Alerts

Login to the Azure Portal and Navigate the Azure Monitor Blade -> Service Health -> Health Alerts

II. Click “Create service health alert”

  • Under Alert Target: Select all the regions and event types
  • Under Actions Choose “Create action group”

III. The Add Action Group

Enter in your datails:

  • Action Group: (something unique)
  • Short Name: Something unique
  • Resource Group: (new or use the resource group for your logic app)

Important: Ensure “Enable the common alert schema” is set to yes

Click ok

Click Done

Reference Material

Slackbot template: