Hosting RServer and RStudio on Azure
Published Jul 09 2019 02:15 AM 16.9K Views



Getting started

So there are various ways of installing RServer and RStudio in this blog I want to share some of the ways in which your institution can deploy this solution.
Option 1. Using Microsoft Machine Learning Server (previous name Microsoft RServer)

Option 2. Using Azure VM to install Ubuntu, RServer and Rstudio step by step guide

Option 3. Using Azure VM MarketPlace Image for RStudio Server Pro for Azure

Option 1. Using Microsoft R Server

In September 2017, Microsoft R Server was released under the new name of Microsoft Machine Learning Server. In version 9.2.1, Machine Learning Server added support for the full data science lifecycle of Python-based analytics to its list of machine learning and AI capabilities enhancements. The R capabilities were also enhanced. In the latest 9.3 version, Machine Learning Server improves operationalization and deployment of web services containing R or Python code.
Read the What's new in this release to learn more.

Building on our commitment to R

Microsoft continues its commitment and development in R -- not only in the latest Machine Learning Server release, but also in the newest Microsoft R Client and Microsoft R Open releases.

Upgrade to Machine Learning Server

All academic institutions get R Server for FREE under Microsoft Azure Dev Tools for teaching. Moving from R Server to Machine Learning Server is as easy as ever. The R analytics and web services you developed under R Server will continue to work under Machine Learning Server.

  1. Follow these instructions to install Machine Learning Server on Windows, Linux, and Hadoop.

  2. Don't forget to upgrade your web and compute nodes if you are operationalizing your analytics. 

  3. Want the new Machine Learning Server? Learn how to install Machine Learning Server here.

Download prior R Server releases

The following table provides links for downloading older versions of Microsoft R Server. Find the instructions for installing R Server here.


Option 2. Installing Ubuntu, RStudio and RServer in the Cloud on VM releases

Student can sign up for a FREE $100 Azure Account here

On the Azure Portal 

Clicking on Create Resources will take you to the marketplace

Selecting Ubuntu Server will launch a dialogue box with four steps:

  • Step 1: Basics: configuration settings
    • Name: A name for the virtual machine, e.g. rstudio
    • User name: The master user who will have sudo access, e.g. userX
    • Authentication type: Either choose ssh or enter a password
    • Resource group: Since this your first instance, create a new one, say rstudio-group
    • Location: where will your machine be located
  • Step 2: Virtual machine size
    • Select the machine you want. Choose the smallest for the purposes of this exercise
  • Step 3: Settings
    • Nothing to change here
  • Step 4: Summary
    • Click create and we’re good to go!

After around a minute or so, your virtual machine will be ready.

Setting up R

The next step is to ssh into your instance. On the dashboard screen, click on the new box that shows your virtual machine. Select Networking. Near the top of the screen will be a Public IP address, of the form: XXX.XXX.XXX.XXX. In my instance, the IP address is

Make a note of your address. Next ssh into your instance via


To ensure that ubuntu is up-to-date on our virtual machine, we invoke super sudo powers. First we update the list of ubuntu packages

sudo apt-get update

Then we upgrade as necessary

sudo apt-get upgrade

Now we get on with the business of installing R. To use the latest version we need to add a new repository

sudo add-apt-repository ppa:marutter/rrutter

Then update again and install base R

sudo apt update
sudo apt-get install r-base

Depending on what R packages you want to install it’s worth installing a couple of other things at this point

sudo apt-get install libxml2 libxml2-dev # igraph
sudo apt-get install libcairo2-dev # Graphics packages
sudo apt-get install libssl-dev libcurl4-openssl-dev #httr

With an eye to the future it’s also worth installing apache2 to help with redirects

sudo apt-get install apache2

Opening ports ready for RStudio

Whenever you access a web-page, the browser specifies a port. For standard http pages, we use port 80, for secure https pages, we use port 443. For example, when we type

in the browser, this is converted to

By default our azure instance only has port 22 open (the port used for ssh communication). To access RStudio, we’ll need to open the following ports

  • 80 (for http)
  • 443 (for https); only required if we implement SSL
  • 8787 – the default RStudio port. In the last section, we’ll remove this, but just now it’s handy to have it open for testing.

Under Networking, click Add inbound port rule and add the three ports (80, 443, 8787):

If everything is working, you should be able to enter XXX.XXX.XXX.XXX in your browser and you’ll see the Apache2 Ubuntu Default Page with the title. It works!

Installing RStudio

Installing RStudio server is now relatively easy:

# Check the above link for updates to the version
$ sudo apt-get install gdebi-core
$ wget
$ sudo gdebi rstudio-server-1.2.1335-amd64.deb

