Integration Options

Serverless Framework
AWS SAM
Programmatic Configuration

Step 1: Add Thundra NuGet package

The .NET Thundra agent can simply be downloaded with the command below:

dotnet add package Thundra.Agent.Lambda --version 1.4.1

Similarly, including agent can be done via the NuGet Package Manager of your IDE if it is available. For example, Visual Studio allows you to add packages through the IDE itself, and a simple search of Thundra .NET will allow you to procure the correct agent to be added to your project.

Step 2: Change serverless.yml

You should replace all your handler to “Thundra.Agent.Lambda::Thundra.Agent.Lambda.Core.ThundraProxy::Handle” and give the real handler path as environment variable separately.

serverless.yml
...
functions:
FirstFunction:
handler: Thundra.Agent.Lambda::Thundra.Agent.Lambda.Core.ThundraProxy::Handle
environment:
thundra_agent_lambda_handler: <your_handler>
thundra_apiKey: <your_api_key>
SecondFunction:
handler: Thundra.Agent.Lambda::Thundra.Agent.Lambda.Core.ThundraProxy::Handle
environment:
thundra_agent_lambda_handler: <your_second_handler>
thundra_apiKey: <your_api_key>
...

Thanks to this method, you can connect Thundra to your functions by modifying the configuration files without changing code. The ThundraProxy class will call the actual handler as soon as it receives the request.

Step 1: Add Thundra NuGet package

The .NET Thundra agent can simply be downloaded with the command below:

dotnet add package Thundra.Agent.Lambda --version 1.4.1

Similarly, including agent can be done via the NuGet Package Manager of your IDE if it is available. For example, Visual Studio allows you to add packages through the IDE itself, and a simple search of Thundra .NET will allow you to procure the correct agent to be added to your project.

Step 2: Change template.yaml

You should replace all your handler to “Thundra.Agent.Lambda::Thundra.Agent.Lambda.Core.ThundraProxy::Handle” and give the real handler path as environment variable separately.

template.yaml
....
FirstFunction:
Type: AWS::Serverless::Function
Properties:
Handler: Thundra.Agent.Lambda::Thundra.Agent.Lambda.Core.ThundraProxy::Handle
Environment:
Variables:
thundra_agent_lambda_handler: <your_handler>
thundra_apiKey: <your_api_key>
SecondFunction:
Type: AWS::Serverless::Function
Properties:
Handler: Thundra.Agent.Lambda::Thundra.Agent.Lambda.Core.ThundraProxy::Handle
Environment:
Variables:
thundra_agent_lambda_handler: <your_second_handler>
thundra_apiKey: <your_api_key>
...

Thanks to this method, you can connect Thundra to your functions by modifying the configuration files without changing code. The ThundraProxy class will call the actual handler as soon as it receives the request.

Step 1: Add Thundra NuGet package

The .NET Thundra agent can simply be downloaded with the command below:

dotnet add package Thundra.Agent.Lambda --version 1.4.1

Similarly, including agent can be done via the NuGet Package Manager of your IDE if it is available. For example, Visual Studio allows you to add packages through the IDE itself, and a simple search of Thundra .NET will allow you to procure the correct agent to be added to your project.

Step 2: Change Handler's code

You should extend Thundra's LambdaRequestHandler within your handler class and override the DoHandleRequest method which encapsulates your handler code. LambdaRequestHandler takes two Generic classes as parameters: the request object's type and the response object's type.

Function.cs
using Amazon.Lambda.Core;
using Thundra.Agent.Lambda.Core;
namespace ThundraSample
{
public class Function : LambdaRequestHandler<string, string>
{
/// <summary>
/// Handler class needs to extend `LambdaRequestHandler< Request, Response >`
/// Please write all code within the DoHandleRequest method
/// </summary>
/// <param name="request"></param>
/// <param name="context"></param>
/// <returns>/Greeting Message/</returns>
public override string DoHandleRequest(string request, ILambdaContext context)
{
return "Hello Thundra";
}
}
}

Step 3: Change Your Handler to Thundra's HandleRequest

Next, you should change your handler to <MyAssembly>::<MyNamespace>.<MyClass>::HandleRequest.

It is a common mistake to point the hook method DoHandleRequest as the handler. In order to Thundra initialize you must change your handler to HandleRequest which resides in the base class(LambdaRequestHandler).