An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
Check the document for user properties [http://docs.oasis-open.org/mqtt/mqtt/v5.0/cs02/mqtt-v5.0-cs02.html#_Toc514345337] you can use the following
import paho.mqtt.client as mqtt
import paho.mqtt.properties as props
from paho.mqtt.packettypes import PacketTypes
final_payload = '{"datetime": "2023-03-30 06:20:30", "RaR": 123, "level": 750, "id": "1234"}'
topic = "your_topic_here"
# Your MQTT client connection code here
publish_properties = props.Properties(PacketTypes.PUBLISH)
publish_properties.UserProperty = ("Content-Type", "application/json")
publish_properties.UserProperty = ("content-encoding", "UTF-8")
client.publish(topic, payload=final_payload, qos=1, properties=publish_properties)