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
Broeks
Helper II
Helper II

Trident-Spark-IDE authentication with each spark job defintion run

In addition to my other topic (SparkContext not initializing when using notebooks... - Microsoft Fabric Community), where I'm trying to get notebooks in VSCode to work, I'm also trying to get spark job definitions to work in VSCode.

 

I've set-up VSCode based on the following youtube video and documentation:
https://www.youtube.com/watch?v=A9SjAyZ_JSc
https://learn.microsoft.com/en-us/fabric/data-engineering/setup-vs-code-extension
https://learn.microsoft.com/en-us/fabric/data-engineering/author-sjd-with-vs-code

 

I'm running the following code as test:

import sys
import os
#import Constant
from pyspark.sql import SparkSession
from pyspark.conf import SparkConf


if __name__ == "__main__":

  #Spark session builder
  conf = SparkConf()
  conf.set("spark.lighter.client.plugin", "org.apache.spark.lighter.DefaultLighterClientPlugin")
  conf.set("spark.sql.catalogImplementation", "lighter")
  conf.set("spark.lighter.sessionState.implementation", "org.apache.spark.sql.lighter.client.SparkLighterSessionStateBuilder")
  conf.set("spark.lighter.externalCatalog.implementation", "org.apache.spark.sql.lighter.client.ConnectCatalogClient")
  conf.set("spark.driver.host", "localhost")
  spark_session =  SparkSession.builder.config(conf=conf).getOrCreate()

  spark_context = spark_session.sparkContext
  spark_context.setLogLevel("DEBUG")
  
  #tableName = "yellowtripdata"
  # You can download the sample CSV file from this site "https://www.nyc.gov/site/tlc/about/tlc-trip-record-data.page" and upload it to the files section of the lakehouse. 
  csvFilePath = "Files/Data/dimension_customer.csv"
  #deltaTablePath = SaveToLH + "/Tables/" + tableName
  deltaTablePath = "Tables/yellowtrip"

  df = spark_session.read.format('csv').options(header='true', inferschema='true').load(csvFilePath)
  df.write.mode('overwrite').format('delta').save(deltaTablePath)

 

And I've though the code works and I'm able to run pyspark code locally there are some issues:

- In addition to the provided steps I've had to add the following to my config:

conf.set("spark.driver.host", "localhost")

 

But the real issue is, that I have to authenticate to the Trident-Spark-IDE everytime i want to run my code.

I've noticed that I needed to authenticate through the debug logging, where is says:

 

[ForkJoinPool.commonPool-worker-25] AADTokenClient: To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code XXXXXXXX to authenticate.

Broeks_0-1722632247975.png

 

After I've authenticated the code runs, but I'm not able to authenticate only once. I'm signed into my account through the Synapse VS Code extension, so that can't be the issue. How can I ensure that I remain logged in?

 

 

1 ACCEPTED SOLUTION
Broeks
Helper II
Helper II

The issues seemed to be releated to the version of the extension that I was using. It's fixed now, so upgrading the extension to 1.9.1. did the trick.

View solution in original post

2 REPLIES 2
Broeks
Helper II
Helper II

The issues seemed to be releated to the version of the extension that I was using. It's fixed now, so upgrading the extension to 1.9.1. did the trick.

Anonymous
Not applicable

Hi @Broeks ,

 

The reason you need to authenticate more than once may be because the token for authentication expires.

 

You can configure the token lifetime, as described below:

vhuijieymsft_0-1722823015332.png

 

Configure tokens - Azure Active Directory B2C | Microsoft Learn

 

If you have any other questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

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.

May FBC25 Carousel

Fabric Monthly Update - May 2025

Check out the May 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.