最佳答案
不需要安装R。您可以在本地安装它并通过 ftp 将文件夹复制到您的 Azure Function。
我使用 R.Net 运行 R在 C# 中。
public static class Function1
{
[FunctionName("Function1")]
public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)]HttpRequestMessage req, ExecutionContext context, TraceWriter log)
{
REngine.SetEnvironmentVariables(System.IO.Path.Combine(context.FunctionDirectory, @"R-3.4.4\bin\x64"), System.IO.Path.Combine(context.FunctionDirectory, @"R-3.4.4"));
REngine engine = REngine.GetInstance();
string[] a = engine.Evaluate("'Hi there .NET, from the R engine'").AsCharacter().ToArray();
engine.Dispose();
return req.CreateResponse(HttpStatusCode.OK, a[0]);
}
}
关于Azure Functions 中缺少 R 站点扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53526216/