Bringing Power Automate and Office 365 Service Communications API v2 together to deliver Current Status into Microsoft Teams.

I have been recently looking how to provide the Current Status of the Microsoft 365 stack into an automated process so I could quickly identify any outages. The Office 365 Service Communications API v2 does exactly that and also allows additional options like Power Automate and PowerShell to pull the data. So in this particular article I am going to look at pushing the Current Status into Microsoft Teams so not just myself but anyone who is apart of the Teams is able to see the status.

Prerequisites

  • You have configured Azure AD App for Office 365 Service Communications API v2
  • Licensed for Power Automate either;
    • Per user plan
    • Per user plan with attended RPA
    • Per Flow plan

Configuring Power Automate to deliver posts into Microsoft Teams Channel.

You will now need to repeat the above process for client_secret and tenantid

After that, you need to create an HTTP action to query the Office 365 API. Populate the same as below, making sure all 3 variables are used.

Please be aware the HTTP Connector has an associated cost due to being a Premium Connector. This cost can be found at the following link

If you were to run the flow at this point it would return a big output of JSON. It’s best to use the Parse JSON action to make it easier to read. Set the Content as the Body of the previous HTTP action and the Schema below:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
{
    "type": "object",
    "properties": {
        "@@odata.context": {
            "type": "string"
        },
        "value": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "FeatureStatus": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "FeatureDisplayName": {
                                    "type": "string"
                                },
                                "FeatureName": {
                                    "type": "string"
                                },
                                "FeatureServiceStatus": {
                                    "type": "string"
                                },
                                "FeatureServiceStatusDisplayName": {
                                    "type": "string"
                                }
                            },
                            "required": [
                                "FeatureDisplayName",
                                "FeatureName",
                                "FeatureServiceStatus",
                                "FeatureServiceStatusDisplayName"
                            ]
                        }
                    },
                    "Id": {
                        "type": "string"
                    },
                    "IncidentIds": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "Status": {
                        "type": "string"
                    },
                    "StatusDisplayName": {
                        "type": "string"
                    },
                    "StatusTime": {
                        "type": "string"
                    },
                    "Workload": {
                        "type": "string"
                    },
                    "WorkloadDisplayName": {
                        "type": "string"
                    }
                },
                "required": [
                    "FeatureStatus",
                    "Id",
                    "IncidentIds",
                    "Status",
                    "StatusDisplayName",
                    "StatusTime",
                    "Workload",
                    "WorkloadDisplayName"
                ]
            }
        }
    }
}

Once the data has been parsed, you can loop through each service and check for service status. The next action is to add an Apply to each action for the value variable.

Within the loop, add a Group Condition that Status is equal to ServiceOperational and ServiceRestored.

Under the If No condition, you can add an action because the service is not operational. To demonstrate, I’ve configured steps for posting a message to Microsoft Teams as shown below

This will then be triggered when there is any status that doesn’t match the define ServiceOperational or ServiceRestored within Office 365. As you can see below I have been notified in Microsoft Teams for an issue with Microsoft 365 stack.

Regards
The Author – Blogabout.Cloud