<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to use read_kafka() SQL with secret()? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-use-read-kafka-sql-with-secret/m-p/116524#M45339</link>
    <description>&lt;P&gt;I found the solution und could successfully establish a connection to Event-Hub.&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;LI-CODE lang="markup"&gt;SELECT
cast(value as STRING) as raw_json,
current_timestamp() as processing_time
FROM read_kafka(
  bootstrapServers =&amp;gt; '&amp;lt;YOUR EVENT-HUB NAMESPACE&amp;gt;.servicebus.windows.net:9093',
  subscribe =&amp;gt; '&amp;lt;YOUR TOPIC&amp;gt;',
  `kafka.sasl.mechanism` =&amp;gt; 'PLAIN',
  `kafka.security.protocol` =&amp;gt; 'SASL_SSL',
  `kafka.sasl.jaas.config` =&amp;gt; concat(
    'kafkashaded.org.apache.kafka.common.security.scram.ScramLoginModule required ', 
    'username="$ConnectionString" ', 'password="', secret('&amp;lt;SCOPE&amp;gt;','&amp;lt;KEY&amp;gt;'), '";' -- Get your Credentials from Key Vault
)
)
Limit 10&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 24 Apr 2025 21:55:06 GMT</pubDate>
    <dc:creator>rak_haq</dc:creator>
    <dc:date>2025-04-24T21:55:06Z</dc:date>
    <item>
      <title>How to use read_kafka() SQL with secret()?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-use-read-kafka-sql-with-secret/m-p/116407#M45304</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I want to read data from the Azure Event Hub using SQL.&lt;/P&gt;&lt;P&gt;Can someone please give me an executable example where you can also use the connection string from the event hub using the SQL function secret(), for example?&lt;/P&gt;&lt;P&gt;This is what i tried but it Databricks can not create a KafkaAdmin:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;SELECT&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;cast(&lt;/SPAN&gt;&lt;SPAN&gt;value&lt;/SPAN&gt; &lt;SPAN&gt;as&lt;/SPAN&gt; &lt;SPAN&gt;STRING&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt; &lt;SPAN&gt;as&lt;/SPAN&gt;&lt;SPAN&gt; raw_json&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;current_timestamp(&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt; &lt;SPAN&gt;as&lt;/SPAN&gt;&lt;SPAN&gt; processing_time&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;FROM&lt;/SPAN&gt;&lt;SPAN&gt; read_kafka(&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt; bootstrapServers &lt;/SPAN&gt;&lt;SPAN&gt;=&amp;gt;&lt;/SPAN&gt; &lt;SPAN&gt;'host:9093'&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt; subscribe &lt;/SPAN&gt;&lt;SPAN&gt;=&amp;gt;&lt;/SPAN&gt; &lt;SPAN&gt;'mytopic'&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt; `kafka.sasl.jaas.config` &lt;/SPAN&gt;&lt;SPAN&gt;=&amp;gt;&lt;/SPAN&gt; &lt;SPAN&gt;secret(&lt;/SPAN&gt;&lt;SPAN&gt;'scope'&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt; &lt;SPAN&gt;'secret'&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;LIMIT&lt;/SPAN&gt; &lt;SPAN&gt;10&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 23 Apr 2025 23:23:16 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-use-read-kafka-sql-with-secret/m-p/116407#M45304</guid>
      <dc:creator>rak_haq</dc:creator>
      <dc:date>2025-04-23T23:23:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to use read_kafka() SQL with secret()?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-use-read-kafka-sql-with-secret/m-p/116418#M45307</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/161356"&gt;@rak_haq&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here’s how you can read from an Azure Event Hub’s Kafka endpoint in Databricks SQL—using the built-in read_kafka table function and the secret() function to inject your connection string securely:&lt;/P&gt;&lt;P&gt;In summary, you must:&lt;BR /&gt;&amp;nbsp; &amp;nbsp;1.&amp;nbsp; Point bootstrapServers at your Event Hubs Kafka endpoint (&amp;lt;NAMESPACE&amp;gt;.servicebus.windows.net:9093).&lt;BR /&gt;&amp;nbsp; &amp;nbsp;2. Tell Kafka to use SASL_SSL with PLAIN and pass the full Event Hubs connection string (including EntityPath) via&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;kafka.sasl.jaas.config.&lt;BR /&gt;&amp;nbsp; &amp;nbsp;3.&amp;nbsp; Retrieve that connection string from a Databricks Secret with secret('scope','key') and wrap it correctly in the&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;JAAS login module config.&lt;BR /&gt;&amp;nbsp; &amp;nbsp;4.Include the required Kafka options (security.protocol, sasl.mechanism, sasl.jaas.config) in your read_kafka call.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Example SQL&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;SELECT&lt;BR /&gt;CAST(value AS STRING) AS raw_json,&lt;BR /&gt;current_timestamp() AS processing_time&lt;BR /&gt;FROM read_kafka(&lt;BR /&gt;bootstrapServers =&amp;gt; '&amp;lt;YOUR_NAMESPACE&amp;gt;.servicebus.windows.net:9093',&lt;BR /&gt;subscribe =&amp;gt; '&amp;lt;YOUR_EVENTHUB_NAME&amp;gt;',&lt;BR /&gt;`kafka.security.protocol`=&amp;gt; 'SASL_SSL',&lt;BR /&gt;`kafka.sasl.mechanism` =&amp;gt; 'PLAIN',&lt;BR /&gt;`kafka.sasl.jaas.config` =&amp;gt; concat(&lt;BR /&gt;'org.apache.kafka.common.security.plain.PlainLoginModule required ',&lt;BR /&gt;'username="$ConnectionString" ',&lt;BR /&gt;'password="', secret('myScope','eventHubConnection'), '";'&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;LIMIT 10;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Apr 2025 02:21:13 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-use-read-kafka-sql-with-secret/m-p/116418#M45307</guid>
      <dc:creator>lingareddy_Alva</dc:creator>
      <dc:date>2025-04-24T02:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to use read_kafka() SQL with secret()?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-use-read-kafka-sql-with-secret/m-p/116438#M45313</link>
      <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/24053"&gt;@lingareddy_Alva&lt;/a&gt;&amp;nbsp;Thank you, but already tried this and iam getten the following Error-Message:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="rak_haq_0-1745479358317.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/16214i92F9758E579D617D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="rak_haq_0-1745479358317.png" alt="rak_haq_0-1745479358317.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I read somewhere you have to use "&lt;SPAN&gt;kafkashaded.org.apache...", do u know something about?&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;A href="https://community.databricks.com/t5/data-engineering/how-to-use-sql-streaming-tables/m-p/93167#M38638" target="_self"&gt;source&lt;/A&gt;)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Apr 2025 07:25:37 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-use-read-kafka-sql-with-secret/m-p/116438#M45313</guid>
      <dc:creator>rak_haq</dc:creator>
      <dc:date>2025-04-24T07:25:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to use read_kafka() SQL with secret()?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-use-read-kafka-sql-with-secret/m-p/116524#M45339</link>
      <description>&lt;P&gt;I found the solution und could successfully establish a connection to Event-Hub.&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;LI-CODE lang="markup"&gt;SELECT
cast(value as STRING) as raw_json,
current_timestamp() as processing_time
FROM read_kafka(
  bootstrapServers =&amp;gt; '&amp;lt;YOUR EVENT-HUB NAMESPACE&amp;gt;.servicebus.windows.net:9093',
  subscribe =&amp;gt; '&amp;lt;YOUR TOPIC&amp;gt;',
  `kafka.sasl.mechanism` =&amp;gt; 'PLAIN',
  `kafka.security.protocol` =&amp;gt; 'SASL_SSL',
  `kafka.sasl.jaas.config` =&amp;gt; concat(
    'kafkashaded.org.apache.kafka.common.security.scram.ScramLoginModule required ', 
    'username="$ConnectionString" ', 'password="', secret('&amp;lt;SCOPE&amp;gt;','&amp;lt;KEY&amp;gt;'), '";' -- Get your Credentials from Key Vault
)
)
Limit 10&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 24 Apr 2025 21:55:06 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-use-read-kafka-sql-with-secret/m-p/116524#M45339</guid>
      <dc:creator>rak_haq</dc:creator>
      <dc:date>2025-04-24T21:55:06Z</dc:date>
    </item>
  </channel>
</rss>

