Siemens.AspNet.Lambda.Sdk 0.1.0-alpha.84

Prefix Reserved
This is a prerelease version of Siemens.AspNet.Lambda.Sdk.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Siemens.AspNet.Lambda.Sdk --version 0.1.0-alpha.84
                    
NuGet\Install-Package Siemens.AspNet.Lambda.Sdk -Version 0.1.0-alpha.84
                    
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" Version="0.1.0-alpha.84" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Siemens.AspNet.Lambda.Sdk" Version="0.1.0-alpha.84" />
                    
Directory.Packages.props
<PackageReference Include="Siemens.AspNet.Lambda.Sdk" />
                    
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 --version 0.1.0-alpha.84
                    
#r "nuget: Siemens.AspNet.Lambda.Sdk, 0.1.0-alpha.84"
                    
#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@0.1.0-alpha.84
                    
#: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&version=0.1.0-alpha.84&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Siemens.AspNet.Lambda.Sdk&version=0.1.0-alpha.84&prerelease
                    
Install as a Cake Tool

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.


📖 Overview

This SDK enables developers to focus on implementing business logic by abstracting boilerplate and common concerns specific to AWS Lambda environments.

✅ Key Features

  • 🚀 Quick implementation of Lambda functions with structured base classes.
  • ⚙️ ASP.NET-like middleware pipeline support.
  • 📌 Customizable startup configurations with dependency injection.
  • 🔍 Structured error logging with built-in handlers for common exceptions.
  • 🔄 JSON serialization management.
  • 🛠️ Predefined strategies for logging and error handling.

📦 Installation

Using the .NET CLI

dotnet add package Siemens.AspNet.Lambda.Sdk

🧠 Key Concepts

Component Description
FunctionBase<TRequest> Base class for quick Lambda implementation - request only
FunctionBase<TRequest, TResponse> Base class for quick Lambda implementation - request and response
FunctionHandlerBase<TStartup, TRequest> Lambda function with custom handler and dependency injection
FunctionHandlerBase<TStartup, TRequest, TResponse> Lambda function with custom handler and dependency injection
ILambdaMiddleware<TRequest> Interface for creating middleware for request only
ILambdaMiddleware<TRequest, TResponse> Interface for creating middleware for request and response

⚡ Quickstart Examples

Dockerfile and entry point for the lambda

Important is the method name InvokeAsync this have to be used for your lambda json or docker file for the entry point of your lambda.

The name full qualified name of the method is used as entry point for the lambda function. The method name is used in the lambda json and docker file.

Component Value (Sample)
AssemblyName SiemensGPT.InitCognitoUser
FunctionFullQualifiedName SiemensGPT.InitCognitoUser.Function
MethodName InvokeAsync

Result: AssemblyName::FunctionFullQualifiedName::MethodName

CMD ["SiemensGPT.InitCognitoUser::SiemensGPT.InitCognitoUser.Function::InvokeAsync"]

Sample Dockerfile:

FROM --platform=linux/amd64 public.ecr.aws/lambda/dotnet:9

WORKDIR /var/task

# This COPY command copies the .NET Lambda project's build artifacts from the host machine into the image. 
# The source of the COPY should match where the .NET Lambda project publishes its build artifacts. If the Lambda function is being built 
# with the AWS .NET Lambda Tooling, the `--docker-host-build-output-dir` switch controls where the .NET Lambda project
# will be built. The .NET Lambda project templates default to having `--docker-host-build-output-dir`
# set in the aws-lambda-tools-defaults.json file to "bin/Release/lambda-publish".
#
# Alternatively Docker multi-stage build could be used to build the .NET Lambda project inside the image.
# For more information on this approach checkout the project's README.md file.
COPY "bin/Release/lambda-publish"  .

CMD ["SiemensGPT.InitCognitoUser::SiemensGPT.InitCognitoUser.Function::InvokeAsync"]

Sample json:

{
  "Information": [
    "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.",
    "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.",
    "dotnet lambda help",
    "All the command line options for the Lambda command can be specified in this file."
  ],
  "profile": "",
  "region": "",
  "configuration": "Release",
  "package-type": "image",
  "function-memory-size": 512,
  "function-timeout": 30,
  "image-command": "SiemensGPT.InitCognitoUser::SiemensGPT.InitCognitoUser.Function::InvokeAsync",
  "docker-host-build-output-dir": "./bin/Release/lambda-publish",
  "repository_uri": "381492162794.dkr.ecr.eu-west-1.amazonaws.com/cognito-beta-user-signup"
}

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;
        }
    }
}

📌 Error Handling and Logging

Built-in structured handlers:

  • DefaultExceptionLogHandler
  • ProblemDetailsExceptionLogHandler
  • ValidationDetailsExceptionLogHandler
  • ValidationProblemDetailsExtendedExceptionLogHandler

Each handler provides detailed, structured logging of exceptions, aiding in quick diagnostics and maintenance.


📚 Documentation

Detailed documentation and further examples can be found within the codebase and will soon be available online.


📢 Contributing

Contributions and feedback are welcome! Please create issues or pull requests to suggest improvements.

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

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
0.1.0-alpha.275 135 9/3/2025
0.1.0-alpha.274 289 9/2/2025
0.1.0-alpha.273 196 9/1/2025
0.1.0-alpha.272 111 9/1/2025
0.1.0-alpha.271 164 8/29/2025
0.1.0-alpha.270 155 8/29/2025
0.1.0-alpha.269 147 8/29/2025
0.1.0-alpha.268 157 8/29/2025
0.1.0-alpha.267 163 8/27/2025
0.1.0-alpha.266 160 8/27/2025
0.1.0-alpha.264 254 8/22/2025
0.1.0-alpha.263 66 8/22/2025
0.1.0-alpha.262 70 8/22/2025
0.1.0-alpha.261 88 8/22/2025
0.1.0-alpha.260 95 8/22/2025
0.1.0-alpha.259 92 8/22/2025
0.1.0-alpha.258 193 8/19/2025
0.1.0-alpha.257 189 8/18/2025
0.1.0-alpha.246 156 8/14/2025
0.1.0-alpha.245 122 8/14/2025
0.1.0-alpha.244 143 8/14/2025
0.1.0-alpha.243 122 8/14/2025
0.1.0-alpha.238 124 8/12/2025
0.1.0-alpha.237 476 8/6/2025
0.1.0-alpha.236 223 8/5/2025
0.1.0-alpha.235 199 8/5/2025
0.1.0-alpha.234 198 8/5/2025
0.1.0-alpha.233 163 8/4/2025
0.1.0-alpha.232 174 8/4/2025
0.1.0-alpha.231 70 8/1/2025
0.1.0-alpha.230 70 8/1/2025
0.1.0-alpha.229 95 7/31/2025
0.1.0-alpha.228 95 7/31/2025
0.1.0-alpha.227 93 7/31/2025
0.1.0-alpha.225 92 7/31/2025
0.1.0-alpha.224 97 7/30/2025
0.1.0-alpha.222 273 7/16/2025
0.1.0-alpha.219 168 7/14/2025
0.1.0-alpha.217 80 7/11/2025
0.1.0-alpha.212 167 7/8/2025
0.1.0-alpha.211 131 7/3/2025
0.1.0-alpha.207 114 7/3/2025
0.1.0-alpha.206 257 6/30/2025
0.1.0-alpha.205 109 6/27/2025
0.1.0-alpha.202 95 6/27/2025
0.1.0-alpha.200 98 6/27/2025
0.1.0-alpha.198 100 6/27/2025
0.1.0-alpha.196 103 6/27/2025
0.1.0-alpha.195 99 6/27/2025
0.1.0-alpha.194 98 6/27/2025
0.1.0-alpha.193 100 6/27/2025
0.1.0-alpha.192 101 6/27/2025
0.1.0-alpha.191 97 6/27/2025
0.1.0-alpha.189 119 6/26/2025
0.1.0-alpha.188 121 6/26/2025
0.1.0-alpha.187 120 6/26/2025
0.1.0-alpha.186 113 6/26/2025
0.1.0-alpha.185 117 6/26/2025
0.1.0-alpha.184 114 6/26/2025
0.1.0-alpha.183 117 6/26/2025
0.1.0-alpha.182 120 6/26/2025
0.1.0-alpha.181 119 6/25/2025
0.1.0-alpha.180 123 6/24/2025
0.1.0-alpha.179 123 6/23/2025
0.1.0-alpha.178 127 6/23/2025
0.1.0-alpha.176 125 6/23/2025
0.1.0-alpha.174 129 6/19/2025
0.1.0-alpha.173 120 6/19/2025
0.1.0-alpha.172 125 6/17/2025
0.1.0-alpha.171 127 6/16/2025
0.1.0-alpha.169 122 6/16/2025
0.1.0-alpha.165 272 6/13/2025
0.1.0-alpha.164 226 6/13/2025
0.1.0-alpha.163 231 6/13/2025
0.1.0-alpha.160 262 6/12/2025
0.1.0-alpha.159 286 6/11/2025
0.1.0-alpha.158 272 6/11/2025
0.1.0-alpha.143 263 6/11/2025
0.1.0-alpha.142 262 6/11/2025
0.1.0-alpha.140 271 6/11/2025
0.1.0-alpha.139 267 6/10/2025
0.1.0-alpha.138 267 6/9/2025
0.1.0-alpha.137 50 6/7/2025
0.1.0-alpha.136 51 6/7/2025
0.1.0-alpha.135 86 6/6/2025
0.1.0-alpha.134 82 6/6/2025
0.1.0-alpha.130 132 6/5/2025
0.1.0-alpha.129 120 6/4/2025
0.1.0-alpha.128 116 6/4/2025
0.1.0-alpha.122 121 6/3/2025
0.1.0-alpha.121 125 6/1/2025
0.1.0-alpha.120 82 6/1/2025
0.1.0-alpha.118 122 5/28/2025
0.1.0-alpha.117 122 5/28/2025
0.1.0-alpha.116 120 5/28/2025
0.1.0-alpha.115 130 5/26/2025
0.1.0-alpha.114 130 5/22/2025
0.1.0-alpha.112 123 5/21/2025
0.1.0-alpha.111 133 5/20/2025
0.1.0-alpha.108 130 5/19/2025
0.1.0-alpha.104 189 5/18/2025
0.1.0-alpha.102 210 5/14/2025
0.1.0-alpha.101 207 5/14/2025
0.1.0-alpha.100 211 5/12/2025
0.1.0-alpha.99 203 5/12/2025
0.1.0-alpha.98 48 5/10/2025
0.1.0-alpha.97 50 5/10/2025
0.1.0-alpha.86 126 5/8/2025
0.1.0-alpha.85 123 5/8/2025
0.1.0-alpha.84 124 5/8/2025
0.1.0-alpha.82 128 5/7/2025
0.1.0-alpha.81 126 5/6/2025
0.1.0-alpha.76 56 5/3/2025
0.1.0-alpha.75 79 5/2/2025
0.1.0-alpha.74 78 5/2/2025