If everything works correctly, you should be able to view rstudio server via


If the page hangs, double check you have opened port 8787 under the network settings.

Adding DNS

The first step is to access the page via a standard URL and not an IP address. In the main dashboard screen, under all resources, click on

rstudio-ip Public IP address

Then select configuration. In the text box under DNS Label, enter text, e.g. rstudio-myname. So in my case, I have used rstudio-jumpingrivers

This means we can now access RStudio via

Getting users to type the port number isn’t ideal. What we would like is for users to type

This involves configuring Apache. First navigate to /etc/apache2/sites-available, e.g.

cd /etc/apache2/sites-available

Next create a file called rstudio.conf. Using your favourite text editor, e.g. vim or nano. Note that this file is very much space sensitive, so check it carefully.

    Allow from localhost

  # Specify path for Logs
  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined
  RewriteEngine on

  # Following lines should open rstudio directly from the url
  # Map rstudio to rstudio/
  RedirectMatch ^/rstudio$ /rstudio/

  RewriteCond %{HTTP:Upgrade} =websocket
  RewriteRule /rstudio/(.*) ws://localhost:8787/$1 [P,L]
  RewriteCond %{HTTP:Upgrade}     !=websocket
  RewriteRule /rstudio/(.*) http://localhost:8787/$1 [P,L]
  ProxyPass /rstudio/     http://localhost:8787/
  ProxyPassReverse /rstudio/ http://localhost:8787/
  ProxyRequests off

Then enable the necessary Apache modules

sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_html
sudo a2enmod proxy_wstunnel
sudo a2enmod rewrite

Finally, restart Apache

sudo a2ensite rstudio.conf
sudo service apache2 restart  

You should now be able to access RStudio via

Adding SSL

In theory it should be straightforward to add SSL support using Let’s Encrypt

 Install Lets Encrypt for Apache

After the system update / upgrade we want to install git, just use the following command:

 sudo apt-get install git -y

When Git is installed we can clone the Lets Encrypt repo. The first parameter is the Lets Encrypt Github repository, the second parameter the folder you want to clone it on your machine.

sudo git clone /your/path/your-letsencrypt-folder

If you successfully cloned the repos cd into the Lets Encrypt folder and enter the following command:

letsencrypt-auto --apache -d -d

For Apache, the installation is very simple, the first parameter will setup your new SSL certificate for your Apache installation, the second parameter will take your domain, if needed set it up with and without www upfront.

Setup your Azure VM Port 443 SSL

While the dependencies get installed, we can setup the SSL security group in Azure. In the endpoint settings or in your network interface security group (depending of your VM), you have to setup a new security group for port 443.


Give your rule a name, set it to TCP and allow all connections to the 443 destination port and hit save. That’s all.

Lets Encrypt setup

Back on the Ubuntu VM, we have to finish the Lets Encrypt setup.

First we have to provide an email address:


Next we have to agree to the ToS:


In the next step we have choose if our website is served in HTTP and HTTPS or in HTTPS only. Make your choice and hit OK.


If everything worked out you will see the following screen:


To test your new certificate just hit this URL, make sure to add your domain with yours.

Your browser should now show that your site provide a private connection.

Renewing your certificate

Your certificate is only valid for 90 days, so you have to make sure to renewal it at least once in this period, to do so you just have to enter the following command:

 letsencrypt-auto renew

Option 3. Using an Azure Marketplace RStudio Server Pro for Azure  

RStudio Server Pro lets you access RStudio from anywhere using a web browser and delivers the team productivity, security, centralized resource management, metrics, and commercial support professional data science teams need to develop in R.

Rstudio Server Pro for Azure is available at

RStudio Server Pro Azure is an on-demand, commercially-licensed integrated development environment (IDE). It offers all of the capabilities found in the popular RStudio open source IDE plus turnkey convenience, enhanced security, the ability to manage multiple R versions and sessions, and more. See for additional capabilities.


Connect to http://instance-public-ip-address:8787 and log in with the username rstudio-user. The password will be your subscriptionId for that instance.

RStudio Server Pro for Azure

Information on support can be found here: We do not provide support for Linux, Azure or R. For Linux: For Azure: For R and R packages: For RStudio Server Pro, first consult: and


Getting support for R Server

Microsoft is committed to providing customers with support. Microsoft R Server support continues in these ways:

The future of Microsoft R Client

Microsoft R Client continues on as an R-only client for Machine Learning Server and R Server.

A Python interpreter can also be installed locally along with the custom Python packages to gain similar functionality on a Windows machine. Learn more.



Version history
Last update:
‎Jul 09 2019 02:21 AM
Updated by: