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.
- Sign in to your Power BI account
- Give a name to your application and select the proper level of API access you want to grant this application
- 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.
- 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.
- Grant permissions
- If all goes well, you should see the screen below, and download the sample application Power BI has created for you.
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.
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.
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.
- Right click the project and restore NuGet Packages
- Open NuGet Packages in the Package Manager Console, and type in the following command to update: Update-Package Microsoft.CodeDom.Providers.DotNetCompilerPlatform -r
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.
Hopefully, this post has helped you jump start on having an application that embeds a Power BI report on a web page.