The Power BI API contains many useful features if you’re looking to interact with Power BI at the API level. In order to use it, we need to register an Azure App first. In this post, we will look at how to do this.
There are 2 options of how to register an Azure App – through the Azure portal and through the Power BI service. Let’s start with the Power BI Service.
Go to https://dev.powerbi.com/apps and click Sign In:
Give the App a name, such as Contoso Power BI Integration, and select the Application type and home page URL. Here we will select Server-side web application:
Enter a redirect URL and select which Power BI access the app should have. Below I am checking Select All, meaning the app has access to Reading, Writing and Creating:
Once Registered, we are provided with an Application ID and an Application Secret. Click Close:
The app has now been registered:
Pretty simple way of setting this up. Alternatively, let’s look at doing this through the Azure portal. To register an app in the Azure portal, go to https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade/quickStartType//sourceType/ and select New Registration:
Provide a name, e.g. PowerBIApp, and the supported account types, e.g. Single tenant, Multitenant etc, and click Register:
Note the Application Client Id to use when integrating with the API:
Select API Permissions and click Add a permission:
Select Power BI Service:
I will grant access to several pieces of Power BI API functionality, and click Add Permissions:
Next, click on Grant admin consent for your org (or you may run into the error “The user or administrator has not consented to use the application”):
You will be prompted to accept the conditions:
Once complete, go to Certificates and Secrets. We will create a new secret that we will use when using the API:
Give the secret a name and duration:
That’s it, you are now set up to integrate to the Power BI API.