Serverless is all the rage, now you can get in on the action using R! Azure Function supports a variety of languages (C#, F#, js, batch, PowerShell, Python, php and the list is growing). However, R is not natively supported. In the following blog we describe how you can run R scripts on Azure Function using the R site extension.

Azure Functions can be used in several scenarios because of the broad choice of triggers offered:

Timer trigger, executes a Function on a schedule.

Http trigger, execute a Function after an HTTP call.

Azure Queue Storage, Service Bus, Blob Storage, triggers the function when a new object or message is received.

Why would you want to run R scripts on Azure Function?

A typical use-case would be replacing your R jobs currently scheduled with cron for example. Using Azure Function you can set up a timer trigger that triggers your R script on a periodic basis. You get a fully managed solution where you can get alerted on errors and access to the logs or edit the scripts directly from the browser. If you choose the consumption plan, then it is very cost-effective, only paying per use and the underlying storage. (There is a free grant for the 1st million calls on the consumption plan).

The following tutorial will walk you through the steps to create a twitter bot posting a ggplot of the temperature forecast for the next 5 days using only R and Azure Functions: