I'm not sure if this is a good idea or a crazy one. I want to have an SD template in which my application uses a unique ID to query all the Devices in IOT Hub, and via the RegistryManager queries the IOT HUb Registry to find its own configuration.
This is working for me fine until I moved the code into IOT Edge Device and created a module. Within that module, I create RegistryManager with a policy key of read-only from the IOT hub. (I opened 443, as they say, RegistryManager uses HTTPClient). I get no exceptions, but the RegistryManager query that works outside the module fails silently within the module/docker image - no error messages just zero information returned.
Yes, this is what Device Twin is for, but to use Device Twin you have to provision each device and pass it the connection string that the module will use to communicate with the IOT Hub. I have thousands of units to deliver, with thousands of SD cards, and updating each one with a provision ID I'm sure will drive me crazy.
I will create the devices using my own code, and create a device twin for each device. However, the device when it starts will have a BootStraping Device ID, and when it finds itself (via the serial number), the Telemetry connection will use that configuration.
the query that I'm using (DeviceConfiguration.MCUSerialNumber are my fields with Digitial Twin)
UPDATE: 20230603 I'm getting closer to my bug on this. I tested the registry query I was performing on the IOT Hub Queries tab, and it works correctly. I then created a simple C# code (LINQPAD) using the same connection string, as well as the same statements, and it works correctly. Then I tested if I can do an HTTPS GET statement from my device, within the docker image, and that works too. So I narrowed it down to the query which seems to NOT work within the docker image, but does work on my desktop.
That is it, the Query returns zero records within the docker image and returns a record on the desktop.
I then update the statement to a simple "select * from devices", and THAT worked.
So it has to be the payload, and the deep link I'm using to get to the attribute that I want in the registry. Testing is continuing.