From 62d70f63953740332e1660e426942a8e14815553 Mon Sep 17 00:00:00 2001 From: timtay-microsoft Date: Wed, 22 Oct 2025 11:20:07 -0700 Subject: [PATCH 01/12] re-organize --- dotnet/Azure.Iot.Operations.sln | 48 ++++++++++++++----- .../Azure.Iot.Operations.Templates.csproj | 41 ++++++++++++++++ dotnet/templates/README.md | 38 +-------------- .../.template.config/template.json | 2 +- .../EventDrivenConnectorTemplate.csproj} | 4 +- .../LeaderElectionConfigurationProvider.cs | 0 .../MessageSchemaProvider.cs | 0 .../EventDrivenConnectorTemplate}/Program.cs | 0 .../TemplateConnectorWorker.cs | 0 .../EventDrivenConnectorTemplate/Worker.cs | 27 +++++++++++ .../appsettings.Development.json | 0 .../appsettings.json | 0 .../.template.config/template.json | 2 +- ...Templates.PollingConnectorTemplate.csproj} | 5 +- .../DatasetSampler.cs | 0 .../DatasetSamplerProvider.cs | 0 .../LeaderElectionConfigurationProvider.cs | 0 .../MessageSchemaProvider.cs | 0 .../Program.cs | 0 .../Worker.cs | 27 +++++++++++ .../appsettings.Development.json | 0 .../appsettings.json | 0 22 files changed, 138 insertions(+), 56 deletions(-) create mode 100644 dotnet/templates/Azure.Iot.Operations.Templates.csproj rename dotnet/templates/{EventDrivenTelemetryConnector => content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate}/.template.config/template.json (83%) rename dotnet/templates/{PollingTelemetryConnector/PollingTelemetryConnectorTemplate.csproj => content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate.csproj} (84%) rename dotnet/templates/{EventDrivenTelemetryConnector => content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate}/LeaderElectionConfigurationProvider.cs (100%) rename dotnet/templates/{EventDrivenTelemetryConnector => content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate}/MessageSchemaProvider.cs (100%) rename dotnet/templates/{EventDrivenTelemetryConnector => content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate}/Program.cs (100%) rename dotnet/templates/{EventDrivenTelemetryConnector => content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate}/TemplateConnectorWorker.cs (100%) create mode 100644 dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/Worker.cs rename dotnet/templates/{EventDrivenTelemetryConnector => content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate}/appsettings.Development.json (100%) rename dotnet/templates/{EventDrivenTelemetryConnector => content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate}/appsettings.json (100%) rename dotnet/templates/{PollingTelemetryConnector => content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate}/.template.config/template.json (83%) rename dotnet/templates/{EventDrivenTelemetryConnector/EventDrivenTelemetryConnector.csproj => content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate.csproj} (84%) rename dotnet/templates/{PollingTelemetryConnector => content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate}/DatasetSampler.cs (100%) rename dotnet/templates/{PollingTelemetryConnector => content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate}/DatasetSamplerProvider.cs (100%) rename dotnet/templates/{PollingTelemetryConnector => content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate}/LeaderElectionConfigurationProvider.cs (100%) rename dotnet/templates/{PollingTelemetryConnector => content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate}/MessageSchemaProvider.cs (100%) rename dotnet/templates/{PollingTelemetryConnector => content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate}/Program.cs (100%) create mode 100644 dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/Worker.cs rename dotnet/templates/{PollingTelemetryConnector => content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate}/appsettings.Development.json (100%) rename dotnet/templates/{PollingTelemetryConnector => content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate}/appsettings.json (100%) diff --git a/dotnet/Azure.Iot.Operations.sln b/dotnet/Azure.Iot.Operations.sln index 08731dcfeb..3fff869d20 100644 --- a/dotnet/Azure.Iot.Operations.sln +++ b/dotnet/Azure.Iot.Operations.sln @@ -75,8 +75,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SqlQualityAnalyzerConnector EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Connectors", "Connectors", "{78562762-96CB-4527-8EE2-43A1CE119A21}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EventDrivenTelemetryConnector", "templates\EventDrivenTelemetryConnector\EventDrivenTelemetryConnector.csproj", "{A05529AD-2D62-405A-9C2D-A122F837ECBD}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PollingRestThermostatConnector", "samples\Connectors\PollingRestThermostatConnector\PollingRestThermostatConnector.csproj", "{6D8CEBB2-C805-4B45-AAFB-418B1E558146}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleTcpServiceApp", "samples\Connectors\SampleTcpServiceApp\SampleTcpServiceApp.csproj", "{566859E0-8783-92AF-29D8-F8C23A802B45}" @@ -87,7 +85,21 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StateChangeSample", "sample EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Iot.Operations.Connector.IntegrationTests", "test\Azure.Iot.Operations.Connector.IntegrationTests\Azure.Iot.Operations.Connector.IntegrationTests.csproj", "{C527ECCE-FBE1-4FBC-9987-F94BACC904F2}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PollingTelemetryConnectorTemplate", "templates\PollingTelemetryConnector\PollingTelemetryConnectorTemplate.csproj", "{698D0245-18C6-37E9-08F6-E8EADCBA0880}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Iot.Operations.Templates", "templates\Azure.Iot.Operations.Templates.csproj", "{997B55FE-157D-4EF8-8F56-94A828C9F464}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "content", "content", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "EventDrivenTelemetryConnector", "EventDrivenTelemetryConnector", "{4117C707-7647-4CB7-9933-A00D7730664C}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PollingTelemetryConnector", "PollingTelemetryConnector", "{8826F302-A3F9-4543-90EE-27196D9179EA}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Azure.Iot.Operations.Templates.EventDrivenTelemetryConnector", "Azure.Iot.Operations.Templates.EventDrivenTelemetryConnector", "{51EB46E0-8EA4-4CEF-BA3E-A7C525AAF04D}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Azure.Iot.Operations.Templates.PollingTelemetryConnector", "Azure.Iot.Operations.Templates.PollingTelemetryConnector", "{AE5D8BA0-9763-472D-98AA-7BABE4C1EE46}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EventDrivenConnectorTemplate", "templates\content\EventDrivenConnectorTemplate\EventDrivenConnectorTemplate\EventDrivenConnectorTemplate.csproj", "{ADDAE3BF-371C-4D4C-913E-9D165F28D6F2}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Iot.Operations.Templates.PollingConnectorTemplate", "templates\content\PollingConnectorTemplate\Azure.Iot.Operations.Templates.PollingConnectorTemplate\Azure.Iot.Operations.Templates.PollingConnectorTemplate.csproj", "{2D62BB36-B1A0-4A57-9F13-EA37A6E6FD51}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -199,10 +211,6 @@ Global {C75E1DD5-0E63-43CB-A16E-6829231059C1}.Debug|Any CPU.Build.0 = Debug|Any CPU {C75E1DD5-0E63-43CB-A16E-6829231059C1}.Release|Any CPU.ActiveCfg = Release|Any CPU {C75E1DD5-0E63-43CB-A16E-6829231059C1}.Release|Any CPU.Build.0 = Release|Any CPU - {A05529AD-2D62-405A-9C2D-A122F837ECBD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A05529AD-2D62-405A-9C2D-A122F837ECBD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A05529AD-2D62-405A-9C2D-A122F837ECBD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A05529AD-2D62-405A-9C2D-A122F837ECBD}.Release|Any CPU.Build.0 = Release|Any CPU {6D8CEBB2-C805-4B45-AAFB-418B1E558146}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6D8CEBB2-C805-4B45-AAFB-418B1E558146}.Debug|Any CPU.Build.0 = Debug|Any CPU {6D8CEBB2-C805-4B45-AAFB-418B1E558146}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -223,10 +231,18 @@ Global {C527ECCE-FBE1-4FBC-9987-F94BACC904F2}.Debug|Any CPU.Build.0 = Debug|Any CPU {C527ECCE-FBE1-4FBC-9987-F94BACC904F2}.Release|Any CPU.ActiveCfg = Release|Any CPU {C527ECCE-FBE1-4FBC-9987-F94BACC904F2}.Release|Any CPU.Build.0 = Release|Any CPU - {698D0245-18C6-37E9-08F6-E8EADCBA0880}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {698D0245-18C6-37E9-08F6-E8EADCBA0880}.Debug|Any CPU.Build.0 = Debug|Any CPU - {698D0245-18C6-37E9-08F6-E8EADCBA0880}.Release|Any CPU.ActiveCfg = Release|Any CPU - {698D0245-18C6-37E9-08F6-E8EADCBA0880}.Release|Any CPU.Build.0 = Release|Any CPU + {997B55FE-157D-4EF8-8F56-94A828C9F464}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {997B55FE-157D-4EF8-8F56-94A828C9F464}.Debug|Any CPU.Build.0 = Debug|Any CPU + {997B55FE-157D-4EF8-8F56-94A828C9F464}.Release|Any CPU.ActiveCfg = Release|Any CPU + {997B55FE-157D-4EF8-8F56-94A828C9F464}.Release|Any CPU.Build.0 = Release|Any CPU + {ADDAE3BF-371C-4D4C-913E-9D165F28D6F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ADDAE3BF-371C-4D4C-913E-9D165F28D6F2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ADDAE3BF-371C-4D4C-913E-9D165F28D6F2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ADDAE3BF-371C-4D4C-913E-9D165F28D6F2}.Release|Any CPU.Build.0 = Release|Any CPU + {2D62BB36-B1A0-4A57-9F13-EA37A6E6FD51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2D62BB36-B1A0-4A57-9F13-EA37A6E6FD51}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2D62BB36-B1A0-4A57-9F13-EA37A6E6FD51}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2D62BB36-B1A0-4A57-9F13-EA37A6E6FD51}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -263,13 +279,19 @@ Global {99113A50-9774-4F42-B18D-5284639194A6} = {CE9A7664-594B-43EB-AA48-606B88411FC9} {C75E1DD5-0E63-43CB-A16E-6829231059C1} = {78562762-96CB-4527-8EE2-43A1CE119A21} {78562762-96CB-4527-8EE2-43A1CE119A21} = {9126F576-80AE-48DC-8A84-EFC8B487D809} - {A05529AD-2D62-405A-9C2D-A122F837ECBD} = {4636D1F8-ACA6-4138-8EC0-1FF71CAF3A3B} {6D8CEBB2-C805-4B45-AAFB-418B1E558146} = {78562762-96CB-4527-8EE2-43A1CE119A21} {566859E0-8783-92AF-29D8-F8C23A802B45} = {78562762-96CB-4527-8EE2-43A1CE119A21} {E97EAFE6-F4D8-4B9A-B53C-8A479A9BBFB5} = {78562762-96CB-4527-8EE2-43A1CE119A21} {4992415C-ABB2-2284-D6CD-8FE01910092F} = {4DDB0B28-1830-4B6F-8A10-FB37874D4D57} {C527ECCE-FBE1-4FBC-9987-F94BACC904F2} = {CE9A7664-594B-43EB-AA48-606B88411FC9} - {698D0245-18C6-37E9-08F6-E8EADCBA0880} = {4636D1F8-ACA6-4138-8EC0-1FF71CAF3A3B} + {997B55FE-157D-4EF8-8F56-94A828C9F464} = {4636D1F8-ACA6-4138-8EC0-1FF71CAF3A3B} + {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} = {4636D1F8-ACA6-4138-8EC0-1FF71CAF3A3B} + {4117C707-7647-4CB7-9933-A00D7730664C} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} + {8826F302-A3F9-4543-90EE-27196D9179EA} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} + {51EB46E0-8EA4-4CEF-BA3E-A7C525AAF04D} = {4117C707-7647-4CB7-9933-A00D7730664C} + {AE5D8BA0-9763-472D-98AA-7BABE4C1EE46} = {8826F302-A3F9-4543-90EE-27196D9179EA} + {ADDAE3BF-371C-4D4C-913E-9D165F28D6F2} = {51EB46E0-8EA4-4CEF-BA3E-A7C525AAF04D} + {2D62BB36-B1A0-4A57-9F13-EA37A6E6FD51} = {AE5D8BA0-9763-472D-98AA-7BABE4C1EE46} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {F2687BCD-45E3-4094-9656-BF183C816BA0} diff --git a/dotnet/templates/Azure.Iot.Operations.Templates.csproj b/dotnet/templates/Azure.Iot.Operations.Templates.csproj new file mode 100644 index 0000000000..fc1c743c4f --- /dev/null +++ b/dotnet/templates/Azure.Iot.Operations.Templates.csproj @@ -0,0 +1,41 @@ + + + + + + Azure.Iot.Operations.Templates + 0.1 + Azure IoT Operations Templates + Microsoft + .NET project templates for creating Azure IoT Operations solutions + https://github.com/Azure/iot-operations-sdks + + + Template + net9.0 + true + false + content + $(NoWarn);NU5128 + true + README.md + + + + false + + + + + + + + + + + + + + + + diff --git a/dotnet/templates/README.md b/dotnet/templates/README.md index 38ae9361ea..93d46c8c99 100644 --- a/dotnet/templates/README.md +++ b/dotnet/templates/README.md @@ -1,36 +1,2 @@ -# Azure IoT Operation .NET Project Templates - -This folder contains .NET project tempate definitions that are useful when developing -applications for your Azure IoT Operations environment. - -## How To Install A .NET Project Template - -To install a project template, simply navigate to the directory of the template you want to install and run the command: - -```bash -dotnet new install . -``` - -## How To Create A New Project With An Installed Project Template - -You can use this locally installed project template when creating a new project in Visual Studio: - -`File -> New Project -> Select the installed project template` - -Alternatively, you can create a new project from an installed template from command line: - -```bash -dotnet new aiopollingtelemetryconnector -n MyConnectorApp -``` - -Where "aiopollingtelemetryconnector" is the short name defined in the project template's [template.json file](./PollingTelemetryConnector/.template.config/template.json) and where "MyConnectorApp" is the name of your project. - -Note that this command will create the project "MyConnectorApp" in the same directory that the command was run from. - -## How To Uninstall A .NET Project Template - -Navigate to the directory with the project template to uninstall and run the command: - -```bash -dotnet new uninstall . -``` + diff --git a/dotnet/templates/EventDrivenTelemetryConnector/.template.config/template.json b/dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/.template.config/template.json similarity index 83% rename from dotnet/templates/EventDrivenTelemetryConnector/.template.config/template.json rename to dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/.template.config/template.json index 70d6b54c9a..997081d551 100644 --- a/dotnet/templates/EventDrivenTelemetryConnector/.template.config/template.json +++ b/dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/.template.config/template.json @@ -2,7 +2,7 @@ "$schema": "http://json.schemastore.org/template", "author": "timtay-microsoft", "classifications": [ "Linux", "Windows", "Service"], - "identity": "AzureIotOperations.EventDrivenTelemetryConnector", + "identity": "Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate", "name": "Azure IoT Operations Event Driven Telemetry Connector", "shortName": "aioeventdriventelemetryconnector", "sourceName":"EventDrivenTelemetryConnector", diff --git a/dotnet/templates/PollingTelemetryConnector/PollingTelemetryConnectorTemplate.csproj b/dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate.csproj similarity index 84% rename from dotnet/templates/PollingTelemetryConnector/PollingTelemetryConnectorTemplate.csproj rename to dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate.csproj index 96bb591866..65119de126 100644 --- a/dotnet/templates/PollingTelemetryConnector/PollingTelemetryConnectorTemplate.csproj +++ b/dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate.csproj @@ -1,4 +1,4 @@ - + net9.0 @@ -9,6 +9,6 @@ - + diff --git a/dotnet/templates/EventDrivenTelemetryConnector/LeaderElectionConfigurationProvider.cs b/dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/LeaderElectionConfigurationProvider.cs similarity index 100% rename from dotnet/templates/EventDrivenTelemetryConnector/LeaderElectionConfigurationProvider.cs rename to dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/LeaderElectionConfigurationProvider.cs diff --git a/dotnet/templates/EventDrivenTelemetryConnector/MessageSchemaProvider.cs b/dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/MessageSchemaProvider.cs similarity index 100% rename from dotnet/templates/EventDrivenTelemetryConnector/MessageSchemaProvider.cs rename to dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/MessageSchemaProvider.cs diff --git a/dotnet/templates/EventDrivenTelemetryConnector/Program.cs b/dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/Program.cs similarity index 100% rename from dotnet/templates/EventDrivenTelemetryConnector/Program.cs rename to dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/Program.cs diff --git a/dotnet/templates/EventDrivenTelemetryConnector/TemplateConnectorWorker.cs b/dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/TemplateConnectorWorker.cs similarity index 100% rename from dotnet/templates/EventDrivenTelemetryConnector/TemplateConnectorWorker.cs rename to dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/TemplateConnectorWorker.cs diff --git a/dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/Worker.cs b/dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/Worker.cs new file mode 100644 index 0000000000..e140dc4403 --- /dev/null +++ b/dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/Worker.cs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +namespace EventDrivenConnectorTemplate +{ + public class Worker : BackgroundService + { + private readonly ILogger _logger; + + public Worker(ILogger logger) + { + _logger = logger; + } + + protected override async Task ExecuteAsync(CancellationToken stoppingToken) + { + while (!stoppingToken.IsCancellationRequested) + { + if (_logger.IsEnabled(LogLevel.Information)) + { + _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now); + } + await Task.Delay(1000, stoppingToken); + } + } + } +} diff --git a/dotnet/templates/EventDrivenTelemetryConnector/appsettings.Development.json b/dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/appsettings.Development.json similarity index 100% rename from dotnet/templates/EventDrivenTelemetryConnector/appsettings.Development.json rename to dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/appsettings.Development.json diff --git a/dotnet/templates/EventDrivenTelemetryConnector/appsettings.json b/dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/appsettings.json similarity index 100% rename from dotnet/templates/EventDrivenTelemetryConnector/appsettings.json rename to dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/appsettings.json diff --git a/dotnet/templates/PollingTelemetryConnector/.template.config/template.json b/dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/.template.config/template.json similarity index 83% rename from dotnet/templates/PollingTelemetryConnector/.template.config/template.json rename to dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/.template.config/template.json index 2fa8beb702..0408c72e8d 100644 --- a/dotnet/templates/PollingTelemetryConnector/.template.config/template.json +++ b/dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/.template.config/template.json @@ -2,7 +2,7 @@ "$schema": "http://json.schemastore.org/template", "author": "timtay-microsoft", "classifications": [ "Linux", "Windows", "Service"], - "identity": "AzureIotOperations.PollingTelemetryConnector", + "identity": "Azure.Iot.Operations.Templates.PollingConnectorTemplate", "name": "Azure IoT Operations Polling Telemetry Connector", "shortName": "aiopollingtelemetryconnector", "sourceName":"PollingTelemetryConnectorTemplate", diff --git a/dotnet/templates/EventDrivenTelemetryConnector/EventDrivenTelemetryConnector.csproj b/dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate.csproj similarity index 84% rename from dotnet/templates/EventDrivenTelemetryConnector/EventDrivenTelemetryConnector.csproj rename to dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate.csproj index 4c4720298f..65119de126 100644 --- a/dotnet/templates/EventDrivenTelemetryConnector/EventDrivenTelemetryConnector.csproj +++ b/dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate.csproj @@ -1,4 +1,4 @@ - + net9.0 @@ -9,7 +9,6 @@ - + - diff --git a/dotnet/templates/PollingTelemetryConnector/DatasetSampler.cs b/dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/DatasetSampler.cs similarity index 100% rename from dotnet/templates/PollingTelemetryConnector/DatasetSampler.cs rename to dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/DatasetSampler.cs diff --git a/dotnet/templates/PollingTelemetryConnector/DatasetSamplerProvider.cs b/dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/DatasetSamplerProvider.cs similarity index 100% rename from dotnet/templates/PollingTelemetryConnector/DatasetSamplerProvider.cs rename to dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/DatasetSamplerProvider.cs diff --git a/dotnet/templates/PollingTelemetryConnector/LeaderElectionConfigurationProvider.cs b/dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/LeaderElectionConfigurationProvider.cs similarity index 100% rename from dotnet/templates/PollingTelemetryConnector/LeaderElectionConfigurationProvider.cs rename to dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/LeaderElectionConfigurationProvider.cs diff --git a/dotnet/templates/PollingTelemetryConnector/MessageSchemaProvider.cs b/dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/MessageSchemaProvider.cs similarity index 100% rename from dotnet/templates/PollingTelemetryConnector/MessageSchemaProvider.cs rename to dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/MessageSchemaProvider.cs diff --git a/dotnet/templates/PollingTelemetryConnector/Program.cs b/dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/Program.cs similarity index 100% rename from dotnet/templates/PollingTelemetryConnector/Program.cs rename to dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/Program.cs diff --git a/dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/Worker.cs b/dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/Worker.cs new file mode 100644 index 0000000000..80e2283560 --- /dev/null +++ b/dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/Worker.cs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +namespace Azure.Iot.Operations.Templates.PollingConnectorTemplate +{ + public class Worker : BackgroundService + { + private readonly ILogger _logger; + + public Worker(ILogger logger) + { + _logger = logger; + } + + protected override async Task ExecuteAsync(CancellationToken stoppingToken) + { + while (!stoppingToken.IsCancellationRequested) + { + if (_logger.IsEnabled(LogLevel.Information)) + { + _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now); + } + await Task.Delay(1000, stoppingToken); + } + } + } +} diff --git a/dotnet/templates/PollingTelemetryConnector/appsettings.Development.json b/dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/appsettings.Development.json similarity index 100% rename from dotnet/templates/PollingTelemetryConnector/appsettings.Development.json rename to dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/appsettings.Development.json diff --git a/dotnet/templates/PollingTelemetryConnector/appsettings.json b/dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/appsettings.json similarity index 100% rename from dotnet/templates/PollingTelemetryConnector/appsettings.json rename to dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/appsettings.json From aad88e87d546860820ed139fb66c9a7a3af4ae46 Mon Sep 17 00:00:00 2001 From: timtay-microsoft Date: Wed, 22 Oct 2025 11:46:18 -0700 Subject: [PATCH 02/12] Fix pathing + readme --- dotnet/Azure.Iot.Operations.sln | 2 +- dotnet/templates/Azure.Iot.Operations.Templates.csproj | 4 +--- dotnet/templates/README.md | 10 ++++++++-- .../.template.config/template.json | 0 ...ions.Templates.EventDrivenConnectorTemplate.csproj} | 0 .../LeaderElectionConfigurationProvider.cs | 0 .../MessageSchemaProvider.cs | 0 .../Program.cs | 0 .../TemplateConnectorWorker.cs | 0 .../Worker.cs | 0 .../appsettings.Development.json | 0 .../appsettings.json | 0 12 files changed, 10 insertions(+), 6 deletions(-) rename dotnet/templates/content/EventDrivenConnectorTemplate/{EventDrivenConnectorTemplate => Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate}/.template.config/template.json (100%) rename dotnet/templates/content/EventDrivenConnectorTemplate/{EventDrivenConnectorTemplate/EventDrivenConnectorTemplate.csproj => Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate.csproj} (100%) rename dotnet/templates/content/EventDrivenConnectorTemplate/{EventDrivenConnectorTemplate => Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate}/LeaderElectionConfigurationProvider.cs (100%) rename dotnet/templates/content/EventDrivenConnectorTemplate/{EventDrivenConnectorTemplate => Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate}/MessageSchemaProvider.cs (100%) rename dotnet/templates/content/EventDrivenConnectorTemplate/{EventDrivenConnectorTemplate => Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate}/Program.cs (100%) rename dotnet/templates/content/EventDrivenConnectorTemplate/{EventDrivenConnectorTemplate => Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate}/TemplateConnectorWorker.cs (100%) rename dotnet/templates/content/EventDrivenConnectorTemplate/{EventDrivenConnectorTemplate => Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate}/Worker.cs (100%) rename dotnet/templates/content/EventDrivenConnectorTemplate/{EventDrivenConnectorTemplate => Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate}/appsettings.Development.json (100%) rename dotnet/templates/content/EventDrivenConnectorTemplate/{EventDrivenConnectorTemplate => Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate}/appsettings.json (100%) diff --git a/dotnet/Azure.Iot.Operations.sln b/dotnet/Azure.Iot.Operations.sln index 3fff869d20..313cc48297 100644 --- a/dotnet/Azure.Iot.Operations.sln +++ b/dotnet/Azure.Iot.Operations.sln @@ -97,7 +97,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Azure.Iot.Operations.Templa EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Azure.Iot.Operations.Templates.PollingTelemetryConnector", "Azure.Iot.Operations.Templates.PollingTelemetryConnector", "{AE5D8BA0-9763-472D-98AA-7BABE4C1EE46}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EventDrivenConnectorTemplate", "templates\content\EventDrivenConnectorTemplate\EventDrivenConnectorTemplate\EventDrivenConnectorTemplate.csproj", "{ADDAE3BF-371C-4D4C-913E-9D165F28D6F2}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate", "templates\content\EventDrivenConnectorTemplate\Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate\Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate.csproj", "{ADDAE3BF-371C-4D4C-913E-9D165F28D6F2}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Iot.Operations.Templates.PollingConnectorTemplate", "templates\content\PollingConnectorTemplate\Azure.Iot.Operations.Templates.PollingConnectorTemplate\Azure.Iot.Operations.Templates.PollingConnectorTemplate.csproj", "{2D62BB36-B1A0-4A57-9F13-EA37A6E6FD51}" EndProject diff --git a/dotnet/templates/Azure.Iot.Operations.Templates.csproj b/dotnet/templates/Azure.Iot.Operations.Templates.csproj index fc1c743c4f..124bb39dd8 100644 --- a/dotnet/templates/Azure.Iot.Operations.Templates.csproj +++ b/dotnet/templates/Azure.Iot.Operations.Templates.csproj @@ -1,10 +1,8 @@ - - Azure.Iot.Operations.Templates - 0.1 + 0.1.0 Azure IoT Operations Templates Microsoft .NET project templates for creating Azure IoT Operations solutions diff --git a/dotnet/templates/README.md b/dotnet/templates/README.md index 93d46c8c99..26844b7568 100644 --- a/dotnet/templates/README.md +++ b/dotnet/templates/README.md @@ -1,2 +1,8 @@ - +# Azure IoT Operations .NET Project Templates + +This package contains the following project templates to help you develop Azure IoT Operations solutions: + + - Azure.Iot.Operations.Templates.PollingConnectorTemplate + - A template for creating an AIO connector that polls an endpoint and forwards that polled telemetry to the AIO MQTT broker. + - Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate + - A template for creating an AIO connector that listens for events from an endpoint and forwards those events the AIO MQTT broker as telemetry. \ No newline at end of file diff --git a/dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/.template.config/template.json b/dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/.template.config/template.json similarity index 100% rename from dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/.template.config/template.json rename to dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/.template.config/template.json diff --git a/dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate.csproj b/dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate.csproj similarity index 100% rename from dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate.csproj rename to dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate.csproj diff --git a/dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/LeaderElectionConfigurationProvider.cs b/dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/LeaderElectionConfigurationProvider.cs similarity index 100% rename from dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/LeaderElectionConfigurationProvider.cs rename to dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/LeaderElectionConfigurationProvider.cs diff --git a/dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/MessageSchemaProvider.cs b/dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/MessageSchemaProvider.cs similarity index 100% rename from dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/MessageSchemaProvider.cs rename to dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/MessageSchemaProvider.cs diff --git a/dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/Program.cs b/dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/Program.cs similarity index 100% rename from dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/Program.cs rename to dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/Program.cs diff --git a/dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/TemplateConnectorWorker.cs b/dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/TemplateConnectorWorker.cs similarity index 100% rename from dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/TemplateConnectorWorker.cs rename to dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/TemplateConnectorWorker.cs diff --git a/dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/Worker.cs b/dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/Worker.cs similarity index 100% rename from dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/Worker.cs rename to dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/Worker.cs diff --git a/dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/appsettings.Development.json b/dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/appsettings.Development.json similarity index 100% rename from dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/appsettings.Development.json rename to dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/appsettings.Development.json diff --git a/dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/appsettings.json b/dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/appsettings.json similarity index 100% rename from dotnet/templates/content/EventDrivenConnectorTemplate/EventDrivenConnectorTemplate/appsettings.json rename to dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/appsettings.json From 85cc6771f5994726ea35e0134cf726938699194d Mon Sep 17 00:00:00 2001 From: timtay-microsoft Date: Wed, 22 Oct 2025 11:48:50 -0700 Subject: [PATCH 03/12] more --- dotnet/templates/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dotnet/templates/README.md b/dotnet/templates/README.md index 26844b7568..87bf74e113 100644 --- a/dotnet/templates/README.md +++ b/dotnet/templates/README.md @@ -5,4 +5,7 @@ This package contains the following project templates to help you develop Azure - Azure.Iot.Operations.Templates.PollingConnectorTemplate - A template for creating an AIO connector that polls an endpoint and forwards that polled telemetry to the AIO MQTT broker. - Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate - - A template for creating an AIO connector that listens for events from an endpoint and forwards those events the AIO MQTT broker as telemetry. \ No newline at end of file + - A template for creating an AIO connector that listens for events from an endpoint and forwards those events the AIO MQTT broker as telemetry. + + +For examples on how to fill out these templates, see the completed samples [here](https://github.com/Azure/iot-operations-sdks/tree/main/dotnet/samples) \ No newline at end of file From ac3c1b992bc08373cc17711db78720ed223cf62a Mon Sep 17 00:00:00 2001 From: timtay-microsoft Date: Wed, 22 Oct 2025 11:49:33 -0700 Subject: [PATCH 04/12] more --- dotnet/templates/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dotnet/templates/README.md b/dotnet/templates/README.md index 87bf74e113..157b678754 100644 --- a/dotnet/templates/README.md +++ b/dotnet/templates/README.md @@ -8,4 +8,6 @@ This package contains the following project templates to help you develop Azure - A template for creating an AIO connector that listens for events from an endpoint and forwards those events the AIO MQTT broker as telemetry. -For examples on how to fill out these templates, see the completed samples [here](https://github.com/Azure/iot-operations-sdks/tree/main/dotnet/samples) \ No newline at end of file +For examples on how to fill out these templates, see the completed samples [here](https://github.com/Azure/iot-operations-sdks/tree/main/dotnet/samples). + +If you have any questions or need any support, please file an issue [here](https://github.com/Azure/iot-operations-sdks/issues) \ No newline at end of file From 0c760111e3cd257fd044b969ec68c34a6456aabd Mon Sep 17 00:00:00 2001 From: timtay-microsoft Date: Wed, 22 Oct 2025 11:50:46 -0700 Subject: [PATCH 05/12] package tags --- dotnet/templates/Azure.Iot.Operations.Templates.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dotnet/templates/Azure.Iot.Operations.Templates.csproj b/dotnet/templates/Azure.Iot.Operations.Templates.csproj index 124bb39dd8..6c06117e89 100644 --- a/dotnet/templates/Azure.Iot.Operations.Templates.csproj +++ b/dotnet/templates/Azure.Iot.Operations.Templates.csproj @@ -1,4 +1,4 @@ - + Azure.Iot.Operations.Templates @@ -6,9 +6,9 @@ Azure IoT Operations Templates Microsoft .NET project templates for creating Azure IoT Operations solutions + azure;iot;sdk;edge https://github.com/Azure/iot-operations-sdks - Template net9.0 true From baea7fec4143e596d4682e1e0f8cef97ddd2cf64 Mon Sep 17 00:00:00 2001 From: timtay-microsoft Date: Wed, 22 Oct 2025 11:53:18 -0700 Subject: [PATCH 06/12] shorten paths --- dotnet/Azure.Iot.Operations.sln | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/dotnet/Azure.Iot.Operations.sln b/dotnet/Azure.Iot.Operations.sln index 313cc48297..2465eb14ac 100644 --- a/dotnet/Azure.Iot.Operations.sln +++ b/dotnet/Azure.Iot.Operations.sln @@ -93,10 +93,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "EventDrivenTelemetryConnect EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PollingTelemetryConnector", "PollingTelemetryConnector", "{8826F302-A3F9-4543-90EE-27196D9179EA}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Azure.Iot.Operations.Templates.EventDrivenTelemetryConnector", "Azure.Iot.Operations.Templates.EventDrivenTelemetryConnector", "{51EB46E0-8EA4-4CEF-BA3E-A7C525AAF04D}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Azure.Iot.Operations.Templates.PollingTelemetryConnector", "Azure.Iot.Operations.Templates.PollingTelemetryConnector", "{AE5D8BA0-9763-472D-98AA-7BABE4C1EE46}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate", "templates\content\EventDrivenConnectorTemplate\Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate\Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate.csproj", "{ADDAE3BF-371C-4D4C-913E-9D165F28D6F2}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Iot.Operations.Templates.PollingConnectorTemplate", "templates\content\PollingConnectorTemplate\Azure.Iot.Operations.Templates.PollingConnectorTemplate\Azure.Iot.Operations.Templates.PollingConnectorTemplate.csproj", "{2D62BB36-B1A0-4A57-9F13-EA37A6E6FD51}" @@ -288,10 +284,8 @@ Global {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} = {4636D1F8-ACA6-4138-8EC0-1FF71CAF3A3B} {4117C707-7647-4CB7-9933-A00D7730664C} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} {8826F302-A3F9-4543-90EE-27196D9179EA} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} - {51EB46E0-8EA4-4CEF-BA3E-A7C525AAF04D} = {4117C707-7647-4CB7-9933-A00D7730664C} - {AE5D8BA0-9763-472D-98AA-7BABE4C1EE46} = {8826F302-A3F9-4543-90EE-27196D9179EA} - {ADDAE3BF-371C-4D4C-913E-9D165F28D6F2} = {51EB46E0-8EA4-4CEF-BA3E-A7C525AAF04D} - {2D62BB36-B1A0-4A57-9F13-EA37A6E6FD51} = {AE5D8BA0-9763-472D-98AA-7BABE4C1EE46} + {ADDAE3BF-371C-4D4C-913E-9D165F28D6F2} = {4117C707-7647-4CB7-9933-A00D7730664C} + {2D62BB36-B1A0-4A57-9F13-EA37A6E6FD51} = {8826F302-A3F9-4543-90EE-27196D9179EA} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {F2687BCD-45E3-4094-9656-BF183C816BA0} From e20a9ac1ccdb2698ec8f82a62a7c55d3a00e19bd Mon Sep 17 00:00:00 2001 From: timtay-microsoft Date: Wed, 22 Oct 2025 12:02:01 -0700 Subject: [PATCH 07/12] fix path? --- dotnet/Azure.Iot.Operations.sln | 4 ++-- .../.template.config/template.json | 0 ...t.Operations.Templates.EventDrivenConnectorTemplate.csproj | 0 .../LeaderElectionConfigurationProvider.cs | 0 .../MessageSchemaProvider.cs | 0 .../Program.cs | 0 .../TemplateConnectorWorker.cs | 0 .../Worker.cs | 0 .../appsettings.Development.json | 0 .../appsettings.json | 0 .../.template.config/template.json | 0 ...e.Iot.Operations.Templates.PollingConnectorTemplate.csproj | 0 .../DatasetSampler.cs | 0 .../DatasetSamplerProvider.cs | 0 .../LeaderElectionConfigurationProvider.cs | 0 .../MessageSchemaProvider.cs | 0 .../Program.cs | 0 .../Worker.cs | 0 .../appsettings.Development.json | 0 .../appsettings.json | 0 20 files changed, 2 insertions(+), 2 deletions(-) rename dotnet/templates/content/EventDrivenConnectorTemplate/{Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate => }/.template.config/template.json (100%) rename dotnet/templates/content/EventDrivenConnectorTemplate/{Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate => }/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate.csproj (100%) rename dotnet/templates/content/EventDrivenConnectorTemplate/{Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate => }/LeaderElectionConfigurationProvider.cs (100%) rename dotnet/templates/content/EventDrivenConnectorTemplate/{Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate => }/MessageSchemaProvider.cs (100%) rename dotnet/templates/content/EventDrivenConnectorTemplate/{Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate => }/Program.cs (100%) rename dotnet/templates/content/EventDrivenConnectorTemplate/{Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate => }/TemplateConnectorWorker.cs (100%) rename dotnet/templates/content/EventDrivenConnectorTemplate/{Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate => }/Worker.cs (100%) rename dotnet/templates/content/EventDrivenConnectorTemplate/{Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate => }/appsettings.Development.json (100%) rename dotnet/templates/content/EventDrivenConnectorTemplate/{Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate => }/appsettings.json (100%) rename dotnet/templates/content/PollingConnectorTemplate/{Azure.Iot.Operations.Templates.PollingConnectorTemplate => }/.template.config/template.json (100%) rename dotnet/templates/content/PollingConnectorTemplate/{Azure.Iot.Operations.Templates.PollingConnectorTemplate => }/Azure.Iot.Operations.Templates.PollingConnectorTemplate.csproj (100%) rename dotnet/templates/content/PollingConnectorTemplate/{Azure.Iot.Operations.Templates.PollingConnectorTemplate => }/DatasetSampler.cs (100%) rename dotnet/templates/content/PollingConnectorTemplate/{Azure.Iot.Operations.Templates.PollingConnectorTemplate => }/DatasetSamplerProvider.cs (100%) rename dotnet/templates/content/PollingConnectorTemplate/{Azure.Iot.Operations.Templates.PollingConnectorTemplate => }/LeaderElectionConfigurationProvider.cs (100%) rename dotnet/templates/content/PollingConnectorTemplate/{Azure.Iot.Operations.Templates.PollingConnectorTemplate => }/MessageSchemaProvider.cs (100%) rename dotnet/templates/content/PollingConnectorTemplate/{Azure.Iot.Operations.Templates.PollingConnectorTemplate => }/Program.cs (100%) rename dotnet/templates/content/PollingConnectorTemplate/{Azure.Iot.Operations.Templates.PollingConnectorTemplate => }/Worker.cs (100%) rename dotnet/templates/content/PollingConnectorTemplate/{Azure.Iot.Operations.Templates.PollingConnectorTemplate => }/appsettings.Development.json (100%) rename dotnet/templates/content/PollingConnectorTemplate/{Azure.Iot.Operations.Templates.PollingConnectorTemplate => }/appsettings.json (100%) diff --git a/dotnet/Azure.Iot.Operations.sln b/dotnet/Azure.Iot.Operations.sln index 2465eb14ac..bb3c80ff6d 100644 --- a/dotnet/Azure.Iot.Operations.sln +++ b/dotnet/Azure.Iot.Operations.sln @@ -93,9 +93,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "EventDrivenTelemetryConnect EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PollingTelemetryConnector", "PollingTelemetryConnector", "{8826F302-A3F9-4543-90EE-27196D9179EA}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate", "templates\content\EventDrivenConnectorTemplate\Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate\Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate.csproj", "{ADDAE3BF-371C-4D4C-913E-9D165F28D6F2}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate", "templates\content\EventDrivenConnectorTemplate\Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate.csproj", "{ADDAE3BF-371C-4D4C-913E-9D165F28D6F2}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Iot.Operations.Templates.PollingConnectorTemplate", "templates\content\PollingConnectorTemplate\Azure.Iot.Operations.Templates.PollingConnectorTemplate\Azure.Iot.Operations.Templates.PollingConnectorTemplate.csproj", "{2D62BB36-B1A0-4A57-9F13-EA37A6E6FD51}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Iot.Operations.Templates.PollingConnectorTemplate", "templates\content\PollingConnectorTemplate\Azure.Iot.Operations.Templates.PollingConnectorTemplate.csproj", "{2D62BB36-B1A0-4A57-9F13-EA37A6E6FD51}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/.template.config/template.json b/dotnet/templates/content/EventDrivenConnectorTemplate/.template.config/template.json similarity index 100% rename from dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/.template.config/template.json rename to dotnet/templates/content/EventDrivenConnectorTemplate/.template.config/template.json diff --git a/dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate.csproj b/dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate.csproj similarity index 100% rename from dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate.csproj rename to dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate.csproj diff --git a/dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/LeaderElectionConfigurationProvider.cs b/dotnet/templates/content/EventDrivenConnectorTemplate/LeaderElectionConfigurationProvider.cs similarity index 100% rename from dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/LeaderElectionConfigurationProvider.cs rename to dotnet/templates/content/EventDrivenConnectorTemplate/LeaderElectionConfigurationProvider.cs diff --git a/dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/MessageSchemaProvider.cs b/dotnet/templates/content/EventDrivenConnectorTemplate/MessageSchemaProvider.cs similarity index 100% rename from dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/MessageSchemaProvider.cs rename to dotnet/templates/content/EventDrivenConnectorTemplate/MessageSchemaProvider.cs diff --git a/dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/Program.cs b/dotnet/templates/content/EventDrivenConnectorTemplate/Program.cs similarity index 100% rename from dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/Program.cs rename to dotnet/templates/content/EventDrivenConnectorTemplate/Program.cs diff --git a/dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/TemplateConnectorWorker.cs b/dotnet/templates/content/EventDrivenConnectorTemplate/TemplateConnectorWorker.cs similarity index 100% rename from dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/TemplateConnectorWorker.cs rename to dotnet/templates/content/EventDrivenConnectorTemplate/TemplateConnectorWorker.cs diff --git a/dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/Worker.cs b/dotnet/templates/content/EventDrivenConnectorTemplate/Worker.cs similarity index 100% rename from dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/Worker.cs rename to dotnet/templates/content/EventDrivenConnectorTemplate/Worker.cs diff --git a/dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/appsettings.Development.json b/dotnet/templates/content/EventDrivenConnectorTemplate/appsettings.Development.json similarity index 100% rename from dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/appsettings.Development.json rename to dotnet/templates/content/EventDrivenConnectorTemplate/appsettings.Development.json diff --git a/dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/appsettings.json b/dotnet/templates/content/EventDrivenConnectorTemplate/appsettings.json similarity index 100% rename from dotnet/templates/content/EventDrivenConnectorTemplate/Azure.Iot.Operations.Templates.EventDrivenConnectorTemplate/appsettings.json rename to dotnet/templates/content/EventDrivenConnectorTemplate/appsettings.json diff --git a/dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/.template.config/template.json b/dotnet/templates/content/PollingConnectorTemplate/.template.config/template.json similarity index 100% rename from dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/.template.config/template.json rename to dotnet/templates/content/PollingConnectorTemplate/.template.config/template.json diff --git a/dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate.csproj b/dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate.csproj similarity index 100% rename from dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate.csproj rename to dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate.csproj diff --git a/dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/DatasetSampler.cs b/dotnet/templates/content/PollingConnectorTemplate/DatasetSampler.cs similarity index 100% rename from dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/DatasetSampler.cs rename to dotnet/templates/content/PollingConnectorTemplate/DatasetSampler.cs diff --git a/dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/DatasetSamplerProvider.cs b/dotnet/templates/content/PollingConnectorTemplate/DatasetSamplerProvider.cs similarity index 100% rename from dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/DatasetSamplerProvider.cs rename to dotnet/templates/content/PollingConnectorTemplate/DatasetSamplerProvider.cs diff --git a/dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/LeaderElectionConfigurationProvider.cs b/dotnet/templates/content/PollingConnectorTemplate/LeaderElectionConfigurationProvider.cs similarity index 100% rename from dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/LeaderElectionConfigurationProvider.cs rename to dotnet/templates/content/PollingConnectorTemplate/LeaderElectionConfigurationProvider.cs diff --git a/dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/MessageSchemaProvider.cs b/dotnet/templates/content/PollingConnectorTemplate/MessageSchemaProvider.cs similarity index 100% rename from dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/MessageSchemaProvider.cs rename to dotnet/templates/content/PollingConnectorTemplate/MessageSchemaProvider.cs diff --git a/dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/Program.cs b/dotnet/templates/content/PollingConnectorTemplate/Program.cs similarity index 100% rename from dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/Program.cs rename to dotnet/templates/content/PollingConnectorTemplate/Program.cs diff --git a/dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/Worker.cs b/dotnet/templates/content/PollingConnectorTemplate/Worker.cs similarity index 100% rename from dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/Worker.cs rename to dotnet/templates/content/PollingConnectorTemplate/Worker.cs diff --git a/dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/appsettings.Development.json b/dotnet/templates/content/PollingConnectorTemplate/appsettings.Development.json similarity index 100% rename from dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/appsettings.Development.json rename to dotnet/templates/content/PollingConnectorTemplate/appsettings.Development.json diff --git a/dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/appsettings.json b/dotnet/templates/content/PollingConnectorTemplate/appsettings.json similarity index 100% rename from dotnet/templates/content/PollingConnectorTemplate/Azure.Iot.Operations.Templates.PollingConnectorTemplate/appsettings.json rename to dotnet/templates/content/PollingConnectorTemplate/appsettings.json From c8784b6fffd656655da20d5cc1592e2aef64444f Mon Sep 17 00:00:00 2001 From: timtay-microsoft Date: Wed, 22 Oct 2025 15:05:28 -0700 Subject: [PATCH 08/12] name of leadership position --- .../LeaderElectionConfigurationProvider.cs | 2 +- .../LeaderElectionConfigurationProvider.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dotnet/templates/content/EventDrivenConnectorTemplate/LeaderElectionConfigurationProvider.cs b/dotnet/templates/content/EventDrivenConnectorTemplate/LeaderElectionConfigurationProvider.cs index 54e383d4d1..70449799fb 100644 --- a/dotnet/templates/content/EventDrivenConnectorTemplate/LeaderElectionConfigurationProvider.cs +++ b/dotnet/templates/content/EventDrivenConnectorTemplate/LeaderElectionConfigurationProvider.cs @@ -14,7 +14,7 @@ public class LeaderElectionConfigurationProvider : IConnectorLeaderElectionConfi public ConnectorLeaderElectionConfiguration GetLeaderElectionConfiguration() { - return new("some-http-leadership-position-id", TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(9)); + return new("some-leadership-position-id", TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(9)); } } } diff --git a/dotnet/templates/content/PollingConnectorTemplate/LeaderElectionConfigurationProvider.cs b/dotnet/templates/content/PollingConnectorTemplate/LeaderElectionConfigurationProvider.cs index 0d1f47c37a..8a1d903aef 100644 --- a/dotnet/templates/content/PollingConnectorTemplate/LeaderElectionConfigurationProvider.cs +++ b/dotnet/templates/content/PollingConnectorTemplate/LeaderElectionConfigurationProvider.cs @@ -14,7 +14,7 @@ public class LeaderElectionConfigurationProvider : IConnectorLeaderElectionConfi public ConnectorLeaderElectionConfiguration GetLeaderElectionConfiguration() { - return new("some-http-leadership-position-id", TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(9)); + return new("some-leadership-position-id", TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(9)); } } } From 35a586bb66e5999b3afc429e6ca10fdd5a91181a Mon Sep 17 00:00:00 2001 From: timtay-microsoft Date: Thu, 23 Oct 2025 10:52:26 -0700 Subject: [PATCH 09/12] build pipeline step --- .github/workflows/ci-dotnet.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci-dotnet.yml b/.github/workflows/ci-dotnet.yml index 49014d5d12..4ba7449014 100644 --- a/.github/workflows/ci-dotnet.yml +++ b/.github/workflows/ci-dotnet.yml @@ -77,8 +77,7 @@ jobs: - name: Install .NET connector templates run: | - dotnet new install dotnet/templates/EventDrivenTelemetryConnector - dotnet new install dotnet/templates/PollingTelemetryConnector + dotnet new install dotnet/templates - name: Build Faultable MQTT Broker run: dotnet build eng/test/faultablemqttbroker/src/Azure.Iot.Operations.FaultableMqttBroker/Azure.Iot.Operations.FaultableMqttBroker.csproj From 2ed2532fa99ffd8721f6c5cfd4a321c651607994 Mon Sep 17 00:00:00 2001 From: timtay-microsoft Date: Thu, 23 Oct 2025 11:32:36 -0700 Subject: [PATCH 10/12] More documentation --- .../LeaderElectionConfigurationProvider.cs | 13 ++++++++++++- .../MessageSchemaProvider.cs | 9 +++++++++ .../content/EventDrivenConnectorTemplate/Program.cs | 3 --- .../DatasetSamplerProvider.cs | 8 ++++++-- .../LeaderElectionConfigurationProvider.cs | 13 ++++++++++++- .../MessageSchemaProvider.cs | 9 +++++++++ .../content/PollingConnectorTemplate/Program.cs | 3 --- 7 files changed, 48 insertions(+), 10 deletions(-) diff --git a/dotnet/templates/content/EventDrivenConnectorTemplate/LeaderElectionConfigurationProvider.cs b/dotnet/templates/content/EventDrivenConnectorTemplate/LeaderElectionConfigurationProvider.cs index 70449799fb..e39cdc3d6a 100644 --- a/dotnet/templates/content/EventDrivenConnectorTemplate/LeaderElectionConfigurationProvider.cs +++ b/dotnet/templates/content/EventDrivenConnectorTemplate/LeaderElectionConfigurationProvider.cs @@ -5,6 +5,15 @@ namespace EventDrivenTelemetryConnector { + /// + /// Factory that provides all leader election configurations for this connector. + /// + /// + /// Connectors can have active/passive replication by deploying more than one replica and having each replica + /// provide the same leadership position Id. That way, only one replica is the leader at a time. + /// + /// If no replication of this connector is needed, then this class can be deleted. + /// public class LeaderElectionConfigurationProvider : IConnectorLeaderElectionConfigurationProvider { public static Func Factory = service => @@ -14,7 +23,9 @@ public class LeaderElectionConfigurationProvider : IConnectorLeaderElectionConfi public ConnectorLeaderElectionConfiguration GetLeaderElectionConfiguration() { - return new("some-leadership-position-id", TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(9)); + // This value should be the same across any replicas but should be unique from connector to connector. + string leadershipPositionId = "some-leadership-position-id"; + return new(leadershipPositionId, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(9)); } } } diff --git a/dotnet/templates/content/EventDrivenConnectorTemplate/MessageSchemaProvider.cs b/dotnet/templates/content/EventDrivenConnectorTemplate/MessageSchemaProvider.cs index 640bfb4483..93e1434642 100644 --- a/dotnet/templates/content/EventDrivenConnectorTemplate/MessageSchemaProvider.cs +++ b/dotnet/templates/content/EventDrivenConnectorTemplate/MessageSchemaProvider.cs @@ -6,6 +6,15 @@ namespace EventDrivenTelemetryConnector { + /// + /// The factory method for determining what message schema should be registered for and attached to each + /// emitted telemetry message for each event handled by this connector. If no message schema is needed, + /// then this class can be left as-is. + /// + /// + /// Registering message schemas allows the receiver of a message to fetch this schema from the schema + /// registry service. With that schema, the receiver can correctly deserialize each received message's payload. + /// internal class MessageSchemaProvider : IMessageSchemaProvider { public static Func Factory = service => diff --git a/dotnet/templates/content/EventDrivenConnectorTemplate/Program.cs b/dotnet/templates/content/EventDrivenConnectorTemplate/Program.cs index 8202d139e4..82b3caad0b 100644 --- a/dotnet/templates/content/EventDrivenConnectorTemplate/Program.cs +++ b/dotnet/templates/content/EventDrivenConnectorTemplate/Program.cs @@ -2,12 +2,9 @@ // Licensed under the MIT License. using Azure.Iot.Operations.Connector; -using Azure.Iot.Operations.Connector.ConnectorConfigurations; using Azure.Iot.Operations.Protocol; using EventDrivenTelemetryConnector; -string connectorClientId = Environment.GetEnvironmentVariable(ConnectorFileMountSettings.ConnectorClientIdEnvVar) ?? throw new InvalidOperationException("No MQTT client Id configured by Akri operator"); - IHost host = Host.CreateDefaultBuilder(args) .ConfigureServices(services => { diff --git a/dotnet/templates/content/PollingConnectorTemplate/DatasetSamplerProvider.cs b/dotnet/templates/content/PollingConnectorTemplate/DatasetSamplerProvider.cs index 5b957b15d4..46c7e55d8b 100644 --- a/dotnet/templates/content/PollingConnectorTemplate/DatasetSamplerProvider.cs +++ b/dotnet/templates/content/PollingConnectorTemplate/DatasetSamplerProvider.cs @@ -7,6 +7,9 @@ namespace PollingTelemetryConnectorTemplate { + /// + /// The factory for creating the samplers for each dataset. + /// public class DatasetSamplerProvider : IDatasetSamplerFactory { public static Func Factory = service => @@ -16,8 +19,9 @@ public class DatasetSamplerProvider : IDatasetSamplerFactory public IDatasetSampler CreateDatasetSampler(string deviceName, Device device, string inboundEndpointName, string assetName, Asset asset, AssetDataset dataset, EndpointCredentials? endpointCredentials) { - // this method should return the appropriate dataset sampler implementation for the provided asset + dataset. This - // method may be called multiple times if the asset or dataset changes in any way over time. + // As the connector discovers each dataset, it will need to know how to sample that dataset. To figure that + // out, this callback is invoked to provide context on which dataset was discovered and what device + endpoint + asset it + // belongs to. This callback may be called multiple times if the asset or dataset changes in any way over time. throw new NotImplementedException(); } } diff --git a/dotnet/templates/content/PollingConnectorTemplate/LeaderElectionConfigurationProvider.cs b/dotnet/templates/content/PollingConnectorTemplate/LeaderElectionConfigurationProvider.cs index 8a1d903aef..2fb3b5addf 100644 --- a/dotnet/templates/content/PollingConnectorTemplate/LeaderElectionConfigurationProvider.cs +++ b/dotnet/templates/content/PollingConnectorTemplate/LeaderElectionConfigurationProvider.cs @@ -5,6 +5,15 @@ namespace PollingTelemetryConnectorTemplate { + /// + /// Factory that provides all leader election configurations for this connector. + /// + /// + /// Connectors can have active/passive replication by deploying more than one replica and having each replica + /// provide the same leadership position Id. That way, only one replica is the leader at a time. + /// + /// If no replication of this connector is needed, then this class can be deleted. + /// public class LeaderElectionConfigurationProvider : IConnectorLeaderElectionConfigurationProvider { public static Func Factory = service => @@ -14,7 +23,9 @@ public class LeaderElectionConfigurationProvider : IConnectorLeaderElectionConfi public ConnectorLeaderElectionConfiguration GetLeaderElectionConfiguration() { - return new("some-leadership-position-id", TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(9)); + // This value should be the same across any replicas but should be unique from connector to connector. + string leadershipPositionId = "some-leadership-position-id"; + return new(leadershipPositionId, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(9)); } } } diff --git a/dotnet/templates/content/PollingConnectorTemplate/MessageSchemaProvider.cs b/dotnet/templates/content/PollingConnectorTemplate/MessageSchemaProvider.cs index 5b05c252bf..f5bbfb8f74 100644 --- a/dotnet/templates/content/PollingConnectorTemplate/MessageSchemaProvider.cs +++ b/dotnet/templates/content/PollingConnectorTemplate/MessageSchemaProvider.cs @@ -6,6 +6,15 @@ namespace PollingTelemetryConnectorTemplate { + /// + /// The factory method for determining what message schema should be registered for and attached to each + /// emitted telemetry message for each dataset handled by this connector. If no message schema is needed, + /// then this class can be left as-is. + /// + /// + /// Registering message schemas allows the receiver of a message to fetch this schema from the schema + /// registry service. With that schema, the receiver can correctly deserialize each received message's payload. + /// internal class MessageSchemaProvider : IMessageSchemaProvider { public static Func Factory = service => diff --git a/dotnet/templates/content/PollingConnectorTemplate/Program.cs b/dotnet/templates/content/PollingConnectorTemplate/Program.cs index 3cc6ad22f5..5babcb83d2 100644 --- a/dotnet/templates/content/PollingConnectorTemplate/Program.cs +++ b/dotnet/templates/content/PollingConnectorTemplate/Program.cs @@ -2,12 +2,9 @@ // Licensed under the MIT License. using Azure.Iot.Operations.Connector; -using Azure.Iot.Operations.Connector.ConnectorConfigurations; using Azure.Iot.Operations.Protocol; using PollingTelemetryConnectorTemplate; -string connectorClientId = Environment.GetEnvironmentVariable(ConnectorFileMountSettings.ConnectorClientIdEnvVar) ?? throw new InvalidOperationException("No MQTT client Id configured by Akri operator"); - IHost host = Host.CreateDefaultBuilder(args) .ConfigureServices(services => { From 8e4771a80e82be822d32a883b8769ae8739031cd Mon Sep 17 00:00:00 2001 From: timtay-microsoft Date: Tue, 4 Nov 2025 11:58:00 -0800 Subject: [PATCH 11/12] compliance --- dotnet/templates/Azure.Iot.Operations.Templates.csproj | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dotnet/templates/Azure.Iot.Operations.Templates.csproj b/dotnet/templates/Azure.Iot.Operations.Templates.csproj index 6c06117e89..48700f723f 100644 --- a/dotnet/templates/Azure.Iot.Operations.Templates.csproj +++ b/dotnet/templates/Azure.Iot.Operations.Templates.csproj @@ -7,7 +7,10 @@ Microsoft .NET project templates for creating Azure IoT Operations solutions azure;iot;sdk;edge - https://github.com/Azure/iot-operations-sdks + https://github.com/Azure/iot-operations-sdks/ + https://github.com/Azure/iot-operations-sdks/blob/main/LICENSE + MIT + © Microsoft Corporation. All rights reserved. Template net9.0 From bba57d67b9b8c4f1d7b635fb3544397579f5c939 Mon Sep 17 00:00:00 2001 From: timtay-microsoft Date: Wed, 5 Nov 2025 10:49:05 -0800 Subject: [PATCH 12/12] readme --- dotnet/templates/README.md | 46 +++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/dotnet/templates/README.md b/dotnet/templates/README.md index 157b678754..97e9f1f432 100644 --- a/dotnet/templates/README.md +++ b/dotnet/templates/README.md @@ -10,4 +10,48 @@ This package contains the following project templates to help you develop Azure For examples on how to fill out these templates, see the completed samples [here](https://github.com/Azure/iot-operations-sdks/tree/main/dotnet/samples). -If you have any questions or need any support, please file an issue [here](https://github.com/Azure/iot-operations-sdks/issues) \ No newline at end of file +If you have any questions or need any support, please file an issue [here](https://github.com/Azure/iot-operations-sdks/issues) + +## How To Install A .NET Project Template + +To install these templates using the published package in Nuget.org, run the following command: + +```bash +dotnet new install Azure.Iot.Operations.Template +``` + +Alternatively, to install these templates from source, run the following command in this directory: + +```bash +dotnet new install . +``` + +## How To Create A New Project With An Installed Project Template + +You can use this locally installed project template when creating a new project in Visual Studio: + +`File -> New Project -> Select the installed project template` + +Alternatively, you can create a new project from an installed template from command line: + +```bash +dotnet new aiopollingtelemetryconnector -n MyConnectorApp +``` + +Where "aiopollingtelemetryconnector" is the short name defined in the project template's [template.json file](./content/PollingConnectorTemplate/.template.config/template.json) and where "MyConnectorApp" is the name of your project. + +Note that this command will create the project "MyConnectorApp" in the same directory that the command was run from. + +## How To Uninstall A .NET Project Template + +To uninstall these templates when they were installed from the published package in Nuget.org, run the following command: + +```bash +dotnet new uninstall Azure.Iot.Operations.Template +``` + +Alternatively, to uninstall these templates when they were installed from source, run the following command in this directory: + +```bash +dotnet new uninstall . +``` \ No newline at end of file