Embedding Power BI reports using App-only token “Customized”

Embedding Power BI reports using App-only token “Customized”

In this post, you will learn how to embed Power BI reports into your web application using Service principal and share with your customers who do not have Power BI account.

Embedding report using Service Principal means you don’t need a master account that has a username and password to authenticate into your application. Service principal uses an application ID and an application secret to authenticate the application (App-only token).
The following information is required to embed your report into an application using App-only token:

  1. Application ID
  2. Application Secrete
  3. Tenant ID
  4. Workspace ID
  5. Report ID

From Azure portal you will get the Application ID, Application secrete and Tenant ID. From Power BI service you will get the workspace ID and the report ID.

There are five main steps to complete the process.

Step one: Register your Web Application in Azure

  • From Azure Portal, click Azure Active Directory
  • Click App registration
  • Click New App Registration
  • Enter the app name and any valid URL
  • Click create
  • Copy the Application ID

Note that App type is Web app/API

  • Click on settings
  • Click keys and type Description
  • Choose Duration and save
  • Copy the application secrete key under value

Step two : Create a security group in Azure and add the Registered App to the security group as member

  • From Azure Active Directory
  •  Click groups
  • New Group
  • Click Members
  • Locate the App you created
  • Click Select
  • Click Create

Note: Group type: security, Membership Type: Assigned

  • Click on Azure Active Directory
  • Select Properties
  • Copy the Directory ID (Tenant ID)

Now from Power BI Service, we will get the Workspace ID and the Report ID

Step three: Allow Service Principal to use Power BI APIs by adding the Security group in the Developer Settings

  • From Power BI Admin Portal ( Admin account is required)
  • Click Tenant settings
  • Go to Developer Settings
  • Enable “Embed Content in apps”
  • Enable “Allow Service principals to use Power BI APIs”
  • Add the security group you created in Azure
  • Click Apply

Step four: Create App Workspace(V2)In Power BI Service

  • Select workspaces
  • Click Create app Workspace
  • Enter Workspace name
  • Click save

Because I do not currently have reports in the new workspace, I am using the sample report.



  • Under Access add the App you created in Azure and give it Admin Permission to the Workspace
  • Click Add
  • Copy the Workspace ID and report ID from the URL

Group ID = Workspace ID

Step five: Download the embed sample App from GitHub to try out the sample application. Or embed within your own application

  • If you are using the sample Application, open the “App Owns Data” folder
  • Open the Solution file in Visual studio
  • Select Web.config
  • Enter the 5 values and click run

Application ID, Application Secrete, Tenant ID, Workspace ID and Report ID.

Because we are embedding report, we click “Embed Report” and see your report embedded into the sample App for your Customers.

You will need an Embedded or Premium capacity to move to Production :
https://docs.microsoft.com/en-us/power-bi/developer/embed-sample-for-customers#move-to-production

Happy Embedding 🙂

3 thoughts on “Embedding Power BI reports using App-only token “Customized”

  1. Thanks Ruki! Great piece. Where can I get the JavaScript code to embed this into my own app?

Comments are closed.

Comments are closed.