Rasa Chatbot in Azure Web App For Containers

William Galindez Arias
4 min readJan 3, 2020

--

If you have been playing around with frameworks/ libraries or tools on Applied Machine Learning, is likely you have mastered the creation of a virtual environment and by doing that you were able to create some isolation in your libraries and python versions, in addition, the usage of Jupyter Notebook might be natural by now. Well, assuming that is your starting point, probably you want to deploy your environment to some less developer oriented one, and terms such as CI/CD, workflows, versioning, containers, git and so on, are more frequent now than when you lived in Jupyter (Pun intended).

I have been using Azure Services for a while, and working in ways to deploy PoCs, or low fidelity prototypes faster in order to get end-user feedback as soon as possible.

In this step-by-step guide created originally mainly for internal use to revisit it when necessary, is documented how to quickly deploy to UAT using Docker Infrastructure, Github and Azure Web App Container Service.

Outline

Outline of the Process to Deploy Rasa Chatbot to Azure Web App

1. The Scenario

Simple Chatbot created using Rasa Library, the Chatbot is a working prototype that runs as expected in a local virtual environment created with virtualenv and using Python 3.7.

2. The Goal

Fig-1. POSTing requests to the endpoint provided by Azure Web App For Container

Deploy the Chatbot to Azure Cloud to interact with this one through a Website using your custom chat client, posting requests to the Chatbot API REST endpoint exposed via HTTPs. Once the Chatbot is deployed and you get the Azure provided URL you can also use Postman.

3. The Tools

4. Step By Step

Part I: Docker Hub

4.1 Push your working project to Github, in my case I use PyCharm, and have previously configured Github as my VCS, make sure to respect the folder structure obtained when running rasa init, and your pushed project must contain your own Dockerfile.

Fig-2. Rasa Project with Dockerfile

4.2 Once the project is pushed to Github, go to Docker Hub and:

Linked accounts Docker
Fig-3. Click on Linked Accounts
  • Click on Account Settings
  • Linked Account
  • Connect to Github

4.3 Linked Accounts, Github>Connect

Fig-4. Connect to your Github, where you have previously Pushed your working project

4.4 In Docker Hub, click on Repositories and create a new one , mark as private or public, up to your needs. Select Builds and choose as “Source Repository” your previously pushed working Project from step 4.1.

Fig-5. Select your bot repo from Github from Docker Builds Configuration

4.5 Specify your Dockerfile for your environment

Fig-6. Dockerfile

4.6 Click on “Save and Build” Button, the operation will take some minutes

Part II: Azure Web App For Containers

5. Assuming you want to use Azure Cloud, and you have a valid subscription

5.1 “Bring your own container” is what we will do by bringing the container we built in step 4.6, in Azure > Home > New > Marketplace, find the service Web App For Containers

Fig-7. Azure Service to bring our container built on Docker Hub

5.2 Select or create a New Resource Group, name your application, Publish as Docker Container

Fig-8. Web App Settings and creation

5.3 Click on “Next:Docker” and select your Image and Tag that can be found in your docker hub repository

Fig-9. Image Source: Docker Hub

5.4 Click on “Review and Create”, Azure will take care of pulling the image from your docker-hub and serve the application via HTTPs.

I personally use this approach for fast deployment and prototyping, it allows to consume the Rasa Chatbot using its API REST via HTTPs without having to worry (yet) about Load Balancing configuration and SSL Certificates.

You need to take care of your Dockerfile and working chatbot on your Machine, in my opinion: The cool Stuff.

--

--