Azure Functions中缺少R网站扩展

时间:2018-11-28 18:52:42

标签: r azure-functions

我正在尝试按照教程将R脚本站点扩展安装到azure函数。它不在列表上。有解决方法吗?

编辑: enter image description here

1 个答案:

答案 0 :(得分:2)

R不需要安装。您可以在本地安装它,并通过ftp将文件夹复制到Azure函数。

我在C#中使用R.Net来运行R。

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]);
    }
}