Benefits of using the Azure IoT SDKs, and pitfalls to avoid if you don’t

Azure IoT provides a set of open-source Software Development Kits (SDKs) to simplify and accelerate the development of IoT solutions build with Azure IoT Hub. Using the SDKs in prototyping and production enables you to:

Develop a “future-proof” solution with minimal code: While you can use protocol libraries to communicate with Azure IoT Hub, you may come back to this decision later and regret it. You will miss out on a lot of upcoming advanced features of IoT Hub and spend time redeveloping code and functionality that you could get for free. The SDKs support new features from IoT Hub, so you can incorporate them with minimal code and ensure your solution is up-to-date.
Leverage features designed for a complete software solution and focus on your specific need: The SDKs contain many libraries that address key problems and needs of IoT solutions such as security, device management, reliability, etc. You can speed up time to market by leveraging these libraries directly and focus on developing for your specific IoT scenario.
Develop with your preferred language for different platform: You can develop with C, C#, Java, Node.js, or Python without worrying about protocol specific intricacy. The SDKs provide out-of-box support for a range of platforms and the C SDK can be ported to new platforms.
Benefit from the flexibility of open source with support from Microsoft and community: The SDKs are available open source on GitHub and we work in the open. You can modify, adapt, and contribute to the code that will run your devices and your applications.

Get started with the SDKs! The rest of the blog provides more details for IoT cloud and device developers on why and how you can use the Azure IoT SDKs, as well as the recommended best practices to develop IoT solutions. Code snippets from the SDKS are shown to demonstrate concepts. Here is where you can find a comprehensive list of our SDKs.

Future proof for new IoT Hub features

Developers who prefer to use protocol libraries to develop custom solutions can use REST, AMQP and MQTT APIs exposed by IoT Hub. However, developers using these low-level protocols must deal with the intricacies of implementing complex device-to-cloud communication patterns. In addition, the IoT industry is quickly evolving past simple scenarios. Essential features like device management, security and digital twin require manipulating interfaces with a higher level of abstraction. Relying on protocol libraries means you will need to reimplement those abstractions later.

With the SDKs, your solution is future-proof with less hassle down the road. The SDKs expose simple protocol agnostic APIs for advanced features of IoT Hub so you can leverage new features with minimal code. For example, IoT Hub released a file upload feature which allows devices to upload files to the cloud. To use this feature in your solution, you only need to update the SDKs to a version that supports this feature, and make the call to IoTHubClient_UploadToBlobAsync() in your solution (API shown for C SDK). Some features come for free. Instead of implementing a retry logic for your solution, you get the industry best practice for retry logic – exponential backoff with jitter – as the default. This is much faster than writing and maintaining your own custom implementation for these advanced features.

Azure IoT Hub Device Provision Service, automates device registration and configuration. The SDKs provide a high-level interface to abstract details like transport method. It also provides a security client to group authentication mechanism and hardware modules under one common interface. Device application developers can focus on customizing first run experience, instead of spending their time on complex hardware-level security. Support for the Device Provisioning Service is available for C SDK in public preview and will be supported in other languages as well. 

Complete software solution for your needs

Regardless of the complexity of your IoT scenario, you need to develop the software on physical things or gateways to be deployed in the field, and a back-end service software for device monitoring and management. The SDKs cover both ends. In addition, they are designed as a complete software solution for device management, security, reliability, diagnostics, bandwidth savings and quality. You can dedicate your energy to developing for your specific need, instead of reimplementing these features. Here are some of the value proposition for using the SDKs in your solution.

Device management

The SDKs provide out-of-box device management infrastructure through features released by IoT Hub, including device twins and direct methods. Operations for managing device twins and invoking methods are straight forward with the SDKs taking care of the authentication, synchronization of the twin, identification of the changes for you on both the device side and the service sides.

You can develop quickly by leveraging building blocks like store and query device metadata, report and synchronize state information, invoke and handle methods to handle operations like update firmware and configuration or execute commands.

How-to guides like Get started with device twins and Use direct methods complement the open source samples describing the use of the APIs.

Security

Azure IoT provides a secure end-to-end Internet of Things platform. Secure your IoT deployment discusses IoT Hub’s security infrastructure in detail. As a developer, you can establish secure connection with devices quickly using the SDKs. IoT hub offers several secure authentication mechanisms including SAS tokens and X.509 certificates. If you choose to use security tokens, the SDKs can generate tokens without requiring any special configuration for most scenarios. If you choose to use X.509, the SDKs provide a device client that supports use of X.509 certificates and a service client to register devices that use X.509 certificate identities.

As Azure IoT continues to improve security, new support for Device Identifier Composition Engine (DICE) and different kinds of Hardware Security Modules (HSMs) was recently added (this blog provide details). The SDKs evolve with Azure IoT Hub and make security simpler and now offer a library which enables the use of different HSMs through a simple interface to DICE and Trusted Platform Module (TPM) compatible secure storages. This library makes it trivial to integrate devices in a scenario involving secure provisioning of devices at scale with the Device Provisioning Service mentioned earlier.

Reliability

The SDKs include several reliability features as well.

Retry policy for unsuccessful device-to-cloud communication is an example, addressing the problem of intermittent and non-reliable connectivity inherent to IoT devices. The SDKs offer the industry best-practice for retry policy, exponential back-off with random jitter, and the option to customize, taking into account the battery constrains of devices.

