This .NET nanoFramework demonstration app acts like a client for Azure EventGrid support for MQTT.
this Visual Studio project demonstrates how to connect to the EventGrid cloud MQTT broker for:
- Connect
- Send data to a topic
- Receive data on a topic
- Last will and testament support
If everything is set up correctly and rolled out on a constrained device like an ESP32, you get a flow like this:
Read the full story in this blog post.
You need three certificates to both secure the TLS communication and to prove the identity:
- The public TLS certificated for the connection to the broker based on DigiCert Global Root G3
- Private client certificate
- Public client certificate
This new EventGrid namespace feature is now demonstrated too (you need to update your m2mqtt library if needed).
Notice the willRetain flag is set to false. That feature is not supported yet by the EventGrid namespace.
If the device connection is interrupted (eg. power is down) a message like this is shown:
An introduction to how to set up the MQTT Broker in Event Grid is seen here.
This post from Roman Kiss helped me with the client credentials.