Azure上的R Server

问题描述 投票:2回答:1

我需要执行R代码作为webservice,所以我尝试了MLS,它工作正常。问题是包太旧了,我需要在旧包上没有实现的功能。我问过微软对它的支持,他们没有数据升级它,新的软件包需要升级它。

我怎样才能使用其他资源,比如webapi而不是MLS?我发现的所有解决方案都需要在机器上安装R,这对于创建azure webapp,function或api来说是一个问题。我需要一个端点来按需预测。

r azure-web-sites azure-functions azure-web-app-service azure-machine-learning-studio
1个回答
0
投票

我找到了一种在Azure函数上执行R的方法。解决方案是在https://sourceforge.net/projects/rportable/中复制R-Portable,使用PowerShell解压缩它并在功能代码上创建一个进程。在我的情况下,我使用的代码:

System.Diagnostics.Process process = new System.Diagnostics.Process();
            process.StartInfo.WorkingDirectory = @"D:\home\site\tools\R-Portable\App\R-Portable\bin\";
            process.StartInfo.FileName = @"D:\home\site\tools\R-Portable\App\R-Portable\bin\Rscript.exe";
            process.StartInfo.Arguments = "-e \"print('Hello world')\"";
            process.StartInfo.UseShellExecute = false;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardError = true;
            process.Start();
            string outputt = process.StandardOutput.ReadToEnd();
            string err = process.StandardError.ReadToEnd();
            process.WaitForExit();

在您的脚本上,您可以访问csv文件或写入,然后在函数读取并返回该文件。

© www.soinside.com 2019 - 2024. All rights reserved.