Skip to content

A C# SDK for connecting devices to Microsoft Azure IoT services

License

Notifications You must be signed in to change notification settings

jamdavi/azure-iot-sdk-csharp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Microsoft Azure IoT SDK for .NET

Contents

This repository contains the following:

  • Microsoft Azure IoT Hub device SDK for C# to connect client devices to Azure IoT Hub with .NET.
  • Microsoft Azure IoT Hub service SDK for C# to manage your IoT Hub service instance from a back-end .NET application.
  • Microsoft Azure Provisioning device SDK for C# to provision devices to Azure IoT Hub with .NET.
  • Microsoft Azure Provisioning service SDK for C# to manage your Provisioning service instance from a back-end .NET application.

Build status

Due to security considerations, build logs are not publicly available.

Service Environment Status
Master Build Status
Preview Build Status

Recommended NuGet packages

Package Name Release Version Pre-release Version
Microsoft.Azure.Devices.Client NuGet NuGet
Microsoft.Azure.Devices NuGet NuGet
Microsoft.Azure.Devices.Shared NuGet NuGet
Microsoft.Azure.Devices.Provisioning.Client NuGet NuGet
Microsoft.Azure.Devices.Provisioning.Transport.Amqp NuGet NuGet
Microsoft.Azure.Devices.Provisioning.Transport.Http NuGet NuGet
Microsoft.Azure.Devices.Provisioning.Transport.Mqtt NuGet NuGet
Microsoft.Azure.Devices.Provisioning.Service NuGet NuGet
Microsoft.Azure.Devices.Provisioning.Security.Tpm NuGet NuGet
Microsoft.Azure.Devices.DigitalTwin.Client N/A NuGet
Microsoft.Azure.Devices.DigitalTwin.Service N/A NuGet

The API reference documentation for .NET SDK is here.

To find SDKs in other languages for Azure IoT, please refer to the azure-iot-sdks repository. For IoT Hub Management SDK in .NET, please visit azure-sdk-for-net repository

Need support?

  • Have a feature request for SDKs? Please post it on User Voice to help us prioritize.
  • Have a technical question? Ask on Stack Overflow with tag “azure-iot-hub”.
  • Need Support? Every customer with an active Azure subscription has access to support with guaranteed response time. Consider submitting a ticket and get assistance from Microsoft support team.
  • Found a bug? Please help us fix it by thoroughly documenting it and filing an issue on GitHub (C, Java, .NET, Node.js, Python).

Developing applications for Azure IoT

Visit Azure IoT Dev Center to learn more about developing applications for Azure IoT.

Samples

Most of our samples are available at Azure IoT Samples for C#.

If you are looking for a good device sample to get started with, please see the device reconnection sample. It shows how to connect a device, handle disconnect events, cases to handle when making calls, and when to re-initialize the DeviceClient.

Contribute to the Azure IoT C# SDK

If you would like to build or change the SDK source code, please follow the devguide.

OS platforms and hardware compatibility

.NET Standard 1.3 (IoT Hub SDKs only) is last supported in the 2020-02-27 and in the 2020-1-31 LTS releases.

The IoT Hub device SDK for .NET can be used with a broad range of OS platforms and devices, mainly modern versions Windows and Linux.

The NuGet packages provide support for the following .NET flavors:

  • .NET Standard 2.1
  • .NET Standard 2.0
  • .NET Framework 4.7.2 (IoT Hub SDKs only)
  • .NET Framework 4.5.1 (IoT Hub SDKs only)

For details on .NET support see the .NET Standard documentation. For details on OS support see the following resources:

Key features and roadmap

IoT Hub Device SDK

✔️ feature available ✖️ feature planned but not supported ➖ no support planned

Features mqtt mqtt-ws amqp amqp-ws https Description
Authentication ✔️ ✔️* ✔️ ✔️* ✔️* Connect your device to IoT Hub securely with supported authentication, including private key, SASToken, X-509 Self Signed and X-509 CA Signed. *IoT Hub only supports X-509 CA Signed over AMQP and MQTT at the moment. X509-CA authentication over websocket and HTTPS are not supported.
Send device-to-cloud message ✔️* ✔️* ✔️ ✔️ ✔️ Send device-to-cloud messages (max 256KB) to IoT Hub with the option to add application properties and system properties, and batch send. *IoT Hub only supports batch send over AMQP and HTTPS at the moment. The MQTT implementation loops over the batch and sends each message individually.
Receive cloud-to-device messages ✔️* ✔️* ✔️ ✔️ ✔️ Receive cloud-to-device messages and read associated application and system properties from IoT Hub, with the option to complete/reject/abandon C2D messages. *IoT Hub does not support the option to reject/abandon C2D messages over MQTT at the moment.
Device Twins ✔️* ✔️* ✔️* ✔️* IoT Hub persists a device twin for each device that you connect to IoT Hub. The device can perform operations like get twin tags, subscribe to desired properties. *Send reported properties version and desired properties version are in progress.
Direct Methods ✔️ ✔️ ✔️ ✔️ IoT Hub gives you the ability to invoke direct methods on devices from the cloud. The SDK supports handler for method specific amd generic operation.
Upload file to Blob ✔️ The user can use the device client to retrieve a SAS URI from IoT Hub (to use for file uploads), upload to Azure Storage blob using IoT Hub provided credentials (using a supported client library), and then use the device client to notify IoT Hub that a file upload has completed. File upload requires HTTPS connection, but can be initiated from client using any protocol for other operations.
Connection Status and Error reporting ✔️ ✔️ ✔️ ✔️ ✔️ Error reporting for IoT Hub supported error code.
Retry policies ✔️ ✔️ ✔️ ✔️ ✔️ Retry policy for unsuccessful device-to-cloud messages have three options: no try, exponential backoff with jitter (default) and custom.
Devices multiplexing over single connection ✔️ ✔️ ✔️
Connection Pooling - Specifying number of connections ✔️ ✔️ ✔️

