How to Integrate Azure Monitor With MS Teams

Keeping a track of critical alerts from all your cloud servers can be a daunting task.

Although Azure Monitor does provide built-in features to send alerts via emails, SMS, etc., given the fact that they often get mixed up with other unimportant emails/SMS, this doesn’t help much. Also, those alerts often get unnoticed.

In order to keep track of all your critical alerts, MS Teams can be a desirable go-to platform. Imagine getting all your alerts sent by Azure Monitor straight into specific channels of specific Teams created on the MS Teams platform.

In such a case, it would become extremely easy to keep track of all your critical alerts, all in one place.

Enough of the background talk, now let’s dive straight into the topic.

So what we are going to do is, integrate the Azure Monitor with MS Teams to receive the alerts of a particular server directly onto MS Teams .

Let’s look at the steps that we need to follow:

  1. Create an ‘alert rule’ for the specific resource that you want to monitor.
  2. Configure that alert rule with an ‘action group’ that you can create right there.
  3. Integrate a ‘logic app’ using a webhook onto that action group (you need to create a logic app first).
  4. Integrate MS Teams with the logic app using the MS Teams connector.

That’s all that you need to do in order to start receiving alerts from Azure Monitor directly on MS Teams.

We will look at the process in detail, and that too in reverse order :)

Firstly, go to MS Teams and create a new team. Then create a new channel that you want to use for receiving those alerts.

Creating a new team on MS Teams

That’s it, we are done with the MS Teams. Now let’s move on to the logic apps.

Firstly, create a logic app using your Azure portal.

Creating a logic app: In the portal, search for ‘Logic Apps’ → Click on ‘Add’ → Create (or enter the name of) the Resource Group that you want your logic app to live in → Enter a name for Logic App → Hit ‘Review + Create’ → Click ‘Create’.

Creating a Logic App

Then go to your logic app.

Click on ‘When a HTTP request is received’.

Here you first need to import a sample payload for the respective alert type.

Let’s say you want to set an alert for measuring ‘Percentage CPU’ for one of your VMs.

In that case, copy the below sample payload and paste it into the text box that comes after clicking on ‘Use sample payload to generate schema’, and click on ‘Done’.

"schemaId": "AzureMonitorMetricAlert",
"data": {
"version": "2.0",
"status": "Activated",
"context": {
"timestamp": "2018-04-09T19:00:07.7461615Z",
"id": "...",
"name": "TEST-VM CPU Utilization",
"description": "",
"conditionType": "SingleResourceMultipleMetricCriteria",
"condition": {
"windowSize": "PT15M",
"allOf": [
"metricName": "Percentage CPU",
"dimensions": [
"name": "ResourceId",
"value": "d92fc5cb-06cf-4309-8c9a-538eea6a17a6"
"operator": "GreaterThan",
"threshold": "5",
"timeAggregation": "PT15M",
"metricValue": 1.0
"subscriptionId": "...",
"resourceGroupName": "TEST",
"resourceName": "test-vm",
"resourceType": "Microsoft.Compute/virtualMachines",
"resourceId": "...",
"portalLink": "..."
"properties": {}

For more details on other types of sample payloads, refer to the original documentation.

You’ll now see something like below:

Click on ‘Save’ and copy the URL that gets generated at the top, in front of ‘HTTP POST URL’. This will be the endpoint where we would send the triggers from Azure Monitor.

Then click on ‘+New step’, and select ‘condition’.

Then add two condition checks,

schemaId == AzureMonitorMetricAlert
version == "2.0"

You need to select schemaId and version from dynamic content fields like below:

Finally, it would look like:

In the ‘True’ section, click on ‘Add an action’ and select ‘For each’, and add ‘allOf’ from the dynamic content onto the text box of For each.

Then click on ‘Add an action’ present in the ‘For Each’ section, and search for ‘MS Teams’ connector. Click on MS Teams when you see it. It will look something like:

Now in the list of actions that you see above, scroll down and select ‘Post a message (V3) (preview). You will see something like below:

Now you might first need to sign in to the MS Teams first, in the same box that you see above. Since I’m already signed in so I can see this directly.

Once you’ve signed in, click on the dropdown arrow that you see in the box corresponding Add Team ID. You’ll see the list of teams that you’ve created on your MS Teams platform. Choose the one you created specifically for receiving the alerts when we started with this article.

Do the same for the channel field.

Then fill in the message body with something as shown in the image below.

Now go back to the main dashboard. Search for ‘Alerts’.

First, we will set up an ‘Action Group’, so click on ‘Manage Actions’.

Click ‘+Add action group’.

Now fill in the relevant details according to your requirement:

Now click on ‘Actions’ from the tabs above.

Then click on the dropdown of ‘Action type’ and select ‘Webhook’. Then give any name to this acton group in the ‘Name’ field. Then in the ‘Selected’ field, paste the URL that you copied from the Logic App.

If you didn’t copy it earlier, don’t worry. You can still go back to that Logic App, then go to ‘Logic App Designer’ from the sidebar, then click on ‘When a HTTP request is received’. There you will see the URL. Copy it.

Now paste the URL if you still didn’t. It will look something like:

Now click on ‘Review+Create’. After the validation gets completed, click ‘Create’.

After a few seconds, your action group will get created.

By this time, we have successfully connected our Logic App with MS Teams as well as our action group with Logic App.

All we need to do now is to create ‘Alert rules’ and connect them with the action group that we just created. The alerts get triggered when a particular condition gets satisfied in the Alert rule that we create. It originated from Azure Monitor.

The connection flow would then look like:

Azure Monitor → Alert Rule → Action Group → Logic App → MS Teams

Go back to ‘Alerts’ dashoard again.

Click on ‘+ New Alert Rule’.

Click ‘Select resource’. Then set the filter for virtual machines. Now choose the VM that you want to get alerted for.

In my case, the name of VM was ‘linuxvm’.

Now, click on ‘Select Condition’ and then in the popup like screen that appears, search for ‘Percentage CPU’ and select.

Then on scrolling down a bit, you’ll see something like:

Here, fill in the required fields according to your requirements and then click done. For example, I’m here setting the ‘Operator’ as greater than or equal to’, ‘Aggregation type’ as ‘Maximum, ‘Threshold value’ as ‘95’ (%), and ‘Frequency of evaluation’ as ‘Every 5 Minutes’ as shown below. Now click on ‘Done’.

Now we need to set the ‘action group’. Click on ‘Select action group’.

Now select the name of the action group that you created. In this example, I’m selecting ‘Performance Alerts’ — an action group that I created for this purpose.

Then click ‘Select’.

Now we are good to go! Just click on ‘Create alert rule’ and the rule will be created successfully.

Now whenever the alert gets triggered, you’ll receive the alert on MS Teams as shown below

Congrats! You have now successfully integrated Azure Monitor with MS Teams for a particular server.

Managing people and Virtual Machines from 9-6 | Built 12K+ community on LinkedIn and 7K+ community on Quora | IIT Kanpur’20