“Exception: Power BI report is not embedded” inside Azure Databricks

We are trying to use the powerbiclient package inside an Azure Databricks notebook to get information on reports but we are getting the error Exception: Power BI report is not embedded.
The same code works instead if we use it locally on Visual Studio Code.

  • Azure Databricks cluster: Personal Compute, runtime 15.3
  • Packages of interest:
    • powerbiclient==3.1.1

Here is the code we are using:

!pip install powerbiclient==3.1.1
dbutils.library.restartPython()
from powerbiclient import Report, models
from io import StringIO
from ipywidgets import interact
import requests
import json

We tried both authenticating via Device Code Login and Service Principal, but we need to stick with the second option:

# # option 1
# from powerbiclient.authentication import DeviceCodeLoginAuthentication
# device_auth = DeviceCodeLoginAuthentication()

# option 2
def azuread_auth(tenant_id: str, client_id: str, client_secret: str, resource_url: str):
    """
    Authenticates Service Principal to the provided Resource URL, and returns the OAuth Access Token
    """
    url = f"https://login.microsoftonline.com/{tenant_id}/oauth2/token"
    payload = f'grant_type=client_credentials&client_id={client_id}&client_secret={client_secret}&resource={resource_url}'
    headers = {
        'Content-Type': 'application/x-www-form-urlencoded'
    }
    response = requests.request("POST", url, headers=headers, data=payload)
    access_token = json.loads(response.text)['access_token']
    return access_token

tenant_id = 'XXX'
client_id = 'YYY
client_secret = 'ZZZ'
scope = 'https://analysis.windows.net/powerbi/api/.default'
resource_url = 'https://analysis.windows.net/powerbi/api'

token = azuread_auth(tenant_id, client_id, client_secret, resource_url)

And then we call the report:

group_id = '123-456'
dataset_id = 'abc-def'
report_id = '7g8-h9i'
report = Report(group_id=group_id, report_id=report_id, auth=token)

But we see that it is not embedded:

print(report._embedded)
# False

If we try to display the report we obtain nothing:

def loaded_callback(event_details):
    print('Report is loaded')
report.on('loaded', loaded_callback)

def rendered_callback(event_details):
    print('Report is rendered')
report.on('rendered', rendered_callback)

report.set_size(200, 300)

report

And if we try to get the pages we get the aforementioned error:

pages = report.get_pages()


Exception                                 Traceback (most recent call last)
File <command-2809091020085831>, line 3
      1 report_dict = {}
      2 # Get list of pages
----> 3 pages = report.get_pages()
      4 for page in pages:
      5     report.set_active_page(page['name'])

File /local_disk0/.ephemeral_nfs/envs/pythonEnv-48b6b502-a176-4d52-a15d-9ed2a921ac04/lib/python3.11/site-packages/powerbiclient/report.py:566, in Report.get_pages(self)
    560 """Returns pages list of the embedded Power BI report
    561 
    562 Returns:
    563     list: list of pages
    564 """
    565 if not self._embedded:
--> 566     raise Exception(self.REPORT_NOT_EMBEDDED_MESSAGE)
    568 # Start getting pages on client side
    569 self._get_pages_request = True

Exception: Power BI report is not embedded

Is there a way to embed PowerBI reports inside Azure Databricks notebooks?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật