0

I created a .NET 7.0 NativeAOT Lambda function from the AWS Templates. I haven't changed it. I installed the Mock Lambda Test Tool. I believe I have to use the Executable Assembly page to test my function? I can't figure out how to test it though. Do I need to set up docker and sam to test it locally? Or do I just build my C# and run the tool? It's just supposed to take a string and convert it to upper case. I haven't been able to find a tutorial on how to do this...

I tried running the Mock Lambda Test Tool 7.0. I was expecting to send my function a string and it return an uppercase string.

I'm running VS Code on Linux. Here's my launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            // Use IntelliSense to find out which attributes exist for C# debugging
            // Use hover for the description of the existing attributes
            // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
            "name": ".NET Core Launch (console)",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            // If you have changed target frameworks, make sure to update the program path.
            //"program": "${workspaceFolder}/DocGenerator/bin/Debug/net7.0/linux-x64/bootstrap.dll",
            "program": "${env:HOME}/.dotnet/tools/dotnet-lambda-test-tool-7.0",
            "args": ["--port 5050"],
            "cwd": "${workspaceFolder}/DocGenerator",
            // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
            "console": "internalConsole",
            "stopAtEntry": false
        },
        {
            "name": ".NET Core Attach",
            "type": "coreclr",
            "request": "attach"
        }
    ]
}

This is my aws-lambda-tools-default.json:

{
  "Information": [
    "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.",
    "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.",
    "dotnet lambda help",
    "All the command line options for the Lambda command can be specified in this file."
  ],
  "profile": "default",
  "region": "us-east-1",
  "configuration": "Release",
  "function-runtime": "provided.al2",
  "function-memory-size": 256,
  "function-timeout": 30,
  "function-handler": "bootstrap",
  "msbuild-parameters": "--self-contained true"
}
TrinaE
  • 33
  • 6

1 Answers1

1

Please check the "launchSettings.json" file under properties folder change the "executablePath" Path and "workingDirectory" and try to run and debug the code,

it should work. code here "executablePath": "%USERPROFILE%\.dotnet\tools\dotnet-lambda-test-tool-7.0.exe", "commandLineArgs": "--port 5050", "workingDirectory": ".\bin\$(Configuration)\net7.0",

  • That got the mock testing tool to run, but it still doesn't seem to be responding to requests? I edited my post to show my launch.json now. – TrinaE Jan 28 '23 at 23:50
  • I also edited my question to show my aws settings. I tried executing the function with the Test Function page and got an error: Invalid format for function handler string bootstrap. Format is ::::. – TrinaE Jan 28 '23 at 23:54
  • Add workingDirectory, "workingDirectory": ".\\bin\\$(Configuration)\\net7.0", – Meharban Ali Jan 29 '23 at 00:08
  • Thanks! Between your answer and this https://stackoverflow.com/questions/40976731/unable-to-load-type-from-assembly-c-amazon-lambda-function it's working! – TrinaE Jan 29 '23 at 01:14
  • Good Please Vote – Meharban Ali Jan 30 '23 at 22:41
  • I marked it as the right answer, but it says I need 15 reputation to vote. :( – TrinaE Jan 31 '23 at 17:03