IoTEdgeObjectModel 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package IoTEdgeObjectModel --version 1.0.0                
NuGet\Install-Package IoTEdgeObjectModel -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="IoTEdgeObjectModel" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add IoTEdgeObjectModel --version 1.0.0                
#r "nuget: IoTEdgeObjectModel, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install IoTEdgeObjectModel as a Cake Addin
#addin nuget:?package=IoTEdgeObjectModel&version=1.0.0

// Install IoTEdgeObjectModel as a Cake Tool
#tool nuget:?package=IoTEdgeObjectModel&version=1.0.0                

Overview

This library provides extensions methods of azure-iot-sdk to support the following scenarios:

  1. Instantiate a new deployment manifest with default EdgeAgent and EdgeHub values (e.g. create options, restart policy, et. al.).
  2. Extract IoT Edge module status (e.g. last updated time, exit code) from $EdgeAgent and $EdgeHub module twin reported properties.

Installation

The library is available via nuget.org

TBD: nuget link

How To Use

The following are samples of how to use the extension methods.

Create a new deployment manifest

You can generate desired properties for edgeAgent with default values using the following snippet:

EdgeAgentDesiredProperties edgeAgentDesiredProperties = new EdgeAgentDesiredProperties();

If you want to change some of the default values, add registry credentials or custom modules properties, you can configure as the following:

EdgeAgentDesiredProperties edgeAgentDesiredProperties = new EdgeAgentDesiredProperties()
{
    SystemModuleVersion = "1.3",
    RegistryCredentials = new List<RegistryCredential>()
    {
       new RegistryCredential("AcrAdmin", "address", "userName", "password"),
    },
    EdgeModuleSpecifications = new List<EdgeModuleSpecification>()
    {
       new EdgeModuleSpecification("custom-module-name", "image-uri"),
    },
};

You can generate desired properties for edgeHub with default values using the following snippet:

EdgeHubDesiredProperties edgeHubConfig = new EdgeHubDesiredProperties();

If you want to change some of the default values, for example the default value of StoreAndForwardTimeToLiveSecs is 7200, you can change it to 3600 by configure it as the following:

EdgeHubDesiredProperties edgeHubConfig = new EdgeHubDesiredProperties()
{
    StoreAndForwardTimeToLiveSecs = 3600,
};

Generate desired properties for custom module:

ModuleSpecificationDesiredProperties moduleSpecificationDesiredProperties = new ModuleSpecificationDesiredProperties()
{
    Name = "custom-module",
    DesiredProperty = new
    {
        dummy_a = new
        {
            dummy_b = "dummy"
        },
    }
};

Finally, setup all desired properties to ConfigurationContent

ConfigurationContent configurationContent = new ConfigurationContent()
                .SetEdgeHub(edgeHubConfig)
                .SetEdgeAgent(edgeAgentDesiredProperties)
                .SetModuleDesiredProperty(moduleSpecificationDesiredProperties);

Then the configurationContent can be appied to IoTEdge device

// apply the configurationContent through SDK.
await registryManager.ApplyConfigurationContentOnDeviceAsync({IoTEdgeId}, configurationContent).ConfigureAwait(false);

Extract IoT Edge Module Status

The reported properties from $EdgeAgent/$EdgeHub module twins can be used to examine the state of a deployment on a device.

// get $EdgeHub and $EdgeAgent module twin through SDK.
Twin edgeAgentTwin = await registryManager.GetTwinAsync(IoTEdgeId, "$edgeAgent").ConfigureAwait(false);
Twin edgeHubTwin = await registryManager.GetTwinAsync(IoTEdgeId, "$edgeHub").ConfigureAwait(false);
// get $EdgeHub and $EdgeAgent module twin through SDK.
EdgeAgentReportedProperties edgeAgentReportedProperties = edgeAgentTwin.GetEdgeAgentReportedProperties();
EdgeHubReportedProperties edgeHubReportedProperties = edgeHubTwin.GetEdgeHubReportedProperties();

Dependencies

Microsoft.Azure.Devices (>= 1.37.1)

StyleCop.Analyzers (>=1.1.118)

Azure IoT Edge: 1.1, 1.2, 1.3

References

iot-edge-object-model

Properties of the IoT Edge agent and IoT Edge hub module twins

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.1.11 136 2/28/2024
1.1.10 120 2/2/2024
1.1.9 104 2/2/2024
1.1.8 163 12/22/2023
1.1.7 698 1/16/2023
1.1.6 252 1/16/2023
1.1.5 266 12/21/2022
1.1.4 310 12/13/2022
1.1.3 336 11/11/2022
1.1.2 308 11/10/2022
1.1.1 319 11/1/2022
1.1.0 372 10/6/2022
1.0.1 380 8/23/2022
1.0.0 392 8/22/2022

1.0.0 initial release