Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot start lambda with Mock Lambda Test Tool

Tags:

c#

aws-lambda

I've been working with AWS lambdas for a few months. I was working with a lambda and it was fine at the end of the day. I came back to work on it the next day, and I can't get Visual Studio to even start the application using the Mock Lambda Test Tool.

I ended up creating an empty lambda that just returns the input (the standard project code that AWS gives you as a template) and that won't even run. I hit the play button to star the Mock Lambda Test Tool, it looks like it will run for a couple seconds, then it closes down. The command window does not even pop up.

This is the code from the template project.

public string FunctionHandler(string input, ILambdaContext context)
{
    return input?.ToUpper();
}

This is all I get in the output window of VS:

The target process exited without raising a CoreCLR started event. Ensure that the target process is configured to use .NET Core. This may be expected if the target process did not run on .NET Core. The program '[16700] dotnet-lambda-test-tool-2.1.exe: Program Trace' has exited with code 0 (0x0). The program '[16700] dotnet-lambda-test-tool-2.1.exe' has exited with code -2147450726 (0x8000809a).

I have tried re-installing the AWS toolkit, and also tried re-installing Visual Studio. This is an issue with VS 2017 and VS 2019. I just installed 2019 to see if that would fix the issue. Any help would be appreciated.

like image 709
Ryan Avatar asked Nov 26 '25 02:11

Ryan


2 Answers

I have seen this issue many time on my system with dotnet-lambda-test-tool-6.0. Only one fix work for me

  1. Remove dotnet-lambda-test-tool-6.0.exe from C:\Users\username.dotnet\tools
  2. Open Command prompt from C:\Users\username.dotnet\tools
  3. run command dotnet tool install -g Amazon.Lambda.TestTool-6.0
like image 149
Pankaj Rawat Avatar answered Nov 27 '25 14:11

Pankaj Rawat


I came to this question having the very same issue. After installing AWS Toolkit I found that the lambda test tool was not installed and therefore I got the same error just as the OP. The only difference is that I was targeting .Net Core 3.1 and therefore I needed amazon.lambda.testool-3.1. However this answer should work for both scenarios.

Unfortunately I did not have the same luck as the OP of having a nice co-worker that could give me the files I needed. So, if this is also your case please continue reading.

In the official project site, which can be found here, there are the instructions to install the tools. It also says that installing the latest version of AWS Toolkit should be enough to have the tools installed (it was not in my case and probably in yours).

It says that in order to install the tools you should run the following commands:

dotnet tool install -g Amazon.Lambda.TestTool-3.1

or

dotnet tool install -g Amazon.Lambda.TestTool-2.1

depending on which tool you need.

However, running these commands fails with the following message:

The tool package could not be restored. Tool 'amazon.lambda.testtool-2.1' failed to install. This failure may have been caused by:

* You are attempting to install a preview release and did not use the --version option to specify the version.
* A package by this name was found, but it was not a .NET Core tool.
* The required NuGet feed cannot be accessed, perhaps because of an Internet connection problem.
* You mistyped the name of the tool.

For more reasons, including package naming enforcement, visit https://aka.ms/failure-installing-tool

And since the project is still in preview I just had to find the latest stable version in order to specify it in the command. For .net core 3.1 here is the nuget site, there I found version 0.10 to be the latest, so the command should look like:

dotnet tool install -g --version 0.10 Amazon.Lambda.TestTool-3.1
like image 25
taquion Avatar answered Nov 27 '25 14:11

taquion



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!