Request size and concurrent job issues when using JobClient (.NET SDK)

Frank Hoogmans 21 Reputation points
2020-11-19T08:13:27.217+00:00

I have an Azure IoTHub (S2) environment with 4000+ devices, to which I'm trying to send the same TwinPatch to update them.
I am hitting 2 different issues when trying to achieve this update.

First
To achieve this update, I am using the Azure IoT SDK JobClient (.NET), using the following code:

JobResponse result = await this._jobClient.ScheduleTwinUpdateAsync(
                        Guid.NewGuid().ToString("D"),
                        $"DeviceId IN [{String.Join(',', deviceIds.Select(d => $"'{d}'"))}]",
                        twinPatch,
                        DateTime.UtcNow,
                        172800)

This results in the following error:

Precondition failed: {"Message":"ErrorCode:PreconditionFailed;The etag in the request does not match the etag of the existing resource, as per RFC7232, please check and try again","ExceptionMessage":"Tracking ID:26317b31a7c54068bf72889047952787-G:3-TimeStamp:11/18/2020 10:55:20"}

After some trial and error, I found that reducing the number of devices in the request to around 250 will make it succeed again. I can't seem to find any documentation on a limit within this query. Is there any limit, and if so, where is it documented?

Second
Subsequently, when splitting this job into multiple jobs, I am running into the concurrent job limit of 5 for an S2 instance (updating 4000 devices in batches of 250 takes 16 jobs). I tried scheduling every next job further in the future, and shortening the max runtime (so they don't overlap), but the 5 concurrent job limit seems to include Queued jobs. Which makes it completely impossible to use this as a primary scheduling mechanism, unless I'm missing something...

Azure IoT
Azure IoT
A category of Azure services for internet of things devices.
399 questions
Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,192 questions
Azure IoT SDK
Azure IoT SDK
An Azure software development kit that facilitates building applications that connect to Azure IoT services.
222 questions
{count} votes

Accepted answer
  1. QuantumCache 20,266 Reputation points
    2020-11-26T01:02:40.363+00:00

    Hello @Frank Hoogmans ,

    Below is the response from Microsoft's Product team, I hope this helps with your initial query.

    1. It will update 10 per seconds and next will be subjects for https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-quotas-throttling#traffic-shaping and throttling.
    2. However, it'll keep retrying throttled requests within specified job execution window. Hence, if windows is short there're chances it'll mark device job as throttled.
    3. There's a separate bucket for jobs so it does not interfere with direct twin updates.
    If you want to avoid throttling we recommend using https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-automatic-device-management


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.