Hello @Anders Nordberg Lauritsen ,
welcome to this moderated Azure community forum.
The Azure IoT Hub is a cloud gateway capable of connection large number of devices, each with their own credentials, using several protocols. Next to device-to-cloud connectivity, cloud-to-device connectivity is also offered.
The IoT Hub offers communication over MQTTs but does not implement a generic MQTT broker. Only a specific subset of topics are supported.
Although the examples are written in C#, this blog post describes all topics used and the purpose of them.
Keep in mind you need to implement the Digicert Global G2 root (public) certificate. This is used for the TLS security of the communication. Make sure your device understands this too.
Regarding the keep-alive pings, I have not come across this in the documentation. I expect this is out of scope for the IoT Hub because this is solved by the underlying MQTT broker and client connection themselves.
If you want to do plain MQTT to the cloud with free topic selection, I recommend the MQTT support of the EventGrid Namespace.
This MQTT broker supports both MQTT V3.1.1 and MQTT V5 features. including keep-alive and LWT.
If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.