Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

henrik55

WinSCP.exe in .NET Core Lambda function

Hi,
I have developed a .NET Core 6.0 using WinSCP 6.1.0 NuGet package. Locally, from my own PC, I can access a SFTP server, obtaining connection and being able to PUT files. When I deploy my app as a AWS Lambda function I get the following error on Session.Open():
WinSCP.SessionLocalException: The winscp.exe executable was not found at location of the assembly WinSCPnet (/var/task), nor the entry assembly Amazon.Lambda.RuntimeSupport (/var/runtime), nor in an installation path. You may use Session.ExecutablePath property to explicitly set path to winscp.exe.

I am aware that for a Azure Function I can set ExecutablePath like this, and it works:
[FunctionName(FunctionName)]
public static void Run([TimerTrigger("%XXXSendSchedule%")] TimerInfo myTimer, ILogger log, ExecutionContext executionContext)
     . . .
     using (Session winscpSession = new Session())
     {
          // See https://winscp.net/eng/docs/guide_microsoft_azure_function_sftp
          winscpSession.ExecutablePath = Path.Combine(executionContext.FunctionAppDirectory, "winscp.exe");

However, in a Lambda function the ILambdaContext does not seem to have anything like Azure's FunctionAppDirectory:
public void MyFunctionHandler(ILambdaContext context)

Where can I find the path where the Lambda function keeps winscp.exe?

Henrik