Siemens.AspNet.Lambda.Sdk.Contracts 0.1.0-alpha.235

Prefix Reserved
This is a prerelease version of Siemens.AspNet.Lambda.Sdk.Contracts.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Siemens.AspNet.Lambda.Sdk.Contracts --version 0.1.0-alpha.235
                    
NuGet\Install-Package Siemens.AspNet.Lambda.Sdk.Contracts -Version 0.1.0-alpha.235
                    
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="Siemens.AspNet.Lambda.Sdk.Contracts" Version="0.1.0-alpha.235" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Siemens.AspNet.Lambda.Sdk.Contracts" Version="0.1.0-alpha.235" />
                    
Directory.Packages.props
<PackageReference Include="Siemens.AspNet.Lambda.Sdk.Contracts" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Siemens.AspNet.Lambda.Sdk.Contracts --version 0.1.0-alpha.235
                    
#r "nuget: Siemens.AspNet.Lambda.Sdk.Contracts, 0.1.0-alpha.235"
                    
#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.
#:package Siemens.AspNet.Lambda.Sdk.Contracts@0.1.0-alpha.235
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Siemens.AspNet.Lambda.Sdk.Contracts&version=0.1.0-alpha.235&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Siemens.AspNet.Lambda.Sdk.Contracts&version=0.1.0-alpha.235&prerelease
                    
Install as a Cake Tool

Siemens.AspNet.Lambda.Sdk.Contracts

The Siemens.AspNet.Lambda.Sdk.Contracts NuGet package provides core abstractions—interfaces, delegates, and base classes—essential for implementing AWS Lambda functions using the Siemens Lambda SDK. This contract library enables consistent, maintainable, and testable Lambda implementations.


📖 Overview

This package defines interfaces and delegates crucial for middleware-based pipeline handling and function execution in AWS Lambda environments.

✅ Key Abstractions

  • 📐 Lambda Function Handlers

    • IFunctionHandler<TRequest>
    • IFunctionHandler<TRequest, TResponse>
  • 🔗 Middleware Interfaces

    • ILambdaMiddleware<TRequest>
    • ILambdaMiddleware<TRequest, TResponse>
  • 🚦 Pipeline Executors

    • ILambdaPipelineExecutor<TRequest>
    • ILambdaPipelineExecutor<TRequest, TResponse>
  • 🔀 Delegates for Request Handling

    • LambdaRequestDelegate<TRequest>
    • LambdaRequestDelegate<TRequest, TResponse>
  • 📌 Structured Error Logging

    • SpecificErrorLogHandler

📦 Installation

Using the .NET CLI

dotnet add package Siemens.AspNet.Lambda.Sdk.Contracts

🚀 Example Implementations

Implementing a simple Lambda function without response

public class MyFunction : FunctionBase<SQSEvent>
{
    public override Task HandleAsync(SQSEvent request, ILambdaContext context)
    {
        // Your Lambda handling logic here      
    }
}

Implementing a simple Lambda function with request and response

public class Function : FunctionBase<CognitoPostConfirmationEvent, CognitoPostConfirmationEvent>
{
    public override Task<CognitoPostConfirmationEvent> HandleAsync(CognitoPostConfirmationEvent request,
                                                                   ILambdaContext context)
    {
        // Your Lambda handling logic here        
    }
}

Implementing a Lambda function with custom handler and dependency injection

Function:

public class Function : FunctionHandlerBase<Startup, CognitoPostConfirmationEvent, CognitoPostConfirmationEvent>
{
}

Startup:

public sealed class Startup : LambdaStartup
{
    protected override void ConfigureServices(IServiceCollection services,
                                              IConfiguration configuration)
    {
        base.ConfigureServices(services, configuration);

        services.AddFunctionHandler();
    }
}

FunctionHandler:

internal static class AddFunctionHandlerExtension
{
    internal static void AddFunctionHandler(this IServiceCollection services)
    {
        services.AddSingletonIfNotExists<IFunctionHandler<CognitoPostConfirmationEvent, CognitoPostConfirmationEvent>, FunctionHandler>();
    }
}

internal sealed class FunctionHandler(IMyService service,
                                      IJsonSerializer jsonSerializer) : IFunctionHandler<CognitoPostConfirmationEvent, CognitoPostConfirmationEvent>
{
    public Task<CognitoPostConfirmationEvent> HandleAsync(CognitoPostConfirmationEvent request,
                                                          ILambdaContext context)
    {
        // Your custom logic here
    }
}

Lambda Middleware Pipeline

Leverage middleware for clean and maintainable request handling. Sample middleware for error logging: (This middleware is already included in the SDK and active !)

internal static class AddErrorLogRequestMiddlewareExtension
{
    internal static void AddErrorLogRequestMiddleware(this IServiceCollection services)
    {
        services.AddErrorLoggingStrategyForLambda();
            
        services.AddSingleton(typeof(ILambdaMiddleware<>), typeof(ErrorLogRequestMiddleware<>));
    }
}

internal sealed class ErrorLogRequestMiddleware<TRequest>(IErrorLoggingStrategyForLambda errorLoggingStrategy) : ILambdaMiddleware<TRequest>
{
    public async Task InvokeAsync(TRequest request,
                                    ILambdaContext context,
                                    LambdaRequestDelegate<TRequest> requestDelegate)
    {
        try
        {
            await requestDelegate(request, context).ConfigureAwait(false);
        }
        catch (Exception e)
        {
            await errorLoggingStrategy.HandleAsync(context, e).ConfigureAwait(false);
            throw;
        }
    }
}

📌 Usage & Best Practices

  • Use provided interfaces to structure Lambda functions clearly.
  • Middleware helps implement cross-cutting concerns (logging, validation, error handling).
  • Implement custom pipeline executors for advanced control over middleware execution flow.

