Search code examples
mqttpublish-subscribeazure-iot-hubaws-iot

Azure Service to Publish and Subscribe on custom topic same as available in AWS IoT


I am working on a software, where I need to send a JSON payload to a wide range of clients. Here the client is a windows PC, where my software is running. On some event, I need to trigger some actions on the client.

To achieve this I was using AWS IoT Core, so that all of the clients are connected to there group (or can say topic at AWS IoT) by subscribe on the topic through MQTT. And I will publish the JSON payload to the topic through MQTT. So it will notify to all of the connected clients. Here the topic is custom, can set any topic. And It does not ask to create multiple devices (at AWS it is Things) at the AWS IoT. Just created a single Thing over there, exported its certificate and using the same certificate across all of the clients. Everything is working fine.

But now I want to switch at Azure. I checked the Azure IoT Hub. I created a Hub and a device in the Hub. I am able to send message to the device. But it is not possible to send messages at custom topic. The topic includes the created device id, so that it will fixed for that device. But in my scenario, I need custom and multiple topics, and I don't want to create multiple devices at Azure. Also it is not clear that the message which I sent is via MQTT protocol or not.

For POC, I am using following Azure IoT Hub REST API to send message on a device:

curl --location --request POST 'https://{AzureIoTHubNAme}.azure-devices.net/devices/{AzureIoTHubDevice}/messages/events/?api-version=2018-06-30' \
--header 'authorization: SAAS-TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
    "SOME-KEY": "SOME-VALUE"
}'

With Azure how can I achieve the same which I am using with AWS IoT? If there are any suggestions or any other Azure service which can fulfill my requirement, please help me to find out.

Thanks.


Solution

  • The Azure IoT Hub is not a generic MQTT broker. I do recommend to read the following documents:

    IoT concepts and Azure IoT Hub

    Reference - IoT Hub endpoints

    Communicate with your IoT hub using the MQTT protocol

    Update:

    From the communication point of the view, the primary focus of the Azure IoT Hub is fast ingesting a device telemetry data to the stream pipeline from millions of simultaneously connected devices in the secure reliable way.

    On the opposite communication side, such as a cloud-to-device, there is no built-in a multicasting (broadcasting) feature, so each cloud-to-device message must be handled from the device to the device individually synchronously (request-reply pattern) and/or asynchronously (queueing pattern) with some throttling limitations.

    Also, there is no built-in a device-to-device messaging, this part must be done outside of the IoT Hub.

    However, the device model has built-in a generic event driven mechanism for states represented by a device twin properties (reported and desired properties).

    Also, the Azure IoT Hub is integrated with the Azure Event Grid, see more details here.

    Basically, you can consider for your solution the following Azure services: