Finding the underlying IoTHub hostname of an Azure IoT Central instance
I'm trying to use an MQTT client to send device telemetry to an IoT Central instance. To do this, I think I need to know the hostname of the underlying IoTHub instance. I have a hostname of the form iotc-{a bunch of letters and numbers}.azure-devices.net, but I can't remember where I got it from or how to generate it again. I get a "connection refused: server unavailable" error when trying to connect to port 8883. I have tried both SAS and x509 certificate authentication, so either I'm getting the authentication wrong with both methods, or I'm getting the hostname wrong. Does anyone have any suggestions for retrieving the underlying IoT Hub hostname?
Solution 1:
IoT Central uses the Device Provisioning Service to handle device provisioning - this approach replaces the use of connection strings as described in the previous answer.
You can use MQTT to interact with IoT Central's DPS instance and retrieve device connection details. This article provides the information you need: https://docs.microsoft.com/azure/iot-dps/iot-dps-mqtt-support
Alternatively, you could run a separate script to generate a connection string for your device to use. For an example of the type of code the script should run, see https://github.com/Azure/azure-iot-sdk-node/blob/main/device/samples/javascript/pnp_simple_thermostat.js. In particular the provisionDevice function.