We can embed Power BI reports in Jupyter notebooks, including notebooks crated in Microsoft Fabric. Let's see how! 

Power BI Python Client

This solution is enabled by using the Microsoft Python powerbiclient library within a Fabric Jupyter notebook.  This library has many other features, so do review it in its GitHub repo, but in this post we'll just do a basic report embedding within a workbook to see how to access a Power BI report from Python code.

The demo in this post is available as a YouTube video demo, so if you'd rather see this done than read about it, click the YouTube embedded video link instead!

Video solution walkthrough

Review the Report

The Power BI report used in this demo is a sample report built on the Contoso sample database.  Viewing the report in Fabric, we can see how it looks, and interact with its individual components in the browser.

The Power BI Report to Embed within the Jupyter Notebook

Create a New Notebook

Switching to the Data Science experience, we can create a new Jupyter Notebook by tapping the Notebook tile.

Create a new Jupyter Notebook

A new, empty Jupyter notebook is created, with some placeholder comments in the first cell.

A new notebook

To access the Power BI content, we first install the Python dependency powerbiclient using pip.

Install the Power BI Python Client

Next, we import needed dependencies from powerbiclient:

  • Report. In the end, we'll create a Report object that reads the Power BI content for display in the notebook.
  • DeviceCodeLoginAuthentication. This object is used to obtain an access token allowing the notebook to access Power BI content in Fabric.
Import Dependencies


To access Power BI content, we need an access token.  In Fabric, this is done by calling DeviceCodeLoginAuthentication() to begin an OAuth authentication flow.

Start OAuth Flow

The OAuth flow will prompt us to enter the device code provided in the Jupyter notebook browser window.

Entering the OAuth code

After entering the code, and confirming our Microsoft ID, we grant access to the Jupyter notebook so it can access the Power BI content.

Grant Access

After completing OAuth, we can create a new Report object, providing the Group, Report and Device Auth Token.

Create a new report object.

Finally, we can view the report within the Jupyter notebook!

View the Power BI Report in the Jupyter Notebook