Embed Power BI reports

Power BI has an embedding capability that allows developers to embed an existing report, dashboard or tile in a web page. As a result, viewers no longer need a license to access the reports or dashboards. The embedded reports and dashboards are fully functional and interactive just like they do in Power BI App. This post shows you how to set the process up. 

To have the embedding capability, you need at least a pro license. 

Step 1 - Register and download your sample application

Go to this website and select “Embed for your customers” solution. Follow the steps shown on the screen.

Fig 1 Welcome Page of Power BI Embedding Application Site
  1. Sign in to your Power BI account
  2. Give a name to your application and select the proper level of API access you want to grant this application
  3. If you don’t have a workspace yet, you can type in the name of the workspace you want to create. If you already have a workspace under your account, you can hit Skip.
  4. If you don’t have the report uploaded yet, you can import the PBIX file and it will publish the report to the workspace. Otherwise, you can hit Skip. 
  5. Grant permissions
  6. If all goes well, you should see the screen below, and download the sample application Power BI has created for you. 
Fig 2 Download Sample Application Page

Step 2 - Fill in the missing info in the Web.config file

If you already have the report published to an existing workspace and skipped Steps (1.3) and (1.4), you need to open the Web.config file and type in the Workspace and Report ID. Here is Microsoft’s guide on how to find that info from the URL.

Fig 3 Workspace ID in the URL
Fig 4 Report ID in the URL

If you didn’t skip Steps (1.3) and (1.4), then Web.config file should already have that info filled out. But you still need to type in the password to your Power BI account. As recommended, it’s best to encrypt your password, instead of putting it directly in the file. 

Fig 5 Web.config File

Step 3 - Restore and update NuGet Packages

Before you test run the application, there are two things you need to do. Otherwise, you will get errors. 

  1. Right click the project and restore NuGet Packages
  2. Open NuGet Packages in the Package Manager Console, and type in the following command to update: Update-Package Microsoft.CodeDom.Providers.DotNetCompilerPlatform -r
Fig 6 Restore NuGet Packages
Fig 7 Open Package Manager Console

Step 4 - Test run the application

Once you hit the Run button, you should see the following pop-up browser screen. Click Embed Report and you will see the report embedded in the page.

Fig 8 Run the Application
Fig 9 Pop-up Browser Window
Fig 10 Embedded Power BI Report

Hopefully, this post has helped you jump start on having an application that embeds a Power BI report on a web page.