I am finding it a challenge to properly package and deploy dotnet functions (using dotnet core 2.1 runtime) utilizing Serverless to AWS Lambda. I am not finding any examples other than ones that use the SAM and dotnet deploy lambda-serverless commands.
Using command line and Serverless, what needs to be done to properly deploy a dotnet core function to AWS Lambda? Is this even possible?
I was finally able to overcome my issues.
- cd into .csproj folder
dotnet lambda package using dotnet lambda tools
dotnet tool install -g Amazon.Lambda.Tools
- Assuming the rest of your serverless.ymal is set up correctly, make sure your serverless.yml has a package property with an artifact that points to the .zip file generated by dotnet lambda package, for example:
- You need a Lambda Entry Point class (e.g. LambdaEntryPoint.cs) that uses a Startup class:
public class LambdaEntryPoint : Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction
protected override void Init(IWebHostBuilder builder)
public class Startup
private readonly IConfiguration _configuration;
public Startup(IConfiguration configuration)
_configuration = configuration;
// This method gets called by the runtime. Use this method to add services to the container
public void ConfigureServices(IServiceCollection services)
/// This method gets called by the runtime. Use this method to configure the HTTP request pipeline
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
Note: some of this can be generated from templates.
- do a regular
Outside of what is readily available on the Internet, these steps highlight some of the hurdles I had to overcome to get mine working.