How to Launch Jupyterlab on Azure and Publish to Kyso
Azure does provide a service that you can use to quickly start using Jupyter with a simple GUI. By using the Azure Notebook Service, you can easily gain access to Jupyter's web-accessible interface to scalable computational resources with all the power of Python and its many libraries. Since the installation is handled by the service, users can access these resources without the need for administration and configuration by the user. Unfortunately, the notebook service only supports Jupyerlab 0.31 at the moment, which is not compatible with Kyso's extension.
This is a short guide to setting up and running a Jupyterlab environment on an Azure instance. We have recently made a cool new Jupyterlab extension that allows anyone to publish their Jupyter notebooks directly to the web as awesome data blogs from anywhere.
1. Create an account
Before you can create a Linux-based virtual machine, you must have an Azure subscription. To obtain one, get an Azure free trial.
2. Create and Configure Virtual Machine
Go to https://portal.azure.com and from the left-hand-side toolbar, select Virtual Machines. Click on Create Virtual Machine.
In the Basics tab, under Project Details, make sure the correct subscription is selected and then choose Create New under Resource group. A resource group is essentially a container that holds all related resources for an Azure service. In the pop-up, choose a name for the resource group. Under Instance Details, name your Virtual machine name and choose your Region. Leave the other defaults. Under Administrator Account, select SSH public key, type your user name, then paste your public key into the text box. Remove any leading or trailing white space in your public key.
You can create a public key from your terminal with:
ssh-keygen -t rsa -b 2048
If you already have one, copy it to your clipboard with:
Under Inbound port rules, then Public inbound ports, choose Allow selected ports and then select SSH (22) and HTTP (80) from the drop-down
Navigate to the Management tab to create a storage account, to which your machine's metrics will be written, available to analyze. Click Review and Create.
On the Create a virtual machine page, you can see the details about the VM you are about to create. When you are ready, select Create. It will take a few minutes for your VM to be deployed. When the deployment is finished, move on to the next section.
3. Configure Security Settings
Once your deployment is complete click Go to resource. You are now looking at your virtual machine dashboard.
Under the settings tab go to Networking to open up a security rule for inbound traffic on the network security group. There are already defaults set for SSH and HTTP traffic, as seen below. Head back to the main VM page dashboard & take note of the remote server's public IP address at the top of the page.
4. Connect to your Virtual Machine
On this page select Connect to connect to your VM. In the Connect to virtual machine side-bar, keep the default options to connect by IP address over port 22. Under Login using VM local account a connection command is shown. Click the button to copy the command to your clipboard. Paste the command into your terminal and answer yes to the prompt.
You are now connected to your remote server from the terminal.
5. Set up Data Science Environment
First, let's get the latest Anaconda build for linux. On your VM terminal, you can enter:
to download the build. Now execute the installer::
If the installer doesn't give you the option to prepend the Anaconda3 install location to PATH in your /home/"username"/.bashrc or if you answer no by mistake you can manually set it with:
Make a separate folder for our notebooks and cd into that directory.
6. Fire Up Jupyterlab
Fire up Jupyterlab:
Take note of the token to gain access to the Jupyter environment.
7. SSH into your Jupyter Lab Environment
Open a new tab in the terminal and ssh into the Jupyterlab environment.
ssh -L 8080:localhost:8888 KyleOS@22.214.171.124
In your browser go to localhost:8080 and enter the token. That's it, you're in!
8. Install Kyso's Publish Extension
The next step is to download Kyso's very own Jupyterlab extension. You can take a look at our documentation on Gi thub here. The prerequisites are Jupyterlab 0.34 (or later) and a Kyso account.
You can check your Jupyterlab version by running:
jupyter lab --version
To install the extension, run the following.
For Jupyter Lab 0.35:
jupyter labextension install @kyso/jupyterlab
For Jupyter Lab 0.34:
jupyter labextension install @firstname.lastname@example.org
Note that this install requires node 5 or later. If you encounter any issues such as ValueError: Please install nodejs 5+ and npm before continuing installation when installing the above run the following & then install the extension:
sudo apt-get install nodejs -y
sudo apt-get install npm -y
Once installed, refresh the page & you will see the Kyso option in the top navbar. You are now able to publish awesome data blogs directly to Kyso from an AWS EC2 instance!