我想通过Azure Functions来执行一个依赖于DLL的C++ .exe。它的工作在我的本地机器上,以及当启动的exe与kudo控制台。
就像帖子里说的那样 在Azure功能中运行.exe可执行文件。 建议我准备好run.csx,然后在同一个文件夹 "D:/home/site/wwwroot/QueueTriggerCSharp1/"中加载.exe和DLLs。
当C++代码中不需要DLLs时,它就会工作。否则,C++找不到DLLs(它们和.exe在同一个文件夹里),退出代码是-1073741701.如果我不上传DLLs,我也会得到同样的退出代码。
我应该在哪里加载DLLs,还是有其他原因?
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}");
}
当我用python azure函数启动exe时,也会出现同样的错误。在kudo控制台中启动python脚本可以工作。
有人有类似的问题吗?
谁能帮帮我吗?
根据我刚刚与微软支持部门的一次会议,有 没办法.
Azure Functions 是一个非常受控的 (沙盒)的环境下,尽管必要的DLLs与EXE相邻,但访问system32目录会阻止EXE的运行。
我发现,带DLL的EXE可以在 服务器核心 但不会在 纳米服务器. 所以我怀疑Functions可能使用nanoserver,这可能是问题所在。
让你的C++在nanoserver上工作 可能 是通往Functions的大门。 但即使它不能让你进入Functions,你也可以从nanoserver大幅降低的占用空间中获益。 然而,我对在nanoserver上运行基于DLL的EXE并不乐观。 也许静态链接的EXEs是一个选择。
其实前段时间有个同事在Functions中运行了一些控制台应用,但后来就停止工作了。
EDIT: 最近才知道,nanoserver永远不会支持32位的应用程序(不知道64位的情况)。