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 ofMicrosoft 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 theWhat's new in this releaseto 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 newestMicrosoft R ClientandMicrosoft R Openreleases.
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.
Followthese instructions to install Machine Learning Serveron Windows, Linux, and Hadoop.
Don't forget toupgrade your web and compute nodesif you are operationalizing your analytics.
- 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 http://portal.azure.com
Clicking onCreate Resources
will take you to the marketplace
SelectingUbuntu 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
- Name: A name for the virtual machine, e.g.
- 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 tossh
into your instance. On the dashboard screen, click on the new box that shows your virtual machine. SelectNetworking
. 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 52.233.194.195
Make a note of your address. Nextssh
into your instance via
ssh userX@XXX.XXX.XXX.XXX
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 newrepository
sudo add-apt-repository ppa:marutter/rrutter
Then update again and install base R
sudo apt updatesudo 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 # igraphsudo apt-get install libcairo2-dev # Graphics packagessudo apt-get install libssl-dev libcurl4-openssl-dev #httr
With an eye to the future it’s also worth installingapache2
to help with redirects
sudo apt-get install apache2
Opening ports ready for RStudio
Whenever you access a web-page, the browser specifies aport. For standard http pages, we use port 80, for secure https pages, we use port 443. For example, when we type
https://www.jumpingrivers.com
in the browser, this is converted to
https://www.jumpingrivers.com:443
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.
UnderNetworking
, clickAdd inbound port rule
and add the three ports (80, 443, 8787):
If everything is working, you should be able to enterXXX.XXX.XXX.XXX
in your browser and you’ll see theApache2 Ubuntu Default Page
with the title.It works!
Installing RStudio
Installing RStudioserver is now relatively easy:
# Check the above link for updates to the version$ sudo apt-get install gdebi-core
$ wget https://download2.rstudio.org/server/bionic/amd64/rstudio-server-1.2.1335-amd64.deb
$ sudo gdebi rstudio-server-1.2.1335-amd64.deb
If everything works correctly, you should be able to view rstudio server via
XXX.XXX.XXX.XXX:8787
If the pagehangs, 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 usedrstudio-jumpingrivers
This means we can now access RStudio via
rstudio-jumpingrivers.westeurope.cloudapp.azure.com:8787
Getting users to type the port number isn’t ideal. What we would like is for users to type
rstudio-jumpingrivers.westeurope.cloudapp.azure.com/rstudio
This involves configuring Apache. First navigate to/etc/apache2/sites-available
, e.g.
cd /etc/apache2/sites-available
Next create a file calledrstudio.conf
. Using your favourite text editor, e.g.vim or nano. Note that this file is very much space sensitive, so check it carefully.
ServerAdmin info@jumpingrivers.com ServerName rstudio-jumpingrivers.westeurope.cloudapp.azure.com ServerAlias www.rstudio-jumpingrivers.westeurope.cloudapp.azure.com 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 proxysudo a2enmod proxy_httpsudo a2enmod proxy_htmlsudo a2enmod proxy_wstunnelsudo a2enmod rewrite
Finally, restart Apache
sudo a2ensite rstudio.confsudo service apache2 restart
You should now be able to access RStudio via
rstudio-jumpingrivers.westeurope.cloudapp.azure.com/rstudio/
Adding SSL
In theory it should be straightforward to add SSL support usingLet’s Encrypt.
Install Lets Encrypt for Apache
After the system update / upgrade we want to installgit, 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 theLets Encrypt Githubrepository, the second parameter the folder you want to clone it on your machine.
sudo git clone https://github.com/letsencrypt/letsencrypt /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 your-own-domain.at -d www.your-own-domain.at
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 tothe 443 destination port and hit save. That’s all.
Lets Encrypt setup
Back on theUbuntu VM, we have to finish the Lets Encrypt setup.
First we have to provide an email address:
Next we have to agree to theToS:
In the next step we have choose if our website is served in HTTP and HTTPS or in HTTPS only. Makeyourchoiceand hit OK.
If everything worked out you will see the following screen:
To test your new certificate just hit thisURL, 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 isonly 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
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 athttps://azuremarketplace.microsoft.com/en-us/marketplace/apps/rstudio-5237862.rstudioserverpro?tab=Overview
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 https://www.rstudio.com/products/rstudio/ for additional capabilities.
Usage:
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:https://rstudio.com/about/support-agreement/. We do not provide support for Linux, Azure or R. For Linux: help.ubuntu.com. For Azure:https://azure.microsoft.com/en-us/support/faq/. For R and R packages:rstd.io/help-with-r. For RStudio Server Pro, first consult:http://docs.rstudio.com/ide/server-pro/https://rstd.io/ide-support-docsandhttps://rstd.io/ide-support-topic.
Getting support for R Server
Microsoft is committed to providing customers with support. Microsoft R Server support continues in these ways:
Review our servicing support timeline
Post in our user forum
The future of Microsoft R Client
Microsoft R Clientcontinues 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.