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
3
Answers
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
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
andPackage 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 🙂.
In my case, I use Upload from – .zip features of Lambda.
I uploaded the project in a zip file and binary files were inside the folder. like
That’s created an issue. When you upload .zip files, make sure binary files are in the main root.
Not inside any folder.