Locally Deploy Rasa X On a Linux Azure Virtual Machine
Published: 2021-01-08 13:41:52


## Introduction

You have already built your assistant locally using Rasa open source. Well, deriving from Rasa Docs installation guide for Rasa X you have decided Server Quick-Install is your best preference as it is the simplest and quickest.

Two things - yes it is simple and quick.

You have also chosen Microsoft Azure as your cloud provider to host your Linux Virtual Machine. One thing - it is damn quick! Here is how to make it simple even when you stick to the terminal and have no idea how to engage an Azure Cloud Shell.

## Prerequisites

* Azure Portal

* Adhere to these Requirements: https://rasa.com/docs/rasa-x/installation-and-setup/install/quick-install-script#requirements

* Linux terminal

### Step 1: Create a Linux VM

In the dashboard of your Azure portal, under Azure services:

* Click Create a resource. Select Compute and choose Virtual Machine. You should be able to see basic configurations for a fresh VM.

* Under Basics, configure a new Resource group that is unique, a Virtual machine name, your Region and choose your Linux image. In my case, Ubuntu Server 18.04 LTS - Gen1 as of writing this article.

**Note:**

* You should be careful to select the recommended Size of vCPU as specified in Rasa Docs. Make sure SSH public key is your Authentication type to enable generation of a new key pair.

* Allow Public inbound ports for selected ports SSH (22), HTTP (80), HTTPS (443). This will allow IP addresses to access your virtual machine. You can confirm this while defining your network connectivity of your VM that the selected inbound ports are allowed. Proceed to create your VM.


### Step 2: SSH into your Linux VM

SSH is an encrypted connection protocol that will allow you to securely sign-in over unsecured connections. The public-private key pair is like the lock on your door. The public key (lock) is exposed to anyone with the right key (private key). Give it to people you trust.

* The public key is placed on your Linux VM when you create the VM

* The private key remains on your local machine.

The VM tests the SSH client to make sure it has the correct private key when you want to connect to your Linux VM.

* Open a terminal in your PC and access your working directory.

* Login to your Azure Portal from your working directory:

**$ Az login**

* SSH to your VM with an SSH client

**$ ssh azureuser@myvm.southafricanorth.cloudapp.azure.com**

Replace with admin user name and the fully qualified domain name, and IP address/DNS name

In case you have misplaced your generated keypair or encountered ***Permission Error*** 

* Generate key value pairs to an already created VM as follows:

**$ ssh-keygen -m PEM -t rsa -b 4096**

* Copy the public key for reset

**$ cat ~/.ssh/id_rsa.pub**

* On your Azure Portal, open your Linux Virtual Machine and paste your public key

**Support + Troubleshooting >>> Reset password >>> Reset SSH**

You can now proceed to ssh into you Linux VM with your new keypairs

### Step 3: Customize and Deploy Rasa X

You should be connected to your virtual machine at this point. Therefore, you could proceed to customize a few settings for your deployment:

**$ export INITIAL_USER_PASSWORD="my-safe-password"**
**$ export RASA_X_VERSION=0.34.0**
**$ export ENABLE_DUCKLING=True**
**$ curl -s get-rasa-x.rasa.com | sudo -E bash**

When done, the script will print the URL to access Rasa X:

You can now access Rasa X on this URL: <--URL-->

Rasa X is deployed locally on your server!


## Conclusion

We have learnt that a key step to achieve quick install on Azure VMs is highly dependent on how you configure your network connectivity to allow inbound ports and finally SSH-ing into your Linux VM. Be careful about root permissions especially in your working directory. Rasa X can also be deployed on a cluster environment to have more control while customizing your deployment.

As a next step, add a custom action server and eventually an Integrated Version Control to connect your Github repository. Happy Rasa X deployment!

## Additional Resources

* https://rasa.com/docs/rasa-x/

* https://rasa.com/docs/rasa-x/installation-and-setup/deploy

* https://docs.microsoft.com/en-us/azure/virtual-machines/linux/mac-create-ssh-keys