Skip to content

Commit 9ba3721

Browse files
committed
chore: added dotnet8 example
1 parent f592cac commit 9ba3721

File tree

8 files changed

+1285
-0
lines changed

8 files changed

+1285
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Library</OutputType> <!-- Ensure this is Library -->
4+
<TargetFramework>net8.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
8+
<AWSProjectType>Lambda</AWSProjectType>
9+
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
10+
<PublishReadyToRun>true</PublishReadyToRun>
11+
</PropertyGroup>
12+
<ItemGroup>
13+
<PackageReference Include="Amazon.Lambda.Core" Version="2.2.0" />
14+
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.4.0" />
15+
<PackageReference Include="Amazon.Lambda.APIGatewayEvents" Version="2.7.0" />
16+
</ItemGroup>
17+
</Project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"Information": [
3+
"This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.",
4+
"To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.",
5+
"dotnet lambda help",
6+
"All the command line options for the Lambda command can be specified in this file."
7+
],
8+
"profile": "",
9+
"region": "",
10+
"configuration": "Release",
11+
"framework": "net8.0",
12+
"function-runtime": "dotnet8",
13+
"function-architecture": "x86_64",
14+
"function-memory-size": 512,
15+
"function-timeout": 30
16+
}

examples/dotnet/build.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
# Install zip on Debian-based systems
4+
if [ -f /etc/debian_version ]; then
5+
apt -qq update
6+
apt -qq -y install zip
7+
8+
# Install required tools if not installed
9+
dotnet tool list -g | grep -q Amazon.Lambda.Tools
10+
if [ $? -ne 0 ]; then
11+
dotnet tool install -g Amazon.Lambda.Tools
12+
fi
13+
14+
# Ensure the global tools path is accessible
15+
export PATH="$PATH:/root/.dotnet/tools"
16+
fi
17+
18+
dotnet restore
19+
# update the dotnet framework as per your project and ensure the global tools path is accessible
20+
dotnet lambda package --configuration Debug --framework net8.0 --output-package newrelic-serverless-dotnet-example.zip

examples/dotnet/handler.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using Amazon.Lambda.Core;
2+
using System.Threading.Tasks;
3+
[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))]
4+
5+
namespace NewrelicExample;
6+
7+
public class Function
8+
{
9+
public async Task<string> FunctionHandler(ILambdaContext context)
10+
{
11+
await Task.Delay(1000); // Simulate some async work
12+
return "Hello, World!";
13+
}
14+
}

0 commit comments

Comments
 (0)