Part I: Operationalizing R models with Dash Enterprise and Microsoft Azure

While R offers excellent support for machine learning, the process of operationalizing ML models as interactive web applications offers a promising tool for collaboration and data visualization. A well-designed web application can help close the gap between analysts and project stakeholders by providing data scientists with a platform to communicate their findings with individuals throughout their organization.

Plotly’s Dash Enterprise makes it easy to deploy, host, and manage interactive applications without requiring the support of a full stack web development team. In Part I of this article, we’ll demonstrate how to leverage a Microsoft Azure virtual machine to host Dash for R applications using Dash Enterprise. In Part II, we’ll cover what’s required to deploy a sample machine learning application.

Note: This guide is intended for use with version 3.3 of Plotly On-Premise.

Part I: Setting up Dash Enterprise on a Microsoft Azure Instance

Microsoft Azure Virtual Machine Initial Setup:

Before following the instructions below, make sure you have a Microsoft Azure account and are able to log into the Azure Console. You can sign up free of charge at https://azure.microsoft.com/en-us/free/

1. Start by clicking on Add VM on Azure Portal:

Figure 1:  Start by creating a Linux virtual machine to host Dash Enterprise within Azure

2. While the Create a virtual machine tool offers multiple customization options, selecting the defaults is sufficient. You may choose to customize your virtual machine if the apps deployed to Dash Enterprise require more resources.


Figure 2:  The default options for setting up an Azure VM should suffice for many users

For this demonstration, we’ll choose the Free Trial option. Once the Resource Group and Virtual Machine Name are specified, select the Region.

An appropriate Image to choose for the VM is Ubuntu Server 18.04 LTS. This uses a base Linux installation, which is compatible with the current release (3.3) of Dash Enterprise. 

3. Next, you’ll want to configure the server requirements. If you aren’t sure what to select, the following options are suggested:

  • 64-bit Linux server with root access
  • 4 CPU (or vCPU) cores
  • 16 GB RAM and 32 GB swap space
  • Minimum 200 GB disk space 

Azure offers D4s_v3 and D4_v3 virtual machine configurations, which both meet the above requirements. For the purposes of this guide, we’ll select D4s_v3:

Figure 3: Selecting the virtual machine configuration

Next, we’ll need to choose a username for the Administrator account. To enable SSH access, we’ll also need to assign an SSH public key. Instructions for creating SSH keys on various operating systems can be found here.

Finally, we’ll have to enable access to several ports on our virtual machine; specifically, we’ll need to allow HTTP (port 80), HTTPS (port 443), and SSH (port 22) traffic. The configuration interface makes this easy, since we just need to choose Select Inbound Ports and click on the ports to open.

Now that we’ve completed the VM configuration, we’re ready to create the instance! Choose Review + Create, and the VM will become available via the portal. We’re only a couple more clicks away from installing Dash Enterprise on Microsoft Azure…

Figure 4: Congratulations, your Azure VM has been deployed!

Configuring the Azure VM:

4. Now that we’ve successfully deployed our Azure VM, we’ll temporarily Stop it so that we can make some additional changes before installing Dash.

Choose Stop from the resource panel as highlighted in the image below:

Figure 5:  Resource Panel for the Azure Virtual Machine

Now that we’ve stopped the VM, we can expand the disk size. The default storage configuration provides 30 GB of disk space, but we can modify this by navigating to Settings > Disks > Disk Name > Configuration (Figure 6) and then selecting the disk to resize; the disk configuration pane is shown in Figure 7:

Figure 6: Selecting the disk to resize
Figure 7: Configuring the VM’s storage options

As the minimum recommended disk size is 200GB, we’ll resize the VM to be 200GB. 

Next, we’ll configure the server instance so that its IP address is static rather than dynamic (DHCP). We’ll want to do this so that the URL used to access the server’s app and management portal is accessible via a consistent IP address.

The IP address configuration can be modified by navigating to Configure > Assignment > Static.

Figure 8: Choose configure to modify the IP address configuration
Figure 9: Choosing static IP address assignment

Finally, we’ll want to configure the Server Manager and Dash ports on our instance. To do this, we’ll have to navigate to Settings > Networking > Inbound port rules > Add inbound port rule, as seen in the figure below:

Figure 10: Adding inbound port
Figure 11: Opening port 8800
Figure 12: Opening port 3022

Installing Dash:

5. Congratulations! You’ve successfully configured an Azure VM for the Dash installation. We’re now just a few more clicks away from starting up your application server for the first time.

Next, we’ll need to connect to the VM over SSH. There are a variety of options depending on your operating system. All Linux distributions and Mac OS include a native SSH client, which is available from the command line interface (called “Terminal” in Mac OS). On Windows, PuTTY is a popular client.

The VM configuration console provides a helpful hint on the syntax required, which is accessible via navigating to Connect > SSH > Login using VM local account:

Figure 13: Accessing the Connect to virtual machine pane

Once we’ve copied the line highlighted above, we should have administrator access to the Azure VM!

Next, we’ll want to create a directory to store files related to our Dash configuration. We’ll choose “plotly” as the directory name:

$ sudo mkdir /plotly

Next, we’ll install Dash and its dependencies:

$ curl -sSL https://get.plot.ly | sudo bash

If you are prompted to provide an IP address for the installation, you can leave it blank by pressing the Enter key. Assuming your network doesn’t feature a proxy server, you can also type “N” when prompted about proxy server details.

The installation should begin. If it concluded successfully, the following message will appear:

Figure 14: Dash installation success!

Configuring Dash:

6. Now that we’ve installed Dash successfully, we can run a quick test by navigating to the Azure management portal and copying the host’s public IP address.

If your organization hasn’t yet provisioned an SSL certificate for your Azure VM, you can still test things out by creating a self-signed certificate.

7. Once we’ve configured an existing or self-signed certificate, we’ll need to provide the server’s hostname and license file:

Figure 15: Configuring the Dash hostname and certificate

Now we need to secure the administration console with a password. Once we’ve entered the password (twice, to confirm), we’ll want to choose Continue to proceed:

Figure 16: Securing the Admin Console

8. We’re almost done! Before starting up our Dash server, we’ll want to run some preflight checks. These ensure that all the basic configuration requirements are satisfied. If one or more of these checks indicates a configuration problem, please contact Plotly Support for assistance.

If all goes well, you should see a screen resembling the figure below:

Figure 17: All Preflight Checks successful

9. Great! Now we’re ready to move on to the final details. Note: it’s important to define the Dash Domain Name, and add corresponding DNS entries which are associated with your Dash server’s public IP address.

  • Be sure to review the Plotly End User License Agreement via the Settings page; you’ll have to accept this agreement to proceed.
  • The Plotly Data Directory setting should reflect your choice of directory path above for storing Dash files; in our guide, we specified “/plotly” as the path.
  • We recommend setting the App Manager SSH Port to 3022; you may also want to test that the SSH service is active and responding to requests before proceeding with deployment.
  • Configure the App Manager Domain Name and validate it by clicking Test hostname resolution
            Figure 18: App Manager & SSL Certificate Configuration

10. Once finished, just click Save at the bottom of the page and your Dash server will start:

Figure 19: Plotly Server Manager Dashboard

To log in to Dash, just click on Open in the Dashboard tab. 

Congratulations! Your Dash server instance is now ready for use. We’ve kept things simple for this tutorial, but for a full overview of server configuration options, please consult our enterprise documentation: https://dash.plot.ly/dash-deployment-server

modern.data