Use Microsoft Azure IoT Hub
Important
This is the Azure Sphere (Legacy) documentation. Azure Sphere (Legacy) is retiring on 27 September 2027, and users must migrate to Azure Sphere (Integrated) by this time. Use the Version selector located above the TOC to view the Azure Sphere (Integrated) documentation.
An Azure Sphere application can interact with Azure IoT Hub to send and receive messages, manage a device twin, and receive direct method calls from an Azure IoT service application. To use these features, you need a Microsoft Azure subscription and an Azure IoT Hub instance.
Azure IoT Hub setup
Use of an Azure IoT Hub with an Azure Sphere device involves a multi-step authentication process:
- Download an authentication CA certificate from the Azure Sphere Security Service, which validates your Azure Sphere tenant's certificate authority.
- Upload the CA certificate to the Azure IoT Hub Device Provisioning Service (DPS) to register the device in your Azure IoT Hub instance.
- Validate the CA certificate to prove ownership of the Azure Sphere tenant. In return, receive a second certificate—the validation certificate—with which you can register your device in the IoT hub.
This process helps to:
- Safeguard against spoofing the device identity, so that an untrusted device cannot be used
- Prevent the use of compromised or untrusted Azure Sphere OS
- Ensure that only an authorized entity can register the device in an Azure IoT Hub instance
Follow the steps in Set up an IoT hub for Azure Sphere to complete the authentication process.
Important
Although it is possible to use a connection string with a device-specific shared access key to authenticate an application to the Azure IoT Hub instance, such a solution is less secure than using certificate-based authentication. Anyone who has access to the shared access key can send and receive messages on behalf of that device. To ensure the security of your devices and applications, always use the certificate-based authentication procedure that is described in this topic.
Using Azure IoT Hub
See Azure IoT sample application on GitHub for a walkthrough of Azure IoT Hub setup.
Azure IoT Hub SDK
The Azure IoT Device SDK for C includes an Azure IoT Hub client library that you can use in Azure Sphere applications.
To learn more about Azure IoT Hub
These tools can help you manage devices in Azure IoT Hub:
Iothub-explorer is a command-line tool that does the same tasks as Device Explorer but also lets you query and set information in the device twin.
Azure IoT Toolkit is a cross-platform, open-source Visual Studio Code extension that helps you manage Azure IoT Hub and devices in Visual Studio Code.
For extended IoT scenarios using other Azure services and tools, check out these tutorials: