Run .exe with DLLs in Azure Function

Viewed 1860

I want to execute a C++ .exe which depends on DLLs by means of Azure Functions. It works on my local machine as well as when starting the exe with kudo console.

Like in post Run .exe executable file in Azure Function suggested I prepared the run.csx and loaded up the .exe and DLLs in the same Folder "D:\home\site\wwwroot\QueueTriggerCSharp1\".

It works when no DLLs in the C++ Code is required. Otherwise C++ doesn't find the DLLs (which are in the same Folder as the .exe) and the exit code is -1073741701. I get the same exit code, if I don't upload the DLLs.

Where should I load the DLLs or could there be another reason for it?

The run.csx-Code:

using System;
using System.Threading;
using System.Diagnostics;

public static void Run(TimerInfo myTimer, TraceWriter log)
{
    System.Diagnostics.Process process = new System.Diagnostics.Process();
    string WorkingDirectoryInfo =@"D:\home\site\wwwroot\QueueTriggerCSharp1\";
    string ExeLocation = @"D:\home\site\wwwroot\QueueTriggerCSharp1\WriteDatebase2.exe";
    Process proc = new Process();
    ProcessStartInfo info = new ProcessStartInfo();
    info.WorkingDirectory = WorkingDirectoryInfo;
    log.Info($"WorkingDirectory: {info.WorkingDirectory}");
    info.FileName = ExeLocation;
    info.Arguments = "";
    info.UseShellExecute = false;
    info.CreateNoWindow = true;
    proc.StartInfo = info;
    proc.Start();
    proc.WaitForExit();
    int exitcode=proc.ExitCode;
    log.Info($"ExitCode: {exitcode}");
}

The same error occurs when I start the exe with a python azure function. Starting the python script in kudo console works.

Does anyone have similar issues?

Can anyone help me? Thanks!

1 Answers

Based on a meeting I just had with Microsoft Support, there is no way to do this.

Azure Functions is a very controlled (sandboxed) environment where access to system32 directory prevents EXE operation, despite the necessary DLLs being adjacent to the EXE.

I have found that an EXE with DLLs works fine on server/core but will not work on nanoserver. So I suspect Functions might use nanoserver, which could be the problem.

Getting your C++ working on nanoserver might be the gateway to Functions. But even if it doesn't get you to Functions, you can benefit from the drastically lower footprint of nanoserver. However, I'm not that optimistic about DLL-based EXEs running on nanoserver. Maybe statically linked EXEs is an option.

A co-worker actually had some console apps running in Functions some time ago but it has since stopped working.

EDIT: Just learned recently that nanoserver will never support 32-bit apps (not sure about 64-bit)

Related