Currently, Databricks does not support using Managed Identities directly for Kafka client authentication (e.g., MSK IAM or Event Hubs Kafka endpoint) in Python Structured Streaming connections. However, there is a supported and secure alternative that aligns with your SFI goal of eliminating client secrets — Unity Catalog service credentials configured with a Managed Identity–based access connector.
Current State of Managed Identity for Kafka in Databricks
Managed Identity–based OAuth authentication for Kafka clients is not yet supported natively in Databricks streaming readers or writers for Kafka on AWS or Azure. As of 2025, Databricks recommends replacing traditional credential-based authentication (client secrets, certificates) with Unity Catalog service credentials that encapsulate a Managed Identity or instance profile for Kafka access.
Recommended Approach Using Unity Catalog Service Credentials
To align with your SFI directive and eliminate client secrets:
-
Create a Managed Identity and Access Connector
-
In Azure, set up an Azure Databricks access connector bound to a user-assigned managed identity.
-
Grant this managed identity access to your target service (MSK or Event Hubs).
-
Record the access connector’s Resource ID.
-
Create a Unity Catalog Service Credential
-
In Databricks, create a new service credential linked to that access connector using the Azure portal or the Databricks catalog UI.
-
Example command:
CREATE SERVICE CREDENTIAL my_kafka_sc
WITH ID '/subscriptions/<sub-id>/resourceGroups/<rg>/providers/Microsoft.Databricks/accessConnectors/<connector-name>';
-
Optionally, include your user-assigned managed identity ID.
-
Reference the Service Credential in Kafka Configuration
-
Replace the old secret-based Kafka auth block in your Spark code with:
df = (spark.readStream
.format("kafka")
.option("databricks.serviceCredential", "my_kafka_sc")
.option("kafka.bootstrap.servers", "<bootstrap-server-url>")
.option("subscribe", "<topic>")
.load())
-
When the databricks.serviceCredential option is used, you should not include SASL, JAAS, or protocol configuration parameters (kafka.sasl.mechanism, kafka.security.protocol, etc.) — Databricks manages those using the bound managed identity.
Availability and Considerations
-
This feature is available starting in Databricks Runtime 16.1 and later.
-
Works across AWS MSK and Azure Event Hubs with Managed Identity or Instance Profile.
-
Ideal for serverless or shared compute environments where secret injection is discouraged.
-
For older runtimes or environments without Unity Catalog, the only supported options remain IAM (AWS instance profile) or Entra ID client secret–based OAuth.
In Summary
If your environment is on Databricks Runtime 16.1 or higher, use Unity Catalog service credentials connected to an Azure Managed Identity to securely authenticate to Kafka (MSK/Event Hubs) without relying on a client secret. This model satisfies SFI governance by removing embedded secrets and leveraging Azure-managed tokens.