I am referring to this article \"https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-python-get-started-send\" related to sending messages to EventHub using Python.
You may also find useful the following way, which basically do the same:
props = {"Type": "iPhone"} # properties you want to send
columns = ['body', 'properties']
values = [(write_binneddata, props)] # You can also send multiple messages adding tuples to the list
df = spark.createDataFrame(values, columns)
conn_string = f"Endpoint=sb://{event_hub_namespace}.servicebus.windows.net/;SharedAccessKeyName={shared_acc_keyname};SharedAccessKey={shared_acc_key};EntityPath={event_hub_name}"
conf = { 'eventhubs.connectionString' : conn_string }
ds = (
df
.write
.format("eventhubs")
.options(**conf)
.option("checkpointLocation", f"{checkpoint_path}")
.save()
)
PS: it needs this library installed.