1. First please add a test hub in your Azure account:
you need to create a IoT Hub and a Resource Group
2. Add device
3. Choose device certification method
- To Use CertifiateAuthority [Recommended]
we need to download tools to create the certificates for the device.
For the 3rd party mqtt test tool such MQTT FX, you may need to download the Root Certicate at: https://github.com/Azure/azure-iot-sdk-c/blob/master/certs/certs.c, but for the HMI PM4, we don't need it.
- To Use SAS password
we need to install VisualStudio Code Azure Extension to apply the SAS password
4. Tools
- Azure CLI
and need to install Azure IoT extension
- VSCode Azure Extension
5. Generate SAS password
To generate the device SAS passowrd, just right click the device in VSCode Azure Cli extension.
You will be asked for enter the hours of the expiration.
6. For testing the publish message
open the powershell for windows, use Azure CLI to enter the command and listen to the events:
7. For testing the subscription of topic
use VSCode Azure Extension to send "Cloud to Device" message, and see what happends on the device
8. Settings in PM4
1 = "Your Hubname".azure-devices.net
2 = "Your Device Name"
3 = "1"/"2"/?api-version=2018-06-30
Note: please remove the double quotes in above 1,2 and 3 when you input into PM4.
9. How to generate client certificate
The X.509 CA certificate is at the top of the chain of certificates for each of your devices. You may purchase or create one depending on how you intend to use it.
For production environment, we recommend that you purchase an X.509 CA certificate from a public root certificate authority. Purchasing a CA certificate has the benefit of the root CA acting as a trusted third party to vouch for the legitimacy of your devices. Consider this option if you intend your devices to be part of an open IoT network where they are expected to interact with third-party products or services.
You may also create a self-signed X.509 CA for experimentation or for use in closed IoT networks.
Regardless of how you obtain your X.509 CA certificate, make sure to keep its corresponding private key secret and protected at all times. This is necessary for trust building trust in the X.509 CA authentication.
Learn how to create a self-signed CA certificate, which you can use for experimentation throughout this feature description.