---
title: "AWS Lambda"
description: "Learn about Sentry's .NET integration with AWS Lambda and ASP.NET Core."
url: https://docs.sentry.io/platforms/dotnet/guides/aws-lambda/
---

# AWS Lambda | Sentry for AWS Lambda

Sentry provides an integration with AWS Lambda ASP.NET Core Server through the [Sentry.AspNetCore NuGet package](https://www.nuget.org/packages/Sentry.AspNetCore).

## [Features](https://docs.sentry.io/platforms/dotnet/guides/aws-lambda.md#features)

In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](https://docs.sentry.io/concepts/key-terms/tracing.md).

Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below.

## [Install](https://docs.sentry.io/platforms/dotnet/guides/aws-lambda.md#install)

Error Monitoring\[ ]Tracing

Add the Sentry dependency:

```powershell
Install-Package Sentry.AspNetCore -Version 6.3.0
```

You can combine this integration with a logging library like `log4net`, `NLog`, or `Serilog` to include both request data as well as your logs as breadcrumbs. The logging ingrations also capture events when an error is logged.

## [Configure](https://docs.sentry.io/platforms/dotnet/guides/aws-lambda.md#configure)

All `ASP.NET Core` configurations are valid here. But one configuration in particular is relevant.

`FlushOnCompletedRequest` ensures all events are flushed out. This is because the general ASP.NET Core hooks for when the process is exiting are not guaranteed to run in a serverless environment. This setting ensures that no event is lost if AWS recycles the process.

```csharp
public class LambdaEntryPoint : Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction
{
    protected override void Init(IWebHostBuilder builder)
    {
        builder
            // Add Sentry
            .UseSentry(options =>
            {
                options.Dsn = "___PUBLIC_DSN___";
                // When configuring for the first time, to see what the SDK is doing:
                o.Debug = true;
                // Adds request URL and headers, IP and name for users, etc.
                o.SendDefaultPii = true;
                // ___PRODUCT_OPTION_START___ performance
                // Set TracesSampleRate to 1.0 to capture 100%
                // of transactions for tracing.
                // We recommend adjusting this value in production
                o.TracesSampleRate = 1.0;
                // ___PRODUCT_OPTION_END___ performance
                // Required in Serverless environments
                options.FlushOnCompletedRequest = true;
            })
            .UseStartup<Startup>();
    }
}
```

Check out the [Sentry ASP.NET Core](https://docs.sentry.io/platforms/dotnet/guides/aspnetcore.md) documentation for the complete set of options.

## [Verify](https://docs.sentry.io/platforms/dotnet/guides/aws-lambda.md#verify)

This snippet includes an intentional error, so you can test that everything is working as soon as you set it up.

```csharp
try
{
    throw null;
}
catch (Exception ex)
{
    SentrySdk.CaptureException(ex);
}
```

## [Samples](https://docs.sentry.io/platforms/dotnet/guides/aws-lambda.md#samples)

* Our [samples on GitHub](https://github.com/getsentry/sentry-dotnet/tree/main/samples/Sentry.Samples.Aws.Lambda.AspNetCoreServer) demonstrate Sentry on AWS Lambda. (**C#**)

## [Next Steps](https://docs.sentry.io/platforms/dotnet/guides/aws-lambda.md#next-steps)

* Explore [practical guides](https://docs.sentry.io/guides.md) on what to monitor, log, track, and investigate after setup

## Other .NET Frameworks

- [.NET for Android](https://docs.sentry.io/platforms/dotnet/guides/android.md)
- [.NET for iOS, macOS, and Mac Catalyst](https://docs.sentry.io/platforms/dotnet/guides/apple.md)
- [ASP.NET](https://docs.sentry.io/platforms/dotnet/guides/aspnet.md)
- [ASP.NET Core](https://docs.sentry.io/platforms/dotnet/guides/aspnetcore.md)
- [Azure Functions](https://docs.sentry.io/platforms/dotnet/guides/azure-functions-worker.md)
- [Blazor WebAssembly](https://docs.sentry.io/platforms/dotnet/guides/blazor-webassembly.md)
- [Entity Framework](https://docs.sentry.io/platforms/dotnet/guides/entityframework.md)
- [Google Cloud Functions](https://docs.sentry.io/platforms/dotnet/guides/google-cloud-functions.md)
- [log4net](https://docs.sentry.io/platforms/dotnet/guides/log4net.md)
- [MAUI](https://docs.sentry.io/platforms/dotnet/guides/maui.md)
- [Microsoft.Extensions.Logging](https://docs.sentry.io/platforms/dotnet/guides/extensions-logging.md)
- [NLog](https://docs.sentry.io/platforms/dotnet/guides/nlog.md)
- [Serilog](https://docs.sentry.io/platforms/dotnet/guides/serilog.md)
- [Windows Forms](https://docs.sentry.io/platforms/dotnet/guides/winforms.md)
- [WinUI](https://docs.sentry.io/platforms/dotnet/guides/winui.md)
- [WPF](https://docs.sentry.io/platforms/dotnet/guides/wpf.md)
- [Xamarin](https://docs.sentry.io/platforms/dotnet/guides/xamarin.md)

## Topics

- [Capturing Errors](https://docs.sentry.io/platforms/dotnet/guides/aws-lambda/usage.md)
- [Enriching Events](https://docs.sentry.io/platforms/dotnet/guides/aws-lambda/enriching-events.md)
- [Extended Configuration](https://docs.sentry.io/platforms/dotnet/guides/aws-lambda/configuration.md)
- [Logs](https://docs.sentry.io/platforms/dotnet/guides/aws-lambda/logs.md)
- [Data Management](https://docs.sentry.io/platforms/dotnet/guides/aws-lambda/data-management.md)
- [Tracing](https://docs.sentry.io/platforms/dotnet/guides/aws-lambda/tracing.md)
- [Security Policy Reporting](https://docs.sentry.io/platforms/dotnet/guides/aws-lambda/security-policy-reporting.md)
- [Crons](https://docs.sentry.io/platforms/dotnet/guides/aws-lambda/crons.md)
- [Migration Guide](https://docs.sentry.io/platforms/dotnet/guides/aws-lambda/migration.md)
- [Troubleshooting](https://docs.sentry.io/platforms/dotnet/guides/aws-lambda/troubleshooting.md)
- [User Feedback](https://docs.sentry.io/platforms/dotnet/guides/aws-lambda/user-feedback.md)
- [Metrics](https://docs.sentry.io/platforms/dotnet/guides/aws-lambda/metrics.md)
- [Unit Testing](https://docs.sentry.io/platforms/dotnet/guides/aws-lambda/unit-testing.md)
- [Legacy SDK](https://docs.sentry.io/platforms/dotnet/guides/aws-lambda/legacy-sdk.md)
