We can use Power Automate to get a list of the MS 365 subscriptions that your organization has acquired. We can do this using the Microsoft Graph API and the following properties: skuPartNumber, consumedUnits and prepaidUnits. In this post I’ll show you how to email a report of your current MS 365 subscriptions. In Part 2 we’ll improve the layout and formatting of the report and then schedule it to run on a weekly basis.
The demo flow assumes that you or your Azure admin has setup an App registration for Microsoft Graph API. See the below on how to do this see: Using App Registrations with Power Automate.
The Basic Flow
The flow starts by gathering information we need to provided from Microsoft Azure: tenant id, client id and the (client) secret:
The HTTP action is shown below. The URI is:
Note the properties that are needed for Authentication in the HTTP action:
HTTP request returns a lot of information. We are interested in just the following properties: skuPartNumber, consumedUnits and prepaidUnits. We can use a Select action along with expressions to limit the information to those properties:
These are the expressions you will need to enter:
1. body('HTTP')?['value'] 2. item()?['skuPartNumber'] 3. item()?['consumedUnits'] 4. item()?['prepaidUnits']?['enabled']
The prepaidUnits property refers to the maximum units or licenses available.
We then Create a HTML table from the output of the Select action:
Finally we add the HTML table to the email and send:
The Runtime Output
In the next post we’ll improve the layout and formatting of the report and then schedule it to run on a weekly basis.
Using App Registrations with Power Automate
Configuring an app registration in Azure AD allows us to grant Power Automate access to objects within our MS 365 tenant through the Microsoft Graph.
The flow assumes that you or your Azure admin have setup an App Registration for Graph API. The App Registration setup is described in the following post: Using Flow with Graph API and Creating app registrations for use with Power Automate
To gather information via Graph API the following information needs to be provided from Microsoft Azure:
- Directory (tenant) Id The ID of the Microsoft Azure Active Directory to retrieve information from.
- Application (client) Id The ID of the application that will connect to Microsoft Azure Active Directory, which in this case the integration connector.
- Application (client) secret The key that will be used as the secret in the connection to Microsoft Azure.
I setup the following demo App registration:
The application secret:
An example of the API permission: