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...