2

I've created a simple empty AWS Lambda function using .Net Core 2.1 :

enter image description here

Here is the folder structure :

enter image description here

(here is the csproj)

And a FunctionHandler which gets DI and invoke some dummy method :

enter image description here

Now let's run the "Mock Lambda Test Tool" , we can see that it works :

enter image description here

So where is the problem?

I've read here that 2.2 is supported :

This means you can now author Lambda functions using .NET Core 2.2 and .NET Core 3.0 preview. Amazon.Lambda.RuntimeSupport is available as source code on GitHub, or as a NuGet package.

And so , I've created a new empty lambda project but with 2.2 :

enter image description here

Same code. But now when I run "Mock Lambda Test Tool" , I get an error :

AWS .NET Mock Lambda Test Tool (0.9.2) Unknown error occurred causing process exit: Failed to find a deps.json file at Amazon.Lambda.TestTool.Runtime.LocalLambdaRuntime.Initialize(String directory) in E:\JenkinsWorkspaces\Lam\LambdaSandboxCoreCLRApi\Tools\LambdaTestTool\Amazon.Lambda.TestTool\Runtime\LocalLambdaRuntime.cs:line 50 at Amazon.Lambda.TestTool.Program.Main(String[] args) in E:\JenkinsWorkspaces\Lam\LambdaSandboxCoreCLRApi\Tools\LambdaTestTool\Amazon.Lambda.TestTool\Program.cs:line 46 Press any key to exit

Here is the error :

enter image description here

Question:

Why is that? I didn't have any deps.json file in 2.1 .

So why do I need it in 2.2 ? Also, what is this path appearing in the error: E:\JenkinsWorkspaces... ? I don't have Jenkins nor something like it.

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
Royi Namir
  • 144,742
  • 138
  • 468
  • 792
  • 1
    Do you have your deps.json file when you publish, does it make it (gets copied) to amazon? – Ilya Chernomordik Jun 16 '19 at 15:00
  • 1
    @IlyaChernomordik I'm not publishing yet. I'm in a phase where I run the mock test tool in visual studio. in 2.1 it does work but in 2.2 it doesn't. ( meaning I can run the test tool in 2.1 project , but not in 2.2)https://i.imgur.com/Jd0VjSF.jpg , and here is the error https://i.imgur.com/PLmA7cq.jpg – Royi Namir Jun 16 '19 at 15:04
  • https://stackoverflow.com/questions/46622113/the-deps-json-file-in-net-core?rq=1, why you did not have it before I am not sure – Ilya Chernomordik Jun 16 '19 at 15:22
  • 1
    @IlyaChernomordik It does exist in the publish folder. but again , I'm not publishing. I'm running the **Mock Lambda Test Tool**. which suppose to show chrome . when I have a 2.1 project everything is fine as i've showed. but when I create a 2.2 project ( not 2.1) , then it shows me an error. – Royi Namir Jun 16 '19 at 15:24
  • Probably something with paths or location of this file, maybe lambda test tool have different directory it points to when it runs. Try comparing actual run locations (you can check with procexp e.g. on windows, or some other means). I mean check which dll is being run by .netcore on which location on 2.1 and 2.2 and check deps.json in both – Ilya Chernomordik Jun 16 '19 at 15:37
  • @IlyaChernomordik It will all make sense if currently,it's not possible to create .net 2.2 lambda functions. [**Aws doesn't show 2.2**](https://i.imgur.com/qnAIysl.jpg) , only 2.1 , but [**this article says we can**](https://aws.amazon.com/blogs/developer/announcing-amazon-lambda-runtimesupport/) .......Can you please shed light ? can we or can't we ? – Royi Namir Jun 16 '19 at 15:40
  • I don't really know, I have not worked with lambda, just know about .net core :) – Ilya Chernomordik Jun 16 '19 at 15:58
  • @IlyaChernomordik I've found the problem FYI....see answer – Royi Namir Jun 16 '19 at 20:16

1 Answers1

5

Well, I've found out the reason for this (I don't know why it happened at first place) but here it is. Bear with me.

When I've created a 2.1 lambda project, everything was OK. ( obviously)

The problem was with 2.2 projects ( targeting 2.2 & nugets of 2.2). (which shows the error as I show in my question)

So then I thought, what if I'll create a 2.1 project and then update(!) its nugets and change target to 2.2 ? .........it worked!

This was really weird. Because I expected it not to.

So then I thought, let's compare file system for a 2.2 project (which doesn't work), with a 2.1 project that was updated to a 2.2 project (which does work, surprisingly).

On the right side, it's the strict 2.2 projects (no update), on the left it's the project that was UPDATED to 2.2 :

enter image description here

I've noticed some .Net core 2.1 files that were in the upgrade but weren't in the strict 2.2 version, so I thought, how can I get those missing files ?

enter image description here

So I've changed (temporarily) the project target to 2.1 :

enter image description here

Then I've run build

This caused the files for the 2.1 folders to appear :

enter image description here

And now ............. , all OK !!! :

enter image description here

mjwills
  • 23,389
  • 6
  • 40
  • 63
Royi Namir
  • 144,742
  • 138
  • 468
  • 792