📚 Documentation

Detailed documentation and examples are included in the source repository and will be published online soon.


📢 Contributing

Contributions and feedback are highly appreciated! Feel free to create issues or submit pull requests.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Siemens.AspNet.Lambda.Sdk.Contracts:

Package Downloads
Siemens.AspNet.Lambda.Sdk

The Siemens.AspNet.Lambda.Sdk NuGet package simplifies and accelerates the development of AWS Lambda functions using ASP.NET-inspired middleware pipelines, structured exception handling, and pre-configured startup patterns.

Siemens.AspNet.Lambda.MsTest.Sdk

The Siemens.AspNet.Lambda.MsTest.Sdk NuGet package provides testing utilities and extensions for AWS Lambda functions, including structured test handlers, mock support, and comprehensive test coverage tools.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0-alpha.237 147 8/6/2025
0.1.0-alpha.236 151 8/5/2025
0.1.0-alpha.235 149 8/5/2025
0.1.0-alpha.234 151 8/5/2025
0.1.0-alpha.233 150 8/4/2025
0.1.0-alpha.232 149 8/4/2025
0.1.0-alpha.231 62 8/1/2025
0.1.0-alpha.230 62 8/1/2025
0.1.0-alpha.229 84 7/31/2025
0.1.0-alpha.228 84 7/31/2025
0.1.0-alpha.227 84 7/31/2025
0.1.0-alpha.225 83 7/31/2025
0.1.0-alpha.224 84 7/30/2025
0.1.0-alpha.222 175 7/16/2025
0.1.0-alpha.219 161 7/14/2025
0.1.0-alpha.217 77 7/11/2025
0.1.0-alpha.212 155 7/8/2025
0.1.0-alpha.211 120 7/3/2025
0.1.0-alpha.207 107 7/3/2025
0.1.0-alpha.206 246 6/30/2025
0.1.0-alpha.205 95 6/27/2025
0.1.0-alpha.202 80 6/27/2025
0.1.0-alpha.200 89 6/27/2025
0.1.0-alpha.198 88 6/27/2025
0.1.0-alpha.196 95 6/27/2025
0.1.0-alpha.195 87 6/27/2025
0.1.0-alpha.194 91 6/27/2025
0.1.0-alpha.193 92 6/27/2025
0.1.0-alpha.192 89 6/27/2025
0.1.0-alpha.191 91 6/27/2025
0.1.0-alpha.189 107 6/26/2025
0.1.0-alpha.188 109 6/26/2025
0.1.0-alpha.187 107 6/26/2025
0.1.0-alpha.186 109 6/26/2025
0.1.0-alpha.185 118 6/26/2025
0.1.0-alpha.184 103 6/26/2025
0.1.0-alpha.183 108 6/26/2025
0.1.0-alpha.182 109 6/26/2025
0.1.0-alpha.181 109 6/25/2025
0.1.0-alpha.180 117 6/24/2025
0.1.0-alpha.179 118 6/23/2025
0.1.0-alpha.178 121 6/23/2025
0.1.0-alpha.176 114 6/23/2025
0.1.0-alpha.174 120 6/19/2025
0.1.0-alpha.173 112 6/19/2025
0.1.0-alpha.172 119 6/17/2025
0.1.0-alpha.171 115 6/16/2025
0.1.0-alpha.169 113 6/16/2025
0.1.0-alpha.165 257 6/13/2025
0.1.0-alpha.164 221 6/13/2025
0.1.0-alpha.163 225 6/13/2025
0.1.0-alpha.160 257 6/12/2025
0.1.0-alpha.159 279 6/11/2025
0.1.0-alpha.158 259 6/11/2025
0.1.0-alpha.143 265 6/11/2025
0.1.0-alpha.142 259 6/11/2025
0.1.0-alpha.140 262 6/11/2025
0.1.0-alpha.139 262 6/10/2025
0.1.0-alpha.138 241 6/9/2025
0.1.0-alpha.137 42 6/7/2025
0.1.0-alpha.136 47 6/7/2025
0.1.0-alpha.135 83 6/6/2025
0.1.0-alpha.134 71 6/6/2025
0.1.0-alpha.130 117 6/5/2025
0.1.0-alpha.129 122 6/4/2025
0.1.0-alpha.128 111 6/4/2025
0.1.0-alpha.122 122 6/3/2025
0.1.0-alpha.121 126 6/1/2025
0.1.0-alpha.120 83 6/1/2025
0.1.0-alpha.118 122 5/28/2025
0.1.0-alpha.117 118 5/28/2025
0.1.0-alpha.116 120 5/28/2025
0.1.0-alpha.115 124 5/26/2025
0.1.0-alpha.114 130 5/22/2025
0.1.0-alpha.112 129 5/21/2025
0.1.0-alpha.111 119 5/20/2025
0.1.0-alpha.108 122 5/19/2025
0.1.0-alpha.104 190 5/18/2025
0.1.0-alpha.102 203 5/14/2025
0.1.0-alpha.101 207 5/14/2025
0.1.0-alpha.100 218 5/12/2025
0.1.0-alpha.99 200 5/12/2025
0.1.0-alpha.98 59 5/10/2025
0.1.0-alpha.97 57 5/10/2025
0.1.0-alpha.86 125 5/8/2025
0.1.0-alpha.85 118 5/8/2025
0.1.0-alpha.84 123 5/8/2025
0.1.0-alpha.82 130 5/7/2025
0.1.0-alpha.81 129 5/6/2025
0.1.0-alpha.76 57 5/3/2025
0.1.0-alpha.75 74 5/2/2025
0.1.0-alpha.74 88 5/2/2025