RpicHybridRelay 1.0.12

dotnet add package RpicHybridRelay --version 1.0.12                
NuGet\Install-Package RpicHybridRelay -Version 1.0.12                
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="RpicHybridRelay" Version="1.0.12" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RpicHybridRelay --version 1.0.12                
#r "nuget: RpicHybridRelay, 1.0.12"                
#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 RpicHybridRelay as a Cake Addin
#addin nuget:?package=RpicHybridRelay&version=1.0.12

// Install RpicHybridRelay as a Cake Tool
#tool nuget:?package=RpicHybridRelay&version=1.0.12                

Hybrid Relay Contracts

Standardized processor classes for Azure Hybrid Relay using encrypted application settings files and a generic pattern for creating processor classes.

Worker startup for Windows Service:

using System.Diagnostics.CodeAnalysis;
using HybridRelaySettings = Rpic.Common.HybridRelay.HybridRelaySettings;

namespace Sample.HybridRelayListener
{
    public class Worker : BackgroundService
    {
        private readonly ILogger<Worker> _logger;

        public Worker(ILogger<Worker> logger)
        {
            _logger = logger;
        }

        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            // Create action controller that will perform an action when called remotely
            var processor = new InventoryExportProcessor();

            // Encryption seed for protecting the configuration file
            const string encryption = "UPD_zPH -@kXd.Zg!xVi7@6XYZK.Z6R";

            // Load relay settings
            var settings = HybridRelaySettings.Load(encryption);

            // Create listener service
            var listener = new Rpic.Common.HybridRelay.HybridRelayListener(
                processor.Process, // The method that will be called when the listener receives data
                settings,
                encryption,
                _logger);

            // Start the service
            await listener.Start(); // Start the listener and register a channel to hybrid relay
            _logger.LogInformation("Worker started at: {time}", DateTimeOffset.Now);

            // Keep running until service stopped
            while (!stoppingToken.IsCancellationRequested)
            {
                await Task.Delay(1000, stoppingToken);
            }

            // Remove the channel listener registration
            await listener.Stop();
            _logger.LogInformation("Worker stopped at: {time}", DateTimeOffset.Now);
        }
    }
}

Settings file:

Note: Make use of appsettings.local or UserSecrets for the key - don't check in your keys to GitHub!

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "HybridRelay": {
    "DisplayName": "RPIC Proxy Service",
    "Description": "Hybrid relay service listener for publishing data records to RPIC Integration Platform.",
    "Namespace": "relay-rpic-lekman-ts",
    "Connection": "hrc-template-rpic-ts",
    "Key": {
      "Value": "Add initial secret here",
      "Secret": "Value will be updated once service starts and encrypt to local machine key and entropy"
    },
    "KeyName": "RootManageSharedAccessKey"
  }
}

Implementation of service process:

using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using Microsoft.Azure.Relay;
using Newtonsoft.Json;
using Rpic.Common.HybridRelay;

namespace Rpic.InventoryLogistics.InventoryExport.HybridRelayListener
{
    internal class SampleProcessor : IHybridRelayListenerProcessor
    {
        internal string Process(Stream stream, ILogger logger)
        {
            // Add code to call private API
            var response = SomeService.Call();

            // Return as JSON
            return JsonConvert.SerializeObject(response);
        }
    }
}
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
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.0.12 520 3/12/2024
1.0.11 147 2/21/2024
1.0.10 125 2/14/2024
1.0.8 127 2/13/2024
1.0.7 93 2/8/2024
1.0.6 214 12/5/2023
1.0.5 159 9/27/2023
1.0.4 2,543 9/19/2023
1.0.3 184 8/15/2023
1.0.2 166 6/29/2023
1.0.1 169 6/29/2023
1.0.0 167 6/28/2023 1.0.0 is deprecated because it has critical bugs.