Using Power Automate to get a list of your MS 365 subscriptions – Part 1

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.

MS 365 subscriptions report sent as an email.

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:

This is the basic flow.

The HTTP action is shown below. The URI is:

https://graph.microsoft.com/v1.0/subscribedSkus

Note the properties that are needed for Authentication in the HTTP action:

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:

Select action

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:

Create HTML table action

Finally we add the HTML table to the email and send:

Send an email with the HTML table embedded.

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:

The information you need to provide to MS Graph before we can use it.
  • 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:

Sample App registration screen.

The application secret:

Show the application secret.

An example of the API permission:

API permissions screen

One thought on “Using Power Automate to get a list of your MS 365 subscriptions – Part 1

Add yours

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Website Built with WordPress.com.

Up ↑

%d bloggers like this: