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
Sperotech
Frequent Visitor

Notebook Kusto connection fails when run as action in pipeline

Hi,

 

I have a notebook that saves data to a Kusto database anfd just runs fine with the Run All command in the notebook pane. However as an action within a pipeline I get the error message:

Notebook execution failed at Notebook service with http status code - '200', please check the Run logs on Notebook, additional details - 'Error name - Py4JJavaError, Error value - An error occurred while calling z:mssparkutils.credentials.getToken.
: java.io.IOException: 500 {"code":"TM_INTERNAL_ERROR","subCode":0,"message":"An internal error occurred.","timeStamp":"2024-10-16T12:33:50.8328415Z","httpStatusCode":500,"hresult":-2147467259,"details":[{"code":"RootActivityId","message":"a1e5ed04-3da7-43ec-a6ab-5c250757e571"}]}

Iin the notebook I have:

 

# Kusto conncetion and database settings
from notebookutils import mssparkutils

# The Kusto cluster uri 
kustoUri = "https://****************.z2.kusto.fabric.microsoft.com"

# The access credentials for the write
accessToken = mssparkutils.credentials.getToken(kustoUri)

# The database to read the data from
database = "*******"

 

 

The notebook uses a Sandard Spark session runtime 1.2 (Spark 3.4, Delta 2.4). 

 

In the stdout log I see the following suspicious in the trace:

File ~/cluster-env/trident_env/lib/python3.10/site-packages/notebookutils/mssparkutils/credentials.py:8, in getToken(audience, name)
7 def getToken(audience, name=''):
----> 8 return creds.getToken(audience, name)
 
Anyone knows hwat could be the cause of this?
 
Regards,
Marc
 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Sperotech 

 

Try using 'kusto' instead of providing a cluster uri. This should work both when running the notebook by itself and in a pipeline. 

 

accessToken = mssparkutils.credentials.getToken('kusto') # enter 'kusto' instead of a specific cluster uri

Microsoft Spark Utilities (MSSparkUtils) for Fabric - Microsoft Fabric | Microsoft Learn

 

vjingzhanmsft_1-1729749530657.png

 

My testing result:

vjingzhanmsft_2-1729749659094.png

 

Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!

View solution in original post

9 REPLIES 9
Anonymous
Not applicable

Hi @Sperotech 

 

Try using 'kusto' instead of providing a cluster uri. This should work both when running the notebook by itself and in a pipeline. 

 

accessToken = mssparkutils.credentials.getToken('kusto') # enter 'kusto' instead of a specific cluster uri

Microsoft Spark Utilities (MSSparkUtils) for Fabric - Microsoft Fabric | Microsoft Learn

 

vjingzhanmsft_1-1729749530657.png

 

My testing result:

vjingzhanmsft_2-1729749659094.png

 

Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!

Hi @Anonymous,

 

See my post in this topic. 

Anonymous
Not applicable

Hi @Sperotech ,

 

I guess there might have been some update happening in the Fabric. The sample code in this article in Real-Time Intelligence documentation might need to be updated. Or there should be some documentations introducing the different behaviors of these codes between in notebook itself and in pipeline. Otherwise, it would mislead users. 

 

You could provide your feedbacks about official documents through the Feedback feature on that article's page. 

vjingzhanmsft_0-1729759946901.png

 

Best Regards,
Jing

FabianSchut
Super User
Super User

There's another topic with a similar issue. Please check that topic and see if a solution will be provided: https://community.fabric.microsoft.com/t5/Data-Science/Fabric-Pipeline-Cant-Query-KQL-but-Manual-Not...

FabianSchut
Super User
Super User

Hi @Sperotech,

 

Could you check the owner of both the data pipeline and the notebook? I've run across a similar problem when the owner of the notebook was removed from the workspace. You could also check whether the owner of the pipeline and notebook has access to all required items for your run.

Hi @FabianSchut ,

Both pipeline and notebook have the same owner and are in the same workspace. B.t.w. this post is a duplicate of this post (my posts were marked as spam, but that is now fixed) and similar to this post with a slightly wrong title because you can just run KQL fine as a pipeline action, but not within a notebook action.

Anonymous
Not applicable

Hi @Sperotech 

 

Sorry for the late response. I will have a test to check if I can reproduce it. May I know your Fabric data region and service version? Did you experience this failure before? Are you connecting to a free Kusto cluster or a paid one under an Azure subscription? 

 

Best Regards,
Jing
Community Support Team

Hi Jing, my region is Sweden. Pipeline, notebook and Kusto database are all within the same workspace in Fabric. I get this connection error message with both the trial and paid (F2 or F16) subscription. I also recreated the pipeline but that does make a difference.

 

Best regards,

Marc (Sperotech)

Anonymous
Not applicable

Thank you for these information. I got the same error message in my testing. I have reported this issue internally. It may take some time to receive a feedback. I will keep you updated on any progress. Thank you again. 

 

Best Regards,
Jing
Community Support Team

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.