Debug C# AWS Lambda Function Locally

Question:

I’ve been reviewing Amazon’s documentation for C# and Lambda. I’ve tried using their yeoman generator and Toolkit for Visual Studio. My goal is to simply have a project that holds multiple functions that I can debug on my local machine. The problem is that running the debugger gives me a message about not having an entry point into the project, which makes sense given it’s created as a class library.

From what I’m seeing, it looks like the development process is to write your code, deploy and run the function on AWS. Debugging would be reviewing the output from that and going from there. Is there a way to actually use the built-in debugger for Visual Studio, though? Better yet, I’d like a workflow for local debugging on my Mac. For example, in NodeJS, I can use the Serverless framework and set my launch.json file in VS Code to the following:

This allows me to mock data and use breakpoints for debugging.

Answer:

I haven’t followed this guide, but it seems to talk about how to debug locally. It does go further into actually setting up on AWS if needed:

https://cloudncode.blog/2017/01/24/getting-started-with-writing-and-debugging-aws-lambda-function-with-visual-studio-code/

From the gist of it, it seems that you setup a Main entry point for your Lambda class that loads a test file from JSON. This is similar to how you would setup tests of your Lambda function on AWS.

Leave a Reply