Configure access to Power BI Rest API
Before you can use the Power BI Rest API, you need to configure a few things. In this blog, I’ll explain the exact steps you need to take before using the API.
There are 4 steps:
- Create a Service Principal (SPN) in Azure Portal
- Add Security Group
- Configure Power BI admin portal
- Configure Power BI Workspace
1. Create a Service Principal (SPN) in Azure Portal
Go to your Azure Active Directory in your Azure portal and click on App registrations.
Click + New registration.
Add a name, keep the defaults and click Register
Your application is now added. Click on the new application.
Before we can use this application (Service Principal), we need a secret. Go to Certificates and secrets.
Click + New client secret.
Enter a Description and click Add.
You get a secret value that is only shown once. So, copy the value and store it in a safe place, like Azure Key Vault.
On the Overview page, you can find the Application ID and Tenant ID. You need these when you connect to the Power BI Rest Api.
2. Add Security Group
Back on the overview page of the Azure Active Directory, go to Groups.
Click New group.
Select the Security group type and give the group a Name. Click Create.
Now we have this security group, we need to add our service principal to this group.
From your new group, select Members and click + Add members.
Search for your service principal and select this user. Then click Select.
3. Configure Power BI admin portal
Go to the Power BI admin portal: https://app.powerbi.com/admin-portal/tenantSettings Scroll down to ‘Developer settings’.
- Allow service principals to use Power BI APIs
- Add your security group
- Click ‘Apply’
Microsoft says it can take 15 minutes before this change is processed in the background. In my experience, it can take more than an hour. So, you have to be a bit patient before you can go to the final step.
4. Configure Power BI Workspace
The last step is to give permission to the security group.
Go to Power BI Service and select the Workspace where your service principal needs permissions. Click Access.
Add the new security group with either member or admin permission. You need admin permissions if you need to automate data refresh, schedule refresh or other data source related activities. When you’re only deploying Power BI files without additional actions, member permissions are sufficient.
Now, you’re all setup to use the Power BI Rest API.