How to configure Apache Kafka on HDInsight to automatically create topics
By default, Apache Kafka on HDInsight doesn't enable automatic topic creation. You can enable auto topic creation for existing clusters using Apache Ambari. You can also enable auto topic creation when creating a new Kafka cluster using an Azure Resource Manager template.
Apache Ambari Web UI
To enable automatic topic creation on an existing cluster through the Ambari Web UI, use the following steps:
From the Azure portal, select your Kafka cluster.
From Cluster dashboards, select Ambari home.
When prompted, authenticate using the login (admin) credentials for the cluster. Instead, you can connect to Ambari directly from
https://CLUSTERNAME.azurehdinsight.net/
whereCLUSTERNAME
is the name of your Kafka cluster.Select the Kafka service from the list on the left of the page.
Select Configs in the middle of the page.
In the Filter field, enter a value of
auto.create
.This setting filters the list of properties and displays the
auto.create.topics.enable
setting.Change the value of
auto.create.topics.enable
totrue
, and then select Save. Add a note, and then select Save again.Select the Kafka service, select Restart, and then select Restart all affected. When prompted, select Confirm restart all.
Note
You can also set Ambari values through the Ambari REST API. This is generally more difficult, as you have to make multiple REST calls to retrieve the current configuration, modify it, etc. For more information, see the Managed HDInsight clusters using the Apache Ambari REST API document.
Resource Manager templates
When creating a Kafka cluster using an Azure Resource Manager template, you can directly set auto.create.topics.enable
by adding it in a kafka-broker
. The following JSON snippet demonstrates how to set this value to true
:
"clusterDefinition": {
"kind": "kafka",
"configurations": {
"gateway": {
"restAuthCredential.isEnabled": true,
"restAuthCredential.username": "[parameters('clusterLoginUserName')]",
"restAuthCredential.password": "[parameters('clusterLoginPassword')]"
},
"kafka-broker": {
"auto.create.topics.enable": "true"
}
}
}
Next Steps
In this document, you learned how to enable automatic topic creation for Apache Kafka on HDInsight. To learn more about working with Kafka, see the following links: