Azure 应用服务,运行 一个用于转换文件的本机 EXE

Azure App Service, run a native EXE to convert a file

我有一个本机 EXE,可以根据命令行参数转换文件。如果我知道如何给出输入和输出文件的完整路径名,我可以 运行 在按下某个按钮时从我的应用程序服务中获取这样的 EXE 并等待输出文件创建吗?不能转换为 DLL。

据我所知,我们可以 运行 Azure 应用程序服务中的本机 exe。

但是不能直接给原生exe传参数

您需要编写一个网络应用程序或其他东西让用户输入输入参数。

然后你可以使用 Process.Start method 到 运行 exe。

具体操作方法,可以参考这个代码示例。

我使用ASP.NET MVC获取输入参数然后将参数发送到exe并获取结果。

    public  ActionResult Index()
    {


        var proc = new Process
        {
            StartInfo = new ProcessStartInfo
            {
                FileName = Server.MapPath("/exe/Sum.exe"),
                //Arguments could be replaced 
                Arguments = "1 2",
                UseShellExecute = false,
                RedirectStandardOutput = true,
                CreateNoWindow = true
            }
        };

        proc.Start();
        while (!proc.StandardOutput.EndOfStream)
        {
            string line = proc.StandardOutput.ReadLine();
            // do something with line

            Response.Write( " The result is : " + line);

        }

        //await getResultAsync();
        return View();
    }

结果: