MIKE
MIKE

Reputation: 1059

R site extension missing in Azure Functions

I am trying to install R script site extension to a azure function by following a tutorial. It is not on the list. Is there a work around?

Edit: enter image description here

Upvotes: 2

Views: 673

Answers (1)

MIKE
MIKE

Reputation: 1059

R does not need to be installed. You can install it locally and copy the folder to your Azure Function via ftp.

I ran R using R.Net in 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]);
    }
}

Upvotes: 2

Related Questions