IoT Hub Service SDK

✔️ feature available ✖️ feature planned but not supported ➖ no support planned

Features Support Transport protocol used underneath Client to use Description
Identity registry (CRUD) ✔️ HTTP RegistryManager Use your backend app to perform CRUD operation for individual device or in bulk.
Query ✔️ HTTP RegistryManager Use your backend app to query for information on device twins, module twins, jobs and message routing.
Import/Export jobs ✔️ HTTP RegistryManager Use your backend app to import or export device identities in bulk.
Scheduled jobs ✔️ HTTP JobsClient Use your backend app to schedule jobs to update desired properties, update tags and invoke direct methods.
Cloud-to-device messaging ✔️ AMQP ServiceClient Use your backend app to send cloud-to-device messages in AMQP and AMQP-WS, and set up notifications for cloud-to-device message delivery.
Direct Methods operations ✔️ HTTP ServiceClient Use your backend app to invoke direct method on device.
File Upload Notifications ✔️ AMQP ServiceClient Use your backend app to receive file upload notifications.
IoT Hub Statistics ✔️ HTTP ServiceClient Use your backend app to get IoT hub identity registry statistics such as total device count for device statistics, and connected device count for service statistics.
Digital Twin Operations ✔️ HTTP DigitalTwinClient or RegistryManager Use your backend app to perform operations on plug and play devices. The operations include get twins, update twins and invoke commands. DigitalTwinClient is the preferred client to use.

Provisioning Device SDK

This repository contains provisioning device client SDK for the Device Provisioning Service.

✔️ feature available ✖️ feature planned but not supported ➖ no support planned

Features mqtt mqtt-ws amqp amqp-ws https Description
TPM Individual Enrollment ✔️ ✔️ ✔️ This SDK supports connecting your device to the Device Provisioning Service via individual enrollment using Trusted Platform Module. Please review the samples folder and this quickstart on how to create a device client. TPM over MQTT is currently not supported by the Device Provisioning Service.
X.509 Individual Enrollment ✔️ ✔️* ✔️ ✔️* ✔️ This SDK supports connecting your device to the Device Provisioning Service via individual enrollment using X.509 root certificate. Please review the samples and this quickstart folder on how to create a device client.
X.509 Enrollment Group ✔️ ✔️* ✔️ ✔️* ✔️ This SDK supports connecting your device to the Device Provisioning Service via individual enrollment using X.509 leaf certificate. Please review the samples folder on how to create a device client.

Note * WebSocket support for MQTT/AMQP is limited to .NET Framework 4.x.

Provisioniong Service SDK

This repository contains provisioning service client SDK for the Device Provisioning Service to programmatically enroll devices.

Feature Support Description
CRUD Operation with TPM Individual Enrollment ✔️ Programmatically manage device enrollment using TPM with the service SDK. Please visit the samples folder to learn more about this feature.
Bulk CRUD Operation with TPM Individual Enrollment ✔️ Programmatically bulk manage device enrollment using TPM with the service SDK. Please visit the samples folder to learn more about this feature.
CRUD Operation with X.509 Individual Enrollment ✔️ Programmatically manage device enrollment using X.509 individual enrollment with the service SDK. Please visit the samples folder to learn more about this feature.
CRUD Operation with X.509 Group Enrollment ✔️ Programmatically manage device enrollment using X.509 group enrollment with the service SDK. Please visit the samples folder to learn more about this feature.
Query enrollments ✔️ Programmatically query registration states with the service SDK. Please visit the samples folder to learn more about this feature.

Read more

Device Explorer is no longer supported. A replacement tool can be found here.

Certificates - Important to know

The Azure IoT Hub certificates presented during TLS negotiation shall be always validated using the appropriate root CA certificate(s).

Always prefer using the local system's Trusted Root Certificate Authority store instead of hardcoding the certificates.

A couple of examples:

Additional Information

For additional guidance and important information about certificates, please refer to this blog post from the security team.

Long-Term Support (LTS)

The project offers a Long Term Support (LTS) version to allow users that do not need the latest features to be shielded from unwanted changes.

As of August 2020, the .NET SDK is shifting to a revised Long-Term Support strategy. The primary motivations for this change are to extend the support period and decrease the churn on LTS releases, while still maintaining a strategy that offers customers choice between new features and stability.

We now will be releasing a new LTS branch yearly, and each LTS release will be supported for 3 years - 1 year of active maintenance with bugfixes, and 2 years of extended support for security fixes.

LTS branches receive all bug fixes that fall in one of these categories:

  • security bugfixes
  • critical bugfixes (crashes, memory leaks, etc.)

No new features or improvements will be picked up in an LTS branch.

LTS branches are named lts_yyyy_mm, where mm and yyyy are the month and year when the branch was created. An example of such a branch is lts_2018_01.

Schedule1

Below is a table showing the mapping of the LTS branches to the packages released.

Release Github Branch LTS Status LTS Start Date Maintenance End Date Removed Date
2020-1-31 lts_2020_01 Active 2020-01-31 2020-06-30 2020-12-31
2018-1-23 lts_2018_01 Deprecated 2018-01-23 2018-06-30 2018-12-31
  • 1 All scheduled dates are subject to change by the Azure IoT SDK team.

Planned release schedule


This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Microsoft collects performance and usage information which may be used to provide and improve Microsoft products and services and enhance your experience. To learn more, review the privacy statement.

About

A C# SDK for connecting devices to Microsoft Azure IoT services

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 98.1%
  • PowerShell 1.8%
  • Other 0.1%