6

I have uploaded a .NET6 project as a zip to AWS Lambda, via Visual Studio --> Publish to AWS Lambda however when I test the lambda, I receive this error:

Error: .NET binaries for Lambda function are not correctly installed in the /var/task directory of the image when the image was built. The /var/task directory is missing.

Does anyone have any suggestions for why this may be happening? Isn't AWS Lambda responsible for including the binaries when you publish as a zip?

Thanks

SamuraiMelon
  • 297
  • 3
  • 11
  • https://greghalter.com/aws-lambda-issue-missing-the-required-deps-json-file/ – Rand Random Jul 20 '22 at 10:48
  • Unfortunately not, and they don't really go into detail about what the actual conflict between their namespace and project name was. My namespace and project name are completely different however so I don't think this is an issue. – SamuraiMelon Jul 20 '22 at 11:23
  • Did you declare your classes public? Visual Studio nowadays tends to mark things internal? – Rand Random Jul 20 '22 at 12:24
  • Yes, but still having the same issue. – SamuraiMelon Jul 20 '22 at 17:11
  • Same error here, did you found any solution? – Longa Aug 09 '22 at 14:12
  • Any solution found for this? I'm facing same issue but I could see the deps.json in build package. Below is the error I received from lambda.. "Error: .NET binaries for Lambda function are not correctly installed in the /var/task directory of the image when the image was built. The /var/task directory is missing the required .deps.json file." – Karthick Jayaraman Oct 28 '22 at 07:12
  • Found the issue was with the handler name defined in new lambda created manually in AWS. This post helped me find the issue.https://stackoverflow.com/questions/41750026/aws-lambda-error-cannot-find-module-var-task-index – Karthick Jayaraman Oct 28 '22 at 09:09
  • This may help, doc doesn't explicitly mentioned VScode publishing, You can upload a .zip file as your deployment package using the Lambda console, AWS Command Line Interface (AWS CLI), or to an Amazon Simple Storage Service (Amazon S3) bucket. https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-package.html – mzm Dec 14 '22 at 17:08

5 Answers5

3

In my case, I use Upload from - .zip features of Lambda.

enter image description here

I uploaded the project in a zip file and binary files were inside the folder. like

enter image description here

That's created an issue. When you upload .zip files, make sure binary files are in the main root. Not inside any folder.

virender
  • 4,539
  • 5
  • 27
  • 31
1

do you somehow have the project marked as self-contained on the msbuild parameters? maybe in aws-lambda-tools-defaults.json or custom runtime set in serverless.tempate? It seems it is looking for the dotnet runtime assemblies in your application path

  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/32875405) – Hoppeduppeanut Oct 11 '22 at 05:30
0

Another rare but possible reason is an overwritten PATH env var value

anton
  • 48
  • 4
0

Adding the following property to the csproj project file, rebuilding and redeploying to Lambda did the trick for me.

<PropertyGroup>
  <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
</PropertyGroup>

Reference: https://mgkeen.com/blog/fixing-runtimeconfigjson-lambda-error

smk081
  • 783
  • 1
  • 10
  • 36
-1

Try checking the lambda configuration in the AWS console.

First, check whether there are any clues in the Code ribbons. If you published through VS, there should be some info like The deployment package of your Lambda function is too large to enable inline code editing and Package size XX.Y MB. If there is nothing (which I think will be the case), check your publish setup. The lambda runtime container expects code to be present at /var/task. If you upload code as zip, it should end up in this directory during lambda container initialization.

This error message might also indicate that a wrong runtime is used (eg. missing the dotnet runtime inside the Amazon Linux container). The structure of the dotnet runtime image can be examined through a Dockerfile that the image originates from.

Hope this helps a little .

Heehaaw
  • 2,677
  • 17
  • 27