Reputation: 8584
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
Upvotes: 1
Views: 1875
Reputation: 5476
Here's a good demo / tutorial that shows how the author approaches using the lambda bootstrap:
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();
}
Upvotes: 2