Synapse Spark Pool(spark 3.1): unable to find class: org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginCallbackHandler

Estephania Palomino Virgen 25 Reputation points Microsoft Employee
2024-04-05T01:34:29.0233333+00:00

I am trying to test Kafka Consumer to read events from Azure EventHub and load it as DataStream in python using Azure Synapse Workspace. I need to do the auth using service principal and secret, please advise me on what I might be doing wrong or if I am missing something here.

sasl_config = f'org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule required clientId="{client_id}" clientSecret="{client_secret}" scope="https://{event_hubs_server}/.default" ssl.protocol="SSL";'

kafka_options = {
    # Port 9093 is the EventHubs Kafka port
    "kafka.bootstrap.servers": f"{event_hubs_server}:9093",
    "kafka.sasl.jaas.config": sasl_config,
    "kafka.sasl.oauthbearer.token.endpoint.url": f"https://login.microsoft.com/{tenant_id}/oauth2/v2.0/token",
    "subscribe": event_hubs_topic,
    "kafka.security.protocol": "SASL_SSL",
    "kafka.sasl.mechanism": "OAUTHBEARER",
    "startingOffsets":"earliest",
    "kafka.sasl.login.callback.handler.class": "org.apache.kafka.common.security.oauthbearer.secured.OAuthBearerLoginCallbackHandler" }  

df = spark.readStream.format("kafka").options(**kafka_options).load()

Error message: Class org.apache.kafka.common.security.oauthbearer.secured.OAuthBearerLoginCallbackHandler could not be found.

Azure Event Hubs
Azure Event Hubs
An Azure real-time data ingestion service.
636 questions
Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
4,913 questions
{count} vote

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.