Explore Courses Blog Tutorials Interview Questions
0 votes
in Azure by (45.3k points)

I need to execute R code as webservice, so i tried MLS and it works ok. The problem is that the packages are too old, and i need functions that are not implemented on old packages. I asked Microsoft support about it, and they have no data up upgrade it, and the new packages require an upgrade of it.

How can i do that using other resources, like webapi instead of MLS? All solutions I found requires R installed on the machine, which is a problem for creating an azure webapp, function, or API. I need an endpoint for forecast on-demand.

1 Answer

0 votes
by (16.8k points)

I found one way to execute R on Azure functions. the solutions is copy R-Portable in unzip it using powershell and create a process on function code. In my case i used the code:

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;


            string outputt = process.StandardOutput.ReadToEnd();

            string err = process.StandardError.ReadToEnd();


On your script you can access csv files or write, and after on function read and return that file.

Browse Categories