cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

How to publish to Azure using MQTT?

Highlighted
Amethyst

How to publish to Azure using MQTT?

I am trying to send data to Azure using MQTT. Thingworx has most of the data and right now the scope is to send a few messages to the application in Azure (Azure is an endpoint, not our data storage so I am looking for a simple solution).

 

When using the MQTT plugin available on the marketplace, I am however not able to get the MQTT thing to connect to the MQTT broker in Azure. Did anyone try this before? Azure is quite specific on how to connect (encrypted traffic only on ports 8883 or 443) and it has a specific user name and password format that contains some unconventional characters. Did anyone use this way of communicating with Azure?

 

Thanks

Best regards

Erik

2 REPLIES 2
Highlighted

Re: How to publish to Azure using MQTT?

Starting to think that this is related to the clientIdFormat setting (defaults to /Thingworx/{s}/{t}). I am not able to find any information regarding what the {s} / {t} parameters mean. Could it be that Azure wants a very specific clientID?

Highlighted

Re: How to publish to Azure using MQTT?

You may find this document helpful https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-mqtt-support:

 

  • For the ClientId field, use the deviceId.

  • For the Username field, use {iothubhostname}/{device_id}/api-version=2016-11-14, where {iothubhostname} is the full CName of the IoT hub.

    For example, if the name of your IoT hub is contoso.azure-devices.net and if the name of your device is MyDevice01, the full Username field should contain:

    contoso.azure-devices.net/MyDevice01/api-version=2016-11-14

  • For the Password field, use a SAS token. The format of the SAS token is the same as for both the HTTPS and AMQP protocols:

    SharedAccessSignature sig={signature-string}&se={expiry}&sr={URL-encoded-resourceURI}

 

 

Also TWX can connect to Azure IoT hub using ThingWorx Azure IoT Hub Connector documented here http://support.ptc.com/help/thingworx_hc/thingworx_cx_services/index.html#page/thingworx_cx_services...

Announcements

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum!