IOT Hub limitation of the number of messages sent from a device

Ciavola Claudio 26 Reputation points

Hello everybody,
Is it possible to set a limitation on the number of messages sent by a device in a certain time for the IOT Hub?

the scenario is to set a policy directly in the Azure IoT Hub to automatically block devices that exceed a certain daily / monthly message quota

Thank you

Azure IoT
Azure IoT
A category of Azure services for internet of things devices.
385 questions
{count} votes

3 answers

Sort by: Most helpful
  1. chbeier 1,866 Reputation points

    This is a good example of how to throttle individual devices. By using the device twin's desired properties, the settings are cloud manageable for individual devices.

    IoT Hub itself has no option to set a limit per device. Although, in case you have a device out of control and flooding your IoT Hub with messages and causing negative impact on your other devices, you can block this device temporarily from connecting to IoT Hub by setting its status to disabled

    az iot hub device-identity update -d {device_id} -n {iothub_name} --set status=disabled  
    2 people found this answer helpful.
    0 comments No comments

  2. chbeier 1,866 Reputation points

    For the scenario you mentioned, you might implement custom logic to measure the message quota per device, see also is-there-a-way-to-retrieve-the-total-message-count.html
    You could either disable these devices temporarily or control the device's send behavior as explained in the example posted by @QuantumCache
    Controlling a device's send behavior has the big advantage that you can still interact with the device (and its user) as it stays connected. A disabled device won't be able to connect until it gets enabled again.
    Additionally, this also prevents the device from useless retries and potential traffic and costs caused by unsuccessful device to cloud communication.

    2 people found this answer helpful.

  3. QuantumCache 20,031 Reputation points

    Hello @Ciavola Claudio ,

    We don’t have that feature out of the box! as of now!

    Please have a look at this sample Temperature Sensor Module code, You may find helpful on how to control the messageCount and the delay.


    1 person found this answer helpful.
    0 comments No comments