The SDKs also implement different connectivity features such as customizable keep-alives times to efficiently maintain cloud-to-device connectivity, support for connection to IoT Hub from networks behind a proxy, turning tracing on or off for the transports, etc. This document describes different connectivity features in the C SDK.

Diagnostics

In addition to providing simple APIs for IoT Hub features, the SDKs also provide diagnostics to aid debugging. The SDKs handle error reporting for error codes emitted by IoT Hub, including exceeded quotas, authentication error, throttling, device not found, etc.

Bandwidth savings

Depending on your IoT scenario, sending data too frequently may incur avoidable costs. The SDKs provide several out-of-the-box solutions for bandwidth savings. Buffering allows the device to store data when connectivity is poor instead of attempting retries. Batching reduces the number of messages transmitted by merging information from multiple messages into a single batch of messages, thus reducing network bandwidth usage. Multiplexing reduces the number of connections by having multiple devices share the same connection.

Quality

The SDKs are developed by Microsoft engineers and go through a rigorous engineering process to ensure quality. Features are covered with both unit and end-to-end tests. Prior to each bi-weekly release, the SDKs are tested with a gated build system for supported platforms to ensure no regression.

Broad language and platform support

Depending on the IoT scenario and your developer experience, you may have a preferred language or platform. The SDKs got you covered. Broad language and platform support with protocol flexibility allows you to develop in your preferred environment without worrying about protocol specific intricacy. Five languages are currently supported: C, C#, Java, Node.js, and Python. We strive to maintain consistency of APIs across the five languages, as much as language specific constructs allow.

Each language is being maintained as a public repository on GitHub, including sample code and documentation. In addition, the SDKs are available as binary packages from Nuget for C#, Maven for Java, apt-get for some Linux Distributions, npm for Node.js and pip for Python.

The SDKs are regularly tested on the following platforms (when languages apply):

Linux (Ubuntu, Debian, Raspbian)
Windows
MBED
Arduino (Huzzah, ThingDev, FeatherM0), FreeRTOS (ESP32, ESP8266)
.NETFramework 4.5, UWP, PCL (Profile 7 – UWP, Xamarin.iOS, Xamarin.Android), .NetMicroFramework, .NetStandard 1.3
Intel Edison

You can find an exhaustive list of the OS platforms the various SDKs have been tested against in the Azure Certified for IoT device catalog. If a platform is not supported, our C SDK is developed in ANSI C99 and can be ported easily following this guide.

Open Source with Support from Microsoft and community

Good open source practice and regular release

Azure IoT SDKs team follow open source best practices and work in the open. If you want to contribute back, simply create a pull request following this guideline. The engineers also monitor questions on Stack Overflow and GitHub closely to resolve any issues in a timely manner. You can track our progress through commits on the public repository.

The SDKs are developed in the master branch of their respective GitHub repositories and a new version is stamped on a bi-weekly basis and package downloaders released at the same time, which means fast turnaround for any new feature release, bug fixes and merge requests. Features supported by the SDKs and roadmap for development are published on each repo’s GitHub page, updated also on a bi-weekly basis with each release.

Long Term Support

Some developers are wary of behavioral or functional breaking changes that may affect devices in the field. The Azure IoT Hub service is a PaaS that exposes bare APIs that are versioned, guarantying continuity of behavior and function when using with a specific version of the service API. To further and complete this engagement at the client level, the SDKs offer a Long Term Support (LTS) version. LTS branches are shielded from unwanted changes. They will still receive all security bug fixes and critical bug fixes. A new LTS version will be created every 6 months with one-year lifetime.

Support plans

You are supported by Microsoft as part of your Azure subscription. Depending on the issue’s priority and severity, you can reach out to Azure Support directly via various plans.

Documentation

Documentation for various developing needs is available. Azure IoT Development Center provides a single landing page for anything developer, linking to resources such as training content, full API documentation, How-To guides. The developer guide part of the Azure documentation provides how-to tutorials to help you get started with various IoT Hub features. GitHub repositories contains instructions on how to get started from source code and feature supported in the SDKs. A list of sample applications showing how to use various IoT Hub features are also provided. You can provide feedback on documentation via GitHub issues and comments directly on the online documentation.

Best practice for using IoT Hub without the SDKs

Azure IoT SDKs are licensed under MIT license giving you all the flexibility you need for your development, with no restriction in modification and redistribution.

If you still choose or need to use a third party protocol client or your own solution, here are some guidelines to avoid security breaches and ensure reliability.

Access control and authentication with IoT Hub
IoT Hub endpoints
Choose a communication protocols
Manage device identities
Device to Cloud features guide
Cloud to Device feature guide
Send and Receive messages

Send device to cloud messages
Read device to cloud messages
Use custom endpoints and routing rules
Send cloud to device messages
IoT Hub messages construct

Understand device twins
Understand device methods
Schedule jobs on multiple devices
IoT Hub query language
Upload files from a device
Understand quotas and throttling

In addition to these, you will need to bear in mind your IoT solution specifics considering device constrains and communication limitations. What should your retry and buffering logic be to save battery and limit bandwidth usage? How and where do you securely store device credentials? How will you provision devices at scale?

Getting started with Azure IoT SDKs

Excited about using the SDKs for development? Getting started is simple. This guide provides an overview for developing with our SDKs. Navigate to the GitHub repository of your preferred language, learn about the supported features and get started with samples. You can also download the SDKs as binary packages from popular package registries and run the sample applications on your device with a few steps. For example, follow this tutorial to get started with our C SDK.
Quelle: Azure

Published by