Skip to content

Right way to get to ILambdaContext for AWS Serverless Application #1480

Answered by normj
genifycom asked this question in Q&A
Discussion options

You must be logged in to vote

If you need the request id inside the subclass of APIGatewayHttpApiV2ProxyFunction then you would need to override the PostMarshallItemsFeatureFeature method.

If you are looking to get ahold of the ILambdaContext inside the ASP.NET Core side of your function this code snippet shows you how to do it.

using Amazon.Lambda.Core;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddControllers();
builder.Services.AddAWSLambdaHosting(LambdaEventSource.RestApi);

var app = builder.Build();

app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();

app.MapGet("/", (HttpContext context) =>
{
    var lambdaContext = context.Items[Amazon.Lambda.AspNetCoreServer.Abs…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by ashishdhingra
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants