Niobium.Device.IoTHub
4.2.66
dotnet add package Niobium.Device.IoTHub --version 4.2.66
NuGet\Install-Package Niobium.Device.IoTHub -Version 4.2.66
<PackageReference Include="Niobium.Device.IoTHub" Version="4.2.66" />
<PackageVersion Include="Niobium.Device.IoTHub" Version="4.2.66" />
<PackageReference Include="Niobium.Device.IoTHub" />
paket add Niobium.Device.IoTHub --version 4.2.66
#r "nuget: Niobium.Device.IoTHub, 4.2.66"
#:package Niobium.Device.IoTHub@4.2.66
#addin nuget:?package=Niobium.Device.IoTHub&version=4.2.66
#tool nuget:?package=Niobium.Device.IoTHub&version=4.2.66
Niobium.Device.IoTHub
Niobium.Device.IoTHub provides a ready-to-use implementation of the IIoTCommander interface for Azure IoT Hub, enabling .NET applications to send commands to IoT devices using Azure's secure, scalable device messaging infrastructure.
What is this project about?
- Implements
AzureIoTHubCommander, anIIoTCommanderfor Azure IoT Hub. - Provides dependency injection modules for easy integration.
- Handles both direct method invocation and cloud-to-device messaging.
- Supports fire-and-forget and request/response command patterns.
- Integrates with the Niobium.Device abstraction for seamless device command execution.
Getting Started
1. Install the NuGet Package
Add the package to your .NET project:
dotnet add package Niobium.Device.IoTHub
2. Register Azure IoT Hub Commander in Dependency Injection
In your DI setup (e.g., Program.cs):
using Niobium.Device.IoTHub;
using Microsoft.Extensions.DependencyInjection;
var services = new ServiceCollection();
services.AddDevice();
This registers AzureIoTHubCommander as the default IIoTCommander.
3. Configure Azure IoT Hub Connection
Set the IOT_HUB_CONN configuration key to your Azure IoT Hub connection string (e.g., via environment variable or appsettings):
IOT_HUB_CONN=HostName=your-iothub.azure-devices.net;SharedAccessKeyName=service;SharedAccessKey=...
4. Execute Commands on Devices
using Niobium.Device;
public class DeviceService
{
private readonly IIoTCommander _commander;
public DeviceService(IIoTCommander commander)
{
_commander = commander;
}
public async Task<bool> TurnOnDeviceAsync(string deviceId)
{
var command = new { Action = "TurnOn" };
var result = await _commander.ExecuteAsync(deviceId, command, fireAndForget: false);
if (result != null && result.Status == 200)
{
var payload = result.GetPayload<MyDeviceResponse>();
// Use payload as needed
return true;
}
return false;
}
}
public class MyDeviceResponse
{
public string Result { get; set; }
}
5. Fire-and-Forget Commands
await _commander.ExecuteAsync("device-id", new { Action = "Ping" }, fireAndForget: true);
6. Advanced: Handling Device Offline/Retry
AzureIoTHubCommander automatically retries on transient errors and logs device offline events. You can override OnDeviceOfflineAsync for custom handling in a derived class.
7. Extending/Customizing
- You can inherit from
AzureIoTHubCommanderto customize retry logic, logging, or device offline handling. - You can register your own
IIoTCommanderimplementation if you need to support other protocols or device types.
How Niobium.Device.IoTHub is Consumed
Consumer projects use Niobium.Device.IoTHub to:
- Register and use Azure IoT Hub device command senders via DI.
- Standardize command execution and result handling for Azure-connected IoT devices.
- Rapidly prototype and deploy device integration features in business applications.
Contributing
Contributions are welcome! To contribute:
- Fork the repository
- Create a feature branch
- Make your changes with clear commit messages
- Submit a pull request
Please ensure your code follows the existing style and includes appropriate tests and documentation.
License
This project is licensed under the MIT License. See the LICENSE file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Azure.Devices (>= 1.41.1)
- Microsoft.Extensions.Azure (>= 1.14.1)
- Niobium.Device (>= 4.2.66)
- Niobium.Platform (>= 4.2.66)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.2.66 | 91 | 9/4/2026 |
| 4.0.60 | 86 | 8/30/2026 |
| 4.0.57 | 91 | 8/29/2026 |
| 4.0.53 | 96 | 8/27/2026 |
| 4.0.42 | 112 | 7/18/2026 |
| 4.0.37 | 101 | 7/17/2026 |
| 4.0.35 | 106 | 7/17/2026 |
| 4.0.34 | 100 | 7/17/2026 |
| 4.0.33 | 106 | 7/16/2026 |
| 4.0.32 | 114 | 7/2/2026 |
| 3.4.30 | 207 | 12/22/2025 |
| 3.4.29 | 305 | 11/11/2025 |
| 3.4.28 | 185 | 11/2/2025 |
| 3.4.27 | 147 | 11/1/2025 |
| 3.4.26 | 146 | 11/1/2025 |
| 3.4.25 | 150 | 11/1/2025 |
| 3.4.24 | 182 | 10/31/2025 |
| 3.2.23 | 133 | 10/18/2025 |
| 3.2.22 | 177 | 10/17/2025 |
| 3.2.21 | 168 | 10/17/2025 |