Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Vienna from September 15-18, 2025, for the ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM. Get registered

Reply
mmilosanovic
Advocate IV
Advocate IV

Some methods in notebooks do not work when executed from Data Pipelines deployed via SPN

Hi,

 

I already created the ticket with Microsoft (2504161420001430) and also opened the issue here and also seems to be related to this issue here.

 

`notebookutils.runtime.context.get("currentWorkspaceName")` works when executed directly from the Notebook, but does not work when executed from the DataPipeline which was deployed in another workspace using Service Principal via Fabric Core APIs (Create Item - https://learn.microsoft.com/en-us/rest/api/fabric/core/items/create-item?tabs=HTTP).

If I reopen the notebook with my personal account and rerun it again from the DataPipeline, then it works. This implies that the issue is coming from the service principal somehow losing permissions/token and is not able to read the current workspace name where it is running in from the notebookutils runtime context.

What I noticed is that this issue is also present for other built-in methods in Fabric. For example: `notebookutils.lakehouse.get()` and `synapsesql()`. Details can be found here: https://github.com/microsoft/fabric-cicd/issues/202#issuecomment-2797384465. Same approach is being followed in the fabric-cicd library and it is using SPN auth + Fabric Core Create Item APIs (as already mentioned and referenced above).

 

Did anyone else experience the same/similar issues?

 

Best regards,

Milos

26 REPLIES 26

Thank you for the detail in your response. You said you were able to run as SPN.... do you know if you were able to run these simple lines? 

 

import json
import sempy.fabric as fabric
from notebookutils import mssparkutils

#Instantiate the client
client = fabric.FabricRestClient()

# Get Workspace
workspaceId = fabric.resolve_workspace_id([workspace name here])

It works by explicitly creating an Service principal token implementation and passing that to fabric rest client. Here is a blog that can helped me with this implementation.

 

https://fabric.guru/using-service-principal-authentication-with-fabricrestclient

v-tsaipranay
Community Support
Community Support

Hi @mmilosanovic ,

Thanks for sharing the details and for raising a support ticket .

 

The issue likely stems from the notebook’s runtime context not being fully initialized when triggered via a Service Principal (SPN) using the Fabric Core APIs. This affects methods like notebookutils.runtime.context.get() and others that rely on workspace-level context.

 

In the meantime, please try the following steps:

  • Ensure the SPN has Contributor or higher role at the workspace level.

  • Verify that the workspace is explicitly included in the SPN’s access scope.

  • Test execution using a user-assigned managed identity if supported.

  • As a workaround, consider passing the required context (e.g., workspace name) as parameters to the notebook via the pipeline.

Please continue monitoring your support case with microsoft and share any updates or guidance as it becomes available, so that other community members who have similar problems to solve it faster.

 

Thank you.

deepakagarwal
Regular Visitor

Having same issue.

annhwallinger
Helper I
Helper I

we are also having the same issue

SparkedMy401
Regular Visitor

Yes, I'm having the same issue.. I'm using the fabric-cicd library

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June FBC25 Carousel

Fabric Monthly Update - June 2025

Check out the June 2025 Fabric update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.