IoT hub shared topic for all devices

Priit 0 Reputation points
2023-01-24T14:09:26.4766667+00:00

Hello,

I have a question about IoT Hub MQTT functionality.
Are there plans to add a shared topic for all devices?
For example, I would like to send a single message from the cloud to the devices (all devices that are connected to the IoT Hub) and these devices would all consume this message from a single topic.

When I have 10000 devices connected to the IoT Hub and I want to send same message to all the devices at the same time (~1 sec).

Currently I understand Direct Methods and C2D messages are all 1 to 1 communication based (devices/{device_id}/messages/devicebound/#).

Thank you.

Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
695 questions
No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Ashok Peddakotla 9,956 Reputation points Microsoft Employee
    2023-01-25T12:14:11.2366667+00:00

    Priit Welcome to Microsoft Q&A forum!

    Are there plans to add a shared topic for all devices? I would like to send a single message from the cloud to the devices (all devices that are connected to the IoT Hub) and these devices would all consume this message from a single topic.

    Azure IoT Hub does not have a shared topic for all devices. Instead, each device has its own unique topic that is used for communication.

    When I have 10000 devices connected to the IoT Hub and I want to send same message to all the devices at the same time (~1 sec).

    You can use the IoT Hub Device Twin feature to create groups of devices and then send messages to those groups. This allows you to send messages to multiple devices at once, without having to specify each individual device's topic.

    For example, you can create a group called "Group1" and add your devices to that group. Then, you can use the following REST API call to send a message to that group:

    PUT https://{iothubname}.azure-devices.net/twins/{deviceId}/methods?api-version=2018-06-30

    In the request body, you can specify the method name and the payload for the message. The payload can be any valid JSON object.

    For more details, please refer to Understand and use device twins in IoT Hub and Communicate with your IoT hub using the MQTT protocol

    Reference: Can I send a message to a group of Azure IoT Hub Devices connected via MQTT WebSocket?

    Hope this helps. Please let us know if you have any further queries.

    If this answers your query, do click Accept Answer and Yes if this answer helpful. And, if you have any further query do let us know.


  2. Sander van de Velde 15,236 Reputation points Microsoft MVP
    2023-01-25T16:00:18.0933333+00:00

    Hello @Priit ,

    If you want to send a message to multiple devices (at scale), check out the Jobs feature.

    Azure IoT Hub enables a number of building blocks like device twin properties and tags and direct methods. Typically, back-end apps enable device administrators and operators to update and interact with IoT devices in bulk and at a scheduled time. Jobs execute device twin updates and direct methods against a set of devices at a scheduled time

    You can also check out Device configuration:

    You are creating a device configuration. It configures a target set of device twins. The configuration continuously ensures that all devices that match the target condition have the specified twin settings, even when new devices are created or modified to match the target condition.

    It takes a target condition for devices (based on the device twin):

    User's image

    And updates the Device twin:

    User's image

    These screen shots are taken from the Azure Portal.


    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.