Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
532e937
Add AWS Lambda guide
KubaZ2 Jun 17, 2026
b861aa3
Merge branch 'main' into feature/aws-lambda-guide
KubaZ2 Jun 17, 2026
b010cd3
Merge branch 'main' into feature/aws-lambda-guide
KubaZ2 Jun 18, 2026
402b8ff
Merge branch 'main' into feature/aws-lambda-guide
KubaZ2 Jun 18, 2026
aba71fb
Merge branch 'main' into feature/aws-lambda-guide
KubaZ2 Jun 20, 2026
8f5013c
Merge branch 'main' into feature/aws-lambda-guide
KubaZ2 Jun 21, 2026
5024fbb
Add Azure Functions guide
KubaZ2 Jun 22, 2026
d1a72aa
Add local.settings.json
KubaZ2 Jun 23, 2026
2d0e42c
Fix REGISTER_COMMANDS value
KubaZ2 Jun 23, 2026
d93554e
Merge main
KubaZ2 Jun 23, 2026
ac841cb
Merge main
KubaZ2 Jul 8, 2026
16e8bf2
Merge branch 'main' into feature/aws-lambda-guide
KubaZ2 Jul 13, 2026
e1cb626
Merge branch 'main' into feature/aws-lambda-guide
KubaZ2 Jul 13, 2026
db247c4
Merge branch 'main' into feature/aws-lambda-guide
KubaZ2 Aug 27, 2026
cf96e10
Fix azure lambda example
KubaZ2 Aug 27, 2026
c975086
Merge branch 'main' into feature/aws-lambda-guide
KubaZ2 Aug 27, 2026
c4d363d
Merge branch 'main' into feature/aws-lambda-guide
KubaZ2 Sep 6, 2026
9b3b508
Improve formatting of HTTP event code
KubaZ2 Sep 7, 2026
bc2c986
Add Webhook Events to AWS Lambda and Azure Function guides
KubaZ2 Sep 7, 2026
3eab9b2
Improve examples
KubaZ2 Sep 7, 2026
ff1c3de
Improve HTTP events introduction guide
KubaZ2 Sep 7, 2026
36abef1
Improve introduction guide
KubaZ2 Sep 7, 2026
3e1a037
Add more examples to introduction guide
KubaZ2 Sep 7, 2026
2ec2558
Split introduction guide into separate guides
KubaZ2 Sep 7, 2026
0632b80
Improve http event guides
KubaZ2 Sep 8, 2026
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
13 changes: 9 additions & 4 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<Project>

<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
</PropertyGroup>

<ItemGroup>
<PackageVersion Include="Azure.Monitor.OpenTelemetry.Exporter" Version="1.8.1" />
<PackageVersion Include="coverlet.collector" Version="10.0.1" />
<PackageVersion Include="libsodium" Version="1.0.22" />
<PackageVersion Include="Microsoft.ApplicationInsights.WorkerService" Version="3.1.2" />
<PackageVersion Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="2.51.0" />
<PackageVersion Include="Microsoft.Azure.Functions.Worker.OpenTelemetry" Version="1.2.0" />
<PackageVersion Include="Microsoft.Bcl.HashCode" Version="6.0.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="5.9.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="5.9.0" />
Expand All @@ -23,6 +25,9 @@
<PackageVersion Include="MSTest.TestAdapter" Version="4.3.3" />
<PackageVersion Include="MSTest.TestFramework" Version="4.3.3" />
<PackageVersion Include="PolySharp" Version="1.16.0" />
<PackageVersion Include="Amazon.Lambda.AspNetCoreServer.Hosting" Version="1.10.0" />
<PackageVersion Include="Microsoft.Azure.Functions.Worker" Version="2.52.0" />
<PackageVersion Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="2.1.0" />
<PackageVersion Include="Microsoft.Azure.Functions.Worker.Sdk" Version="2.0.7" />
</ItemGroup>

</Project>
</Project>
53 changes: 0 additions & 53 deletions Documentation/guides/basic-concepts/http-interactions.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<AWSProjectType>Lambda</AWSProjectType>

<!-- This property makes the build directory similar to a publish directory and helps the AWS .NET Lambda Mock Test Tool find project dependencies. -->
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

