Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .autover/changes/issue-2208-handler-configuration-docs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"Projects": [
{
"Name": "Amazon.Lambda.AspNetCoreServer.Hosting",
"Type": "Patch",
"ChangelogMessages": [
"Added Handler Configuration documentation explaining executable vs class library modes and Main(string[] args) pitfall"
]
}
]
}
36 changes: 35 additions & 1 deletion Libraries/src/Amazon.Lambda.AspNetCoreServer.Hosting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,38 @@ app.MapControllers();

app.Run();

```
```

## Handler Configuration

When deploying your Lambda function, the handler configuration depends on your project structure.

### Executable Mode (Recommended)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the README for Amazon.Lambda.AspNetCoreServer.Hosting which always has the Lambda function deployed as an executable. The doc update should be explaining how for this library the executable programming model is always used and the function handler must be set to the assembly name.

You can remove the Common Configuration Issue section because once they know to deploy as an executable that is a non-issue.


For executable mode, use `AssemblyName` as the handler (e.g., `MyLambdaProject`). This mode works with top-level statements or a `Main()` method without parameters. The Lambda runtime client handles event routing automatically.

### Class Library Mode

For class library mode, use `AssemblyName::ClassName::MethodName` as the handler. This mode works with traditional class-based handlers and uses reflection-based method invocation.

### Common Configuration Issue

When using `Main(string[] args)` with executable mode handler configuration, the Lambda runtime attempts to deserialize the incoming API Gateway event JSON into the `string[] args` parameter, which causes a `JsonSerializerException`.

Incorrect usage:
```csharp
static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
// ... rest of setup
}
```

Correct usage for executable mode:
```csharp
static void Main()
{
var builder = WebApplication.CreateBuilder();
// ... rest of setup
}
```