An Azure hosted internet of things (IoT) application platform.
Use a per‑device SAS key derived from an IoT Central SAS enrollment group and let the device authenticate via DPS using that key, the device ID, and the ID scope.
For a 4G LTE gateway, the key points are:
- Ensure the device is using DPS, not a raw IoT Hub connection string
- IoT Central expects devices to connect through Device Provisioning Service (DPS).
- The device must send:
- ID scope (of the IoT Central app)
- Device ID
- SAS key (or SAS token derived from that key)
- The device then receives its IoT Hub connection details from DPS and connects using those.
- Create or use a SAS enrollment group in IoT Central
- In IoT Central, use a SAS enrollment group (for example the default SAS-IoT-Devices) to manage symmetric keys.
- Each device must have a unique device ID.
- The enrollment group holds the group‑level primary/secondary keys.
- Derive a per‑device key from the group primary key
- From the SAS enrollment group, copy the group primary key.
- Use Azure CLI to compute the device key:
az extension add --name azure-iot az iot central device compute-device-key \ --primary-key <enrollment group primary key> \ --device-id <your-device-id> - Flash/store on the gateway:
- Device ID (must match what you used above)
- Device SAS key (output of the command)
- IoT Central ID scope (from Permissions > Device connection groups in IoT Central)
- Let the device generate SAS tokens from the device key
- At runtime, the gateway should generate a SAS token from the device key, not from the group key.
- The token must be valid for the DPS/Iot Hub resource and within its expiry time.
- The SDKs typically do this automatically when given the device key.
- Use the correct model ID and auto‑registration behavior
- If relying on automatic registration, the device does not need to be pre‑created in IoT Central.
- The device must:
- Use the correct ID scope and device key as above.
- Send the model ID so IoT Central can assign the device to the correct device template.
- Typical failure causes in this scenario
- Device key not derived from the correct SAS enrollment group primary key.
- Device ID on the device does not match the ID used when computing the device key.
- Using the group key directly on the device instead of a per‑device key.
- Wrong ID scope (from another IoT Central app or environment).
- SAS token expired or signed for the wrong resource.
To fix the current failure:
- In IoT Central, confirm the ID scope and group primary key from Permissions > Device connection groups > SAS-IoT-Devices.
- Recompute the device key using
az iot central device compute-device-keywith the exact device ID used by the gateway. - Update the gateway configuration with:
- ID scope
- Device ID
- Device key (not the group key)
- Ensure the device SDK is configured to use DPS with SAS and that it generates the SAS token from this device key.
If done correctly, the TLS handshake will succeed (as it already does) and SAS authentication via DPS/IoT Central should also succeed.
References: