IoTEdge.Extensions.Hosting
1.0.0-alpha
See the version list below for details.
dotnet add package IoTEdge.Extensions.Hosting --version 1.0.0-alpha
NuGet\Install-Package IoTEdge.Extensions.Hosting -Version 1.0.0-alpha
<PackageReference Include="IoTEdge.Extensions.Hosting" Version="1.0.0-alpha" />
paket add IoTEdge.Extensions.Hosting --version 1.0.0-alpha
#r "nuget: IoTEdge.Extensions.Hosting, 1.0.0-alpha"
// Install IoTEdge.Extensions.Hosting as a Cake Addin
#addin nuget:?package=IoTEdge.Extensions.Hosting&version=1.0.0-alpha&prerelease
// Install IoTEdge.Extensions.Hosting as a Cake Tool
#tool nuget:?package=IoTEdge.Extensions.Hosting&version=1.0.0-alpha&prerelease
Azure IoT Edge Extensions
This library extends Azure IoT Edge to:
- integrate with modern .NET hosting,
- implement IoT Edge recommendations for logging via the standard .NET
ILogger<T>
API, - provide an easy onboarding path to IoT Edge recommendations for Prometheus-based metrics.
Usage
Add the IoTEdge.Extensions.Hosting
NuGet package to your application.
Logging
In your Program.cs file, add a call to IHostBuilder.ConfigureIoTEdgeTelemetry()
as follows:
public static void Main(string[] args)
{
Host.CreateDefaultBuilder(args)
.ConfigureIoTEdgeTelemetry() // Add this line
.ConfigureServices(services =>
{
services.AddHostedService<MyModuleService>();
}).Build().Run();
}
This configures the .NET ILogger<T>
-based logging infrastructure to use the IoT Edge-recommended logging format. Log messages will be sent to the console (stdout) in a way that allows the GetModuleLogs
direct method to be used to retrieve logs remotely, filtering by date/time range and severity.
Metrics
To report metrics from your application, add a reference to the prometheus-net
NuGet package and then inject an instance of IModuleMetrics
into your hosted service (or wherever you need to report metrics). The methods on that interface can be used to generate Prometheus metrics instances that are preconfigured with device_id
and module_id
labels. From there, you can use the native APIs from the prometheus-net library.
using Prometheus;
public sealed class MyModuleService : IHostedService
{
private readonly ILogger<MyModuleService> logger;
private readonly IHistogram processingDuration;
public MyModuleService(
IModuleMetrics metrics, // Using constructor injection
ILogger<MyModuleService> logger)
{
this.logger = logger;
requestDuration = metrics.CreateDurationHistogram(
"mymodule_processing_duration_seconds",
"Processing duration (in seconds)");
}
// ... other logic
private Task ProcessAsync()
{
using (processingDuration.NewTimer())
{
// Do work here
}
}
}
Feedback
This is an alpha release. All feedback, bug reports, etc. are welcome! Please use the Issues tab in this repository.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Extensions.Hosting (>= 5.0.0)
- prometheus-net (>= 4.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on IoTEdge.Extensions.Hosting:
Package | Downloads |
---|---|
IoTEdge.Extensions.Licensing
Provides a licensing extension for Azure IoT Edge using the WorkSense Edge Licensing Service. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.4.0 | 500 | 6/13/2022 |
1.3.0 | 732 | 3/20/2021 |
1.2.0-alpha | 275 | 3/20/2021 |
1.0.2-alpha | 267 | 12/3/2020 |
1.0.1-alpha | 235 | 12/3/2020 |
1.0.0-alpha | 272 | 12/2/2020 |
1.0.0-alpha is the initial public release, providing the IHostBuilder.ConfigureIoTEdgeTelemetry() extension method and the IModuleMetrics interface.