This article is about how to call Microsoft Fabric and Power BI APIs in Power Automate without using the Service Principal (SPN). I mean without having the client ID and secret.
Let me tell you why I have chosen this topic – If we want to call the APIs, we need an App registered in Microsoft Entra ID and it will give the client ID and secret which is the primary pre-requsitie to call the APIs. Sometimes, it will be difficult to get the App registred becase this will be manage and maintained by Azure Team in the organization and their policies may delay the process of registering the app. If you are in that situation, then this article help you to call the APIs even without an Microsoft Entra ID App using Power Automate.
Let me cover from the beginning to help everyone understand.
Microsoft Fabric and Power BI provides REST API support to access the platform through APIs to automate the development, deployment and etc. We have a huge list of APIs available for both Power BI and Fabric. Check the Microsoft documentation to see all the list of APIs.
Microsoft Fabric – Microsoft Fabric REST APIs for automation and embedded analytics – Microsoft Fabric REST APIs | Microsoft Learn
Power BI – Power BI REST APIs for embedded analytics and automation – Power BI REST API | Microsoft Learn
If you are new to using these APIs then I would recommend going through my previous articles and videos where I have covered the detailed information.
Option Try IT – Access Power BI REST APIs Effortlessly – Hari BI Academy
You also can call these APIs from any other applications which supports API trigger. For example, Postman, PowerShell, Power Automate etc.
In general, if you want to call the APIs, you need an App should be registered in Microsoft Entra ID with the required permissions which is nothing but the scope for that App. This App provides a client ID and client secret. This APP is nothing but the Service Principal (SPN). This client ID and client secret helps to get the Authentication token (Bearer type) and that token will be used as an authorization to call the APIs.
Steps to Access the APIs.
- Generate Token – Get the token using username and password or client credentials
There are two ways to generate token.
a. We can use grant type as individual user email and password to generate the token. In this case, user permission is considered as a scope when we call the APIs.
b. In case, if we use client_credentials as grant type then we don’t need to pass the individual email and password. It will consider the SPN permissions as scope.
2. Call APIs – Call the Power BI APIs with the Authorization as Bearer token which got generated in previous step.
I believe, now you have the basic understanding of APIs and how to use.
As we understood that the client ID and secret is one of the pre-requisite, Azure AD team should create an app and share the details. In an organization, Azure and Power BI/Fabric will be managed by different teams. We need to request the Azure for the App – Client ID and secret. In some organizations, there is a strict process to be followed to raise a request and get the client ID and secret. I have seen Organization where Power BI admin team waited for a month and even more to get the client ID and secret.
Lets go into the core infiormation of this article – How Power Automate can save here if you want to call the APIs.
Power Automate has some pre-build actions for Power BI like dataset refresh, actions for export, goals etc. Lets focus on how to call other APIs in Power Automate. For an understanding purpose, lets take below API
API – https://api.powerbi.com/v1.0/myorg/groups
Power Automate has a connector called “HTTP with Microsoft Entra ID (preauthorized)“. This is one of the great connectors to call any APIs within Microsoft which supports Entra ID as an authentication.
Please check Microsoft article about this connector and understand more information – HTTP with Microsoft Entra ID (preauthorized) – Connectors | Microsoft Learn
How to configure?
Configure this action is pretty simple. We need to provide below information. One more information, this is a premium connector.
Below is the connector.
Use the below information,
Base Resource Url – https://api.powerbi.com
Microsoft Entra ID Resource URI (Application ID URI) – https://analysis.windows.net/powerbi/api
Then sign in with your credentials. Once it is successfully signed in then you will see a window like below to enter the API details like method and URL.
You no need to provide Authorization header.
We can run the flow and it will show the response like below.
If you want to use this connector for Microsoft Fabric with Power BI items then use the below details.
Base Resource Url – https://api.powerbi.com
Microsoft Entra ID Resource URI (Application ID URI) – https://analysis.windows.net/powerbi/api
You can use Try It option to call any APIs which is the easiest way without any extra dependencies. In case, if you want to automate the APIs on a daily schedule or you want to process the results before you consume then go with Power Automate.
Considerations:
- As this API calls are using user credentials, the API permission scope is limited to the user access. For example, if you have access to see only 4 workspaces then the response will show only those 4 workspaces.
- SPN is the recommended approach if you want to get information for your entire Power BI / Fabric tenant as the SPN can be added as an admin API. Also, SPN does not require username and password which will change often then it will impact the flow.
Please share your feedback in the below comment section. Happy Learning!!
Leave a Reply