![]() |
VOOZH | about |
dotnet add package AWSLambda.AspNetCoreAppMesh --version 1.0.6.1
NuGet\Install-Package AWSLambda.AspNetCoreAppMesh -Version 1.0.6.1
<PackageReference Include="AWSLambda.AspNetCoreAppMesh" Version="1.0.6.1" />
<PackageVersion Include="AWSLambda.AspNetCoreAppMesh" Version="1.0.6.1" />Directory.Packages.props
<PackageReference Include="AWSLambda.AspNetCoreAppMesh" />Project file
paket add AWSLambda.AspNetCoreAppMesh --version 1.0.6.1
#r "nuget: AWSLambda.AspNetCoreAppMesh, 1.0.6.1"
#:package AWSLambda.AspNetCoreAppMesh@1.0.6.1
#addin nuget:?package=AWSLambda.AspNetCoreAppMesh&version=1.0.6.1Install as a Cake Addin
#tool nuget:?package=AWSLambda.AspNetCoreAppMesh&version=1.0.6.1Install as a Cake Tool
You have a fleet of serverless ASP.NET Core apps configured as AWS Lambda functions. While AmazonLambdaClient.InvokeAsync() found in the AWSSDK.Lambda is a one way to achieve inter-Lambda communication, the method does not work for invocation of Lambdas running on your local machine. This library aims to fill this functionality gap by marshalling your requests using Kestrel when your ASP.NET Core lambdas are being debugged locally.
Say you have an existing Invoke code such as this:
var invokeReq = new InvokeRequest();
invokeReq.FunctionName = "MyLambdaFunction";
invokeReq.InvocationType = InvocationType.RequestResponse;
// ... other params
var apiGatewayReq = new APIGatewayProxyRequest()
{
HttpMethod = "GET",
Path = "/home/index"
};
invokeReq.Payload = JsonSerializer.Serialize(apiGatewayReq);
var lambdaClient = new AmazonLambdaClient(); // region, creds
var resp = await lambdaClient.InvokeAsync(invokeReq); // When running in AWS environment
// --- OR, WHEN DEBUGGING LOCALLY ---
// This will route the request to MyLambdaFunction running on your local machine
resp = await invokeReq.RouteAPIGatewayProxyRequestLocally();
Catalog Tool keeps track of all the running Lambda ASP.NET Core Applications on your local machine that register to recieve incoming InvokeRequest requests.
dotnet tool install -g AWSLambda.AspNetCoreAppMesh.Catalog
/* or to update */
dotnet tool update -g AWSLambda.AspNetCoreAppMesh.Catalog
Run the Catalog Tool
dotnet lambda-app-mesh --urls http://localhost:5050
The --urls param is optional. The tool will listen on port 5000 and 5001 by default.
Once the Catalog Tool is running, your ASP.NET Core applications will be able to register themselves with the catalog. Ensure the catalog url is resolvable and reachable by your applications.
See full Catalog Tool Documentation
InvokeRequest objects locallyIn Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddAWSLambdaAppMeshClient(opts =>
{
opts.LambdaName = "MyAspNetCoreLambda"; // name of your Lambda function
opts.CatalogUrl = "http://localhost:5050"; // URL the Catalog Tool (dotnet lambda-app-mesh) is listening on
});
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseAWSLambdaAppMeshClient();
}
Now, you can call RouteAPIGatewayProxyRequestLocally() on your InvokeRequest requests. In order for InvokeRequest to be processed, the receiver ASP.NET Core Lambda must be running on your machine, and must have registered with the Catalog tool.
InvokeRequest requestsIt is assumed that your ASP.NET Core Lambda applications are configured to run using Kestrel when debugging locally. If you are running the app using IIS or IIS Express then the incoming requests will fail to process properly.
Ensure the Catalog Tool (dotnet lambda-app-mesh) is running prior to launching your ASP.NET Core apps. Otherwise, you'll get an exception when trying to register with the catalog.
In Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddAPIGatewayProxyFunctionEntryPoint<LambdaEntryPoint>(); // your APIGatewayProxyFunction entry point
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.HandleIncomingAWSLambdaInvokeRequests(env);
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp3.1 netcoreapp3.1 is compatible. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
v1.0.6 - .NET Core 3.1 support (coinciding with https://aws.amazon.com/blogs/compute/announcing-aws-lambda-supports-for-net-core-3-1/)
v1.0.5 - Corrected a few error messages
v1.0.4 - Fixed issue with circular host registration
v1.0.3 - Improved ApplicationUrl discovery
v1.0.2 - Friendlier error messages
v1.0.1 - Intital Release