MyTypeScriptLibrary 1.0.0
dotnet add package MyTypeScriptLibrary --version 1.0.0
NuGet\Install-Package MyTypeScriptLibrary -Version 1.0.0
<PackageReference Include="MyTypeScriptLibrary" Version="1.0.0" />
<PackageVersion Include="MyTypeScriptLibrary" Version="1.0.0" />
<PackageReference Include="MyTypeScriptLibrary" />
paket add MyTypeScriptLibrary --version 1.0.0
#r "nuget: MyTypeScriptLibrary, 1.0.0"
#:package MyTypeScriptLibrary@1.0.0
#addin nuget:?package=MyTypeScriptLibrary&version=1.0.0
#tool nuget:?package=MyTypeScriptLibrary&version=1.0.0
ASP.NET Core Web 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 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 file in GitHub.
Configuring for API Gateway HTTP API
API Gateway supports the original REST API and the new HTTP API. In addition HTTP API supports 2 different
payload formats. When using the 2.0 format the base class of LambdaEntryPoint must be Amazon.Lambda.AspNetCoreServer.APIGatewayHttpApiV2ProxyFunction.
For the 1.0 payload format the base class is the same as REST API which is Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction.
Note: when using the AWS::Serverless::Function CloudFormation resource with an event type of HttpApi the default payload
format is 2.0 so the base class of LambdaEntryPoint must be Amazon.Lambda.AspNetCoreServer.APIGatewayHttpApiV2ProxyFunction.
Configuring for Application Load Balancer
To configure this project to handle requests from an Application Load Balancer instead of API Gateway change
the base class of LambdaEntryPoint from Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction to
Amazon.Lambda.AspNetCoreServer.ApplicationLoadBalancerFunction.
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
- LambdaEntryPoint.cs - class that derives from Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction. The code in this file bootstraps the ASP.NET Core hosting framework. The Lambda function is defined in the base class. Change the base class to Amazon.Lambda.AspNetCoreServer.ApplicationLoadBalancerFunction when using an Application Load Balancer.
- LocalEntryPoint.cs - for local development this contains the executable Main function which bootstraps the ASP.NET Core hosting framework with Kestrel, as for typical ASP.NET Core applications.
- Startup.cs - usual ASP.NET Core Startup class used to configure the services ASP.NET Core will use.
- appsettings.json - used for local development.
- Controllers\ValuesController - 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 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
Execute unit tests
cd "AWSServerless1/test/AWSServerless1.Tests"
dotnet test
Deploy application
cd "AWSServerless1/src/AWSServerless1"
dotnet lambda deploy-serverless
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 427 | 12/10/2024 |