NET 6 REST API Service as a Lambda: error during the query

0

I have created the NET 6 service using AWS SDK Template. It works fine in Windows. I have deployed it to AWS Lambda. It starts ok, It should show Swagger UI but I see logs with an unknown error:

2023-03-01T16:31:11.189+01:00 INIT_START Runtime Version: dotnet:6.v13 Runtime Version ARN: arn:aws:lambda:eu-central-1::runtime:699f346a05dae24c58c45790bc4089f252bf17dae3997e79b17d939a288aa1ec

2023-03-01T16:31:12.074+01:00 2023-03-01T15:31:12.063Z [Information] Microsoft.Hosting.Lifetime: Application started. Press Ctrl+C to shut down.

2023-03-01T16:31:12.076+01:00 2023-03-01T15:31:12.075Z [Information] Microsoft.Hosting.Lifetime: Hosting environment: Production

2023-03-01T16:31:12.076+01:00 2023-03-01T15:31:12.076Z [Information] Microsoft.Hosting.Lifetime: Content root path: /var/task

2023-03-01T16:31:12.159+01:00 START RequestId: c497c0cb-a7e7-49e3-b289-f924b17fd4ab Version: $LATEST

2023-03-01T16:31:12.451+01:00

Copy 2023-03-01T15:31:12.450Z c497c0cb-a7e7-49e3-b289-f924b17fd4ab fail System.NullReferenceException: Object reference not set to an instance of an object. 2023-03-01T15:31:12.450Z c497c0cb-a7e7-49e3-b289-f924b17fd4ab fail System.NullReferenceException: Object reference not set to an instance of an object.

What should I check and how to fix it?

Oleg
gefragt vor einem Jahr206 Aufrufe
1 Antwort
0

This is most commonly caused by referencing a null object in your code. For Example:

public class MyClass { public int id {get; set;} }

MyClass myClass; myClass.Id = 0; // Null reference because it has not been instantiated.

//Working code MyClass myClass = new MyClass(); // new MyClass(); instantiates the object. myClass.Id = 0; // Works because the myClass has been instantiated.

Since you say it works locally, Could there be a permission missing on lambda that is preventing an object from instantiating like it normally would with your local permissions? I would check that first.

beantwortet vor einem Jahr

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen