Training
Certification
Microsoft Certified: Azure Developer Associate - Certifications
Build end-to-end solutions in Microsoft Azure to create Azure Functions, implement and manage web apps, develop solutions utilizing Azure storage, and more.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Microsoft provides Azure IoT device SDKs and middleware for embedded and constrained device scenarios. This article helps device developers decide which one to use for your application.
The following diagram shows four common scenarios in which customers connect devices to Azure IoT, using a C-based (C99) SDK. The rest of this article provides more details on each scenario.
Starting in 2015, Azure IoT C SDK was the first Azure SDK created to connect devices to IoT services. It's a stable platform that was built to provide the following capabilities for connecting devices to Azure IoT:
Providing communication transport, TLS and socket abstraction has a performance cost. Many paths require malloc
and memcpy
calls between the various abstraction layers. This performance cost is small compared to a desktop or a Raspberry Pi device. Yet on a truly constrained device, the cost becomes significant overhead with the possibility of memory fragmentation. The communication transport layer also requires a doWork
function to be called at least every 100 milliseconds. These frequent calls make it harder to optimize the SDK for battery powered devices. The existence of multiple abstraction layers also makes it hard for customers to use or change to any given library.
Scenario 1 is recommended for Windows or Linux devices, which normally are less sensitive to memory usage or power consumption. However, Windows and Linux-based devices can also use the Embedded C SDK as shown in Scenario 2. Other options for windows and Linux-based devices include the other Azure IoT device SDKs: Java SDK, .NET SDK, Node SDK and Python SDK.
In 2020, Microsoft released the Azure SDK for Embedded C (also known as the Embedded C SDK). This SDK was built based on customers feedback and a growing need to support constrained micro-controller devices. Typically, constrained micro-controllers have reduced memory and processing power.
The Embedded C SDK has the following key characteristics:
The Embedded C SDK supports micro-controllers with no operating system, micro-controllers with a real-time operating system (like Eclipse ThreadX), Linux, and Windows. Customers can implement custom platform layers to use the SDK on custom devices. The SDK also provides some platform layers such as Arduino, and Swift. Microsoft encourages the community to submit other platform layers to increase the out-of-the-box supported platforms. Wind River VxWorks is an example of a platform layer submitted by the community.
The Embedded C SDK adds some programming benefits because of its flexibility compared to the Azure IoT C SDK. In particular, applications that use constrained devices will benefit from enormous resource savings and greater programmatic control. In comparison, if you use Eclipse ThreadX or FreeRTOS, you can have these same benefits along with other features per RTOS implementation.
Scenario 3 involves using Eclipse ThreadX and the Azure IoT middleware. Eclipse ThreadX is built on top of the Embedded C SDK, and adds MQTT and TLS Support. The middleware for Eclipse ThreadX exposes APIs for the application that are similar to the native Eclipse ThreadX APIs. This approach makes it simpler for developers to use the APIs and connect their Eclipse ThreadX-based devices to Azure IoT. Eclipse ThreadX is a fully integrated, efficient, real time embedded platform, that provides all the networking and IoT features you need for your solution.
Samples for several popular developer kits from ST, NXP, Renesas, and Microchip, are available. These samples work with Azure IoT Hub or Azure IoT Central, and are available as IAR Workbench or semiconductor IDE projects on GitHub.
Because it's based on the Embedded C SDK, the Azure IoT middleware for Eclipse ThreadX is non-memory allocating. Customers must allocate SDK data structures in global memory, or a heap, or a stack. After customers allocate a data structure, they must pass the address of the structure into the SDK functions to initialize and perform various operations.
Scenario 4 brings the embedded C middleware to FreeRTOS. The embedded C middleware is built on top of the Embedded C SDK and adds MQTT support via the open source coreMQTT library. This middleware for FreeRTOS operates at the MQTT level. It establishes the MQTT connection, subscribes and unsubscribes from topics, and sends and receives messages. Disconnections are handled by the customer via middleware APIs.
Customers control the TLS/TCP configuration and connection to the endpoint. This approach allows for flexibility between software or hardware implementations of either stack. No background tasks are created by the Azure IoT middleware for FreeRTOS. Messages are sent and received synchronously.
The core implementation is provided in this GitHub repository. Samples for several popular developer kits are available, including the NXP1060, STM32, and ESP32. The samples work with Azure IoT Hub, Azure IoT Central, and Azure Device Provisioning Service, and are available in this GitHub repository.
Because it's based on the Azure Embedded C SDK, the Azure IoT middleware for FreeRTOS is also non-memory allocating. Customers must allocate SDK data structures in global memory, or a heap, or a stack. After customers allocate a data structure, they must pass the address of the allocated structures into the SDK functions to initialize and perform various operations.
The following diagram summarizes technical options for each SDK usage scenario described in this article.
The following table compares the four device SDK development scenarios based on memory and protocol usage.
Memory allocation |
Memory usage |
Protocols supported |
Recommended for | |
---|---|---|---|---|
Azure IoT C SDK | Mostly Dynamic | Unrestricted. Can span to 1 MB or more in RAM. |
AMQP HTTP MQTT v3.1.1 |
Microprocessor-based systems Microsoft Windows Linux Apple OS X |
Azure SDK for Embedded C | Static only | Restricted by amount of data application allocates. |
MQTT v3.1.1 | Micro-controllers Bare-metal Implementations RTOS-based implementations |
Azure IoT Middleware for Eclipse ThreadX | Static only | Restricted | MQTT v3.1.1 | Micro-controllers RTOS-based implementations |
Azure IoT Middleware for FreeRTOS | Static only | Restricted | MQTT v3.1.1 | Micro-controllers RTOS-based implementations |
The following table compares the four device SDK development scenarios based on support for Azure IoT features.
Azure IoT C SDK | Azure SDK for Embedded C |
Azure IoT middleware for Eclipse ThreadX |
Azure IoT middleware for FreeRTOS |
|
---|---|---|---|---|
SAS Client Authentication | Yes | Yes | Yes | Yes |
x509 Client Authentication | Yes | Yes | Yes | Yes |
Device Provisioning | Yes | Yes | Yes | Yes |
Telemetry | Yes | Yes | Yes | Yes |
Cloud-to-Device Messages | Yes | Yes | Yes | Yes |
Direct Methods | Yes | Yes | Yes | Yes |
Device Twin | Yes | Yes | Yes | Yes |
IoT Plug-And-Play | Yes | Yes | Yes | Yes |
Telemetry batching (AMQP, HTTP) |
Yes | No | No | No |
Uploads to Azure Blob | Yes | No | No | No |
Automatic integration in IoT Edge hosted containers |
Yes | No | No | No |
To learn more about device development and the available SDKs for Azure IoT, see the following table.
Training
Certification
Microsoft Certified: Azure Developer Associate - Certifications
Build end-to-end solutions in Microsoft Azure to create Azure Functions, implement and manage web apps, develop solutions utilizing Azure storage, and more.