<!-- Generate ready to run images during publishing to improvement cold starts. -->
<!-- <PublishReadyToRun>true</PublishReadyToRun> -->

<PublishAot>true</PublishAot>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Amazon.Lambda.AspNetCoreServer.Hosting" />
<PackageReference Include="libsodium" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\Hosting\NetCord.Hosting.AspNetCore\NetCord.Hosting.AspNetCore.csproj" />
<ProjectReference Include="..\..\..\..\Hosting\NetCord.Hosting.Services\NetCord.Hosting.Services.csproj" />
<ProjectReference Include="..\..\..\..\NetCord\NetCord.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
...
+ <PublishAot>true</PublishAot>
- <!-- Generate ready to run images during publishing to improvement cold starts. -->
- <PublishReadyToRun>true</PublishReadyToRun>
</PropertyGroup>
...
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using NetCord.Hosting.Services.ApplicationCommands;
using NetCord.Hosting.AspNetCore;
using NetCord.Hosting.Rest;

using Amazon.Lambda.Serialization.SystemTextJson;
using Amazon.Lambda.APIGatewayEvents;

using System.Text.Json.Serialization;

var registerCommands = args.Contains("--register-commands");

var builder = WebApplication.CreateSlimBuilder(args);

builder.Services
.AddDiscordRest()
.AddHttpApplicationCommands(o => o.AutoRegisterCommands = registerCommands)
.AddAWSLambdaHosting(LambdaEventSource.HttpApi,
// That is only required when using Native AOT,
// otherwise that parameter can be omitted
new SourceGeneratorLambdaJsonSerializer<APIGatewaySerializerContext>());

var app = builder.Build();

app.AddSlashCommand("ping", "Ping AWS Lambda", () => "Pong from AWS Lambda!");

if (registerCommands)
{
await app.StartAsync();
await app.StopAsync();
return;
}

app.UseHttpInteractions("/");

await app.RunAsync();

// That is passed to AddAWSLambdaHosting for Native AOT,
// otherwise that class can be omitted
[JsonSerializable(typeof(APIGatewayHttpApiV2ProxyRequest))]
[JsonSerializable(typeof(APIGatewayHttpApiV2ProxyResponse))]
public partial class APIGatewaySerializerContext : JsonSerializerContext;
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# ASP.NET Core Minimal API Serverless Application

This project shows how to run an ASP.NET Core Web API project as an AWS Lambda exposed through Amazon API Gateway. The NuGet package [Amazon.Lambda.AspNetCoreServer](https://www.nuget.org/packages/Amazon.Lambda.AspNetCoreServer) contains a Lambda function that is used to translate requests from API Gateway into the ASP.NET Core framework and then the responses from ASP.NET Core back to API Gateway.


For more information about how the Amazon.Lambda.AspNetCoreServer package works and how to extend its behavior view its [README](https://github.com/aws/aws-lambda-dotnet/blob/master/Libraries/src/Amazon.Lambda.AspNetCoreServer/README.md) file in GitHub.

## Executable Assembly ##

.NET Lambda projects that use C# top level statements like this project must be deployed as an executable assembly instead of a class library. To indicate to Lambda that the .NET function is an executable assembly the
Lambda function handler value is set to the .NET Assembly name. This is different then deploying as a class library where the function handler string includes the assembly, type and method name.

To deploy as an executable assembly the Lambda runtime client must be started to listen for incoming events to process. For an ASP.NET Core application the Lambda runtime client is started by included the
`Amazon.Lambda.AspNetCoreServer.Hosting` NuGet package and calling `AddAWSLambdaHosting(LambdaEventSource.HttpApi)` passing in the event source while configuring the services of the application. The
event source can be API Gateway REST API and HTTP API or Application Load Balancer.

### Project Files ###

* serverless.template - an AWS CloudFormation Serverless Application Model template file for declaring your Serverless functions and other AWS resources
* aws-lambda-tools-defaults.json - default argument settings for use with Visual Studio and command line deployment tools for AWS
* Program.cs - entry point to the application that contains all of the top level statements initializing the ASP.NET Core application.
The call to `AddAWSLambdaHosting` configures the application to work in Lambda when it detects Lambda is the executing environment.
* Controllers\CalculatorController - example Web API controller

You may also have a test project depending on the options selected.

## Here are some steps to follow from Visual Studio:

To deploy your Serverless application, right click the project in Solution Explorer and select *Publish to AWS Lambda*.

To view your deployed application open the Stack View window by double-clicking the stack name shown beneath the AWS CloudFormation node in the AWS Explorer tree. The Stack View also displays the root URL to your published application.

## Here are some steps to follow to get started from the command line:

Once you have edited your template and code you can deploy your application using the [Amazon.Lambda.Tools Global Tool](https://github.com/aws/aws-extensions-for-dotnet-cli#aws-lambda-amazonlambdatools) from the command line.

Install Amazon.Lambda.Tools Global Tools if not already installed.
```
dotnet tool install -g Amazon.Lambda.Tools
```

If already installed check if new version is available.
```
dotnet tool update -g Amazon.Lambda.Tools
```

Deploy application
```
cd "AWSLambda/src/AWSLambda"
dotnet lambda deploy-serverless
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"Information": [
"This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.",
"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.",
"dotnet lambda help",
"All the command line options for the Lambda command can be specified in this file."
],
"profile": "",
"region": "",
"configuration": "Release",
"s3-prefix": "AWSLambda/",
"template": "serverless.template",
"template-parameters": ""
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"AWSTemplateFormatVersion": "2010-09-09",
"Transform": "AWS::Serverless-2016-10-31",
"Description": "An AWS Serverless Application that uses the ASP.NET Core framework running in Amazon Lambda.",
"Parameters": {},
"Conditions": {},
"Resources": {
"AspNetCoreFunction": {
"Type": "AWS::Serverless::Function",
"Properties": {
"Handler": "MyBot",
"Runtime": "dotnet10",
"CodeUri": "",
"MemorySize": 512,
"Timeout": 30,
"Role": null,
"Policies": [
"AWSLambda_FullAccess"
],
"Events": {
"ProxyResource": {
"Type": "HttpApi",
"Properties": {
"Path": "/{proxy+}",
"Method": "ANY"
}
},
"RootResource": {
"Type": "HttpApi",
"Properties": {
"Path": "/",
"Method": "ANY"
}
}
}
}
}
},
"Outputs": {
"ApiURL": {
"Description": "API endpoint URL for Prod environment",
"Value": {
"Fn::Sub": "https://${ServerlessHttpApi}.execute-api.${AWS::Region}.amazonaws.com/"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
...
"Resources": {
"AspNetCoreFunction": {
...
"Properties": {
...
"Events": {
"ProxyResource": {
+ "Type": "HttpApi",
- "Type": "Api",
...
},
"RootResource": {
+ "Type": "HttpApi",
- "Type": "Api",
...
}
}
}
}
},
"Outputs": {
"ApiURL": {
...
"Value": {
+ "Fn::Sub": "https://${ServerlessHttpApi}.execute-api.${AWS::Region}.amazonaws.com/"
- "Fn::Sub": "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<AWSProjectType>Lambda</AWSProjectType>

<!-- This property makes the build directory similar to a publish directory and helps the AWS .NET Lambda Mock Test Tool find project dependencies. -->
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

<!-- Generate ready to run images during publishing to improvement cold starts. -->
<!-- <PublishReadyToRun>true</PublishReadyToRun> -->

<PublishAot>true</PublishAot>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Amazon.Lambda.AspNetCoreServer.Hosting" />
<PackageReference Include="libsodium" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\Hosting\NetCord.Hosting.AspNetCore\NetCord.Hosting.AspNetCore.csproj" />
<ProjectReference Include="..\..\..\..\Hosting\NetCord.Hosting.Services\NetCord.Hosting.Services.csproj" />
<ProjectReference Include="..\..\..\..\NetCord\NetCord.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
...
+ <PublishAot>true</PublishAot>
- <!-- Generate ready to run images during publishing to improvement cold starts. -->
- <PublishReadyToRun>true</PublishReadyToRun>
</PropertyGroup>
...
</Project>
Loading