aws / aws-lambda-dotnet

Libraries, samples and tools to help .NET Core developers develop AWS Lambda functions.
Apache License 2.0
1.58k stars 478 forks source link

New Serverless Templates don't include EntryPoint cs files or startup.cs, How can I test locally with postman? #808

Closed ajmcateer closed 3 years ago

ajmcateer commented 3 years ago

I am fairly new to ASP.net Core and very new to AWS Lambdas

I am using the latest Serverless application template in Visual Studio 2019, It came with just the following relevant files

I figured out how to add configuration in serverless.template to point to different class for lambda functions and how to add multiple functions per file. I am currently testing locally with the Mock Lambda Test Tool, but would like to use Postman. I see references to being able to run the program locally using IIS or Kestrel. but they all refer to several files that don't exist

As far as I can tell they may have been part of the template for 2.1 but not certian.

Do I need to create these files myself? If so where is the documentation on how to do it? Is there a different/better way to test the Lambda functions locally using postman?

The Lambda Test Tool is nice and if I have to use it I can but being able to use Postman would be great.

ashishdhingra commented 3 years ago

Hi @ajmcateer,

Good morning.

Thanks for posting the guidance question. Looks like you are using the EmptyFunction template instead of serverless template. Here are the templates for .NET 5 that get installed with .NET CLI after you install using dotnet new -i Amazon.Lambda.Templates:

Lambda Empty Function (.NET 5 Container Image)            lambda.image.EmptyFunction                        [C#], F#          AWS/Lambda/Function   
Lambda ASP.NET Core Web API (.NET 5 Container Image)      serverless.image.AspNetCoreWebAPI                 [C#], F#          AWS/Lambda/Serverless 
Lambda Empty Serverless (.NET 5 Container Image)          serverless.image.EmptyServerless                  [C#], F#          AWS/Lambda/Serverless

When I use command dotnet new serverless.image.AspNetCoreWebAPI, following files are generated:

AWSServerlessNET5.csproj    LambdaEntryPoint.cs     Startup.cs          aws-lambda-tools-defaults.json
Controllers         LocalEntryPoint.cs      appsettings.Development.json    serverless.template
Dockerfile          Readme.md           appsettings.json

If you are using Visual Studio 2019 on Windows, the following templates are available after you install latest version of AWS Toolkit for VS:

Screen Shot 2021-02-12 at 10 26 25 AM

Kindly note that you would need Docker installed to run it locally (which I guess you already have since you are able to debug using Mock Lambda test tool), just mentioning here.

Hope this helps and kindly confirm if this issue could be closed.

Thanks, Ashish

github-actions[bot] commented 3 years ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.