Getting started with Tyk on Microsoft Azure and Ubuntu

Microsoft Azure is one of the most popular cloud platforms and getting started with Tyk on it has never been easier!

For this demonstration we will set up an VM instance, deploy Tyk using the tyk-pro-docker image via docker, bootstrap the dashboard, and create our first endpoint. By the end of this tutorial you’ll have a working version of Tyk that you can use to explore all of Tyk’s features!

Prerequisites:

  • An active Azure account
  • A terminal to run commands in

Step 1: Create and launch your VM instance

Log into the Azure dashboard. Once logged in, on the menu to the left, select the Virtual machines menu item

Once on the Virtual machines screen click Add -> Virtual machines

Now, we can begin to configure our VM. We will keep all the defaults except we will put our Virtual machine name as “tyk-poc”, select a resource group for the VM, select Ubuntu as our Image, and check off the HTTP, HTTPS, and SSH ports under Select inbound ports.

NOTE: you may need to create a new resource group if you don’t already have one configured!

After that is set, we then click the Review + create button at the bottom of the screen.

Once at the Review + create screen, we then click the Create button at the bottom of the screen.

To log into the VM instance you’ll need a key pair. When you click Create, a modal will pop up to generate a new key pair. You will now click the Download private key and create resources button and save the private key. Don’t lose this file since you’ll need it to log into the VM! Your instance will now launch!

Now you’ll see that Azure is launching your instance! Once everything has completed, click the X on the top right of the screen

Now, you’ll want to navigate back to the Virtual machines screen. From here we will go to the ellipsis in our VM entry in the table and click “Connect”.

From here, we will then need the path to our SSH key saved earlier. This screen will generate some lines of script to help us connect to the instance! Plug in your details, generate the scripts, and log in through your terminal.

Step 2: Installing Tyk on our new Azure instance!

We are now at the point where we will start to install the required components on the instance.

First we will install Git

sudo apt-get install git -y

Then we will update the repository and install a few more dependencies 

sudo apt-get update
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

Next we we will add the docker GPG key

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

And add the Stable Repository where we will grab our docker files for installation

sudo add-apt-repository \
     "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
     $(lsb_release -cs) \
     stable"

Then we once again run an update on the apt package index (This allows us to install docker from the stable repository added in the previous command)

sudo apt-get update

Next, we Install docker

sudo apt-get install docker-ce docker-ce-cli containerd.io

Then install docker-compose

sudo curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

We make docker-compose into an executable

sudo chmod +x /usr/local/bin/docker-compose

And lastly create a symlink for our docker compose executable

sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

After all of the above is set up, clone the Tyk Pro Docker repo from github using:

git clone https://github.com/TykTechnologies/tyk-pro-docker-demo

Then change to the newly created directory:

cd tyk-pro-docker-demo/

At this point we want to bring up the stack. We do that using the docker-compose command like so:

sudo su
docker-compose up -d

Once you press ENTER to run the command, the process will start to bring up the stack!

Once the process has brought up the stack you should see the following outlining that all components are up and running:

Now that we are up and running, let’s navigate to the dashboard to get started with Tyk! For this you’ll want to navigate to: http://<your Azure instance public IP>:3000

Step 3: Configuring and using your new Tyk instance!

Once we have navigated to the URL in the previous step you will come to the unlicensed dashboard screen. Here you will plug in your Tyk licence key and click “Activate key”.

After this, we should see the Dashboard Setup screen. Here you’ll want to fill out your details and click “BOOTSTRAP”.

After the bootstrap has completed, you then are taken into your new Tyk installation. From here navigate to the API Designer screen by clicking the APIs menu item on the left of the screen.

Once in the API Designer screen, under API Name enter “Test API”

Scrolling down on the screen, we will put our Target URL as “http://httpbin.org

And lastly, at the bottom of the page under Authentication mode, select “Open (Keyless)” as your authentication type. Then click SAVE to create the endpoint.

Now you should see your first endpoint created under the Created APIs list on the next screen.

Step 4: Test the endpoint!

Lastly, using Postman (or another one of your favourite tools) we will send a GET request to our endpoint. The URL we will hit will be: http://<your Azure instance public IP>:8080/test-api

Your results should look like this:

And there you have it, a new instance of Tyk up and running on Microsoft Azure and Ubuntu. Now you can easily start to discover some of the great features that Tyk has to offer!