1

Recently amazon announced support for a custom .net core runtime: https://aws.amazon.com/blogs/developer/announcing-amazon-lambda-runtimesupport/

My current aws lambda project is written C# using the .NET Core 2.1; 2.2 is not supported yet hence I'd like to use custom runtime.

However, it seems that in order to use the custom runtime, it is necessary to use LambdaBootstrap. From the docs it is not clear to me if it is possible to use it alongside asp.net core: https://github.com/aws/aws-lambda-dotnet/tree/master/Libraries/src/Amazon.Lambda.RuntimeSupport

p.s. currently my aws lambda is using asp.net core for authentication and other

2
  • 1
    are you talking about running a webapp in parallel with the lamda? if so there are surely ways considering asp.net core runs as a console app but don't get why you would want to do it Commented Apr 20, 2019 at 1:59
  • thanks; I've edited my question to clarify my situation: my current aws lambda project is written C# using the .NET Core 2.1; 2.2 is not supported yet hence I'd like to use custom runtime. Commented Apr 20, 2019 at 3:17

1 Answer 1

2

Here's a good demo / tutorial that shows how the author approaches using the lambda bootstrap:

https://medium.com/@dimoss/asp-net-core-2-2-3-0-serverless-web-apis-in-aws-lambda-with-a-custom-runtime-and-lambda-warmer-ce19ce2e2c74

The author uses the following code to switch between local debugging and the lambda entry:

public class LocalEntryPoint
{
    private static readonly LambdaEntryPoint LambdaEntryPoint = new LambdaEntryPoint();
    private static readonly Func<APIGatewayProxyRequest, ILambdaContext, Task<APIGatewayProxyResponse>> Func = LambdaEntryPoint.FunctionHandlerAsync;

    public static async Task Main(string[] args)
    {
#if DEBUG
        BuildWebHost(args).Run();
#else
        // Wrap the FunctionHandler method in a form that LambdaBootstrap can work with.
        using (var handlerWrapper = HandlerWrapper.GetHandlerWrapper(Func, new JsonSerializer()))

        // Instantiate a LambdaBootstrap and run it.
        // It will wait for invocations from AWS Lambda and call the handler function for each one.
        using (var bootstrap = new LambdaBootstrap(handlerWrapper))
        {
            await bootstrap.RunAsync();
        }
#endif
    }

    public static IWebHost BuildWebHost(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseStartup<Startup>()
            .Build();
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.