Beginner's Guide to Hosting a Blog on Azure - Part 1
6 min read

Beginner's Guide to Hosting a Blog on Azure - Part 1

Beginner's Guide to Hosting a Blog on Azure - Part 1

This is Part 1 of a 3 part tutorial which deploys a Ghost blog onto an Azure virtual machine, and directs traffic from a domain name (purchased on Google Domains) to the newly created Azure instance.

Part 0 / Part 1 / Part 2 / Part 3

Overview

For this tutorial, we will create an Azure virtual machine.

We will then deploy an open source blog platform called Ghost. Ghost has the benefit of being extremely low-code. Once configured, you can log in and visually manage all of your posts, tagging for posts, etc. It enables you to easily collect payment, monitor traffic, and more.

Later in the tutorial, I explore Ghost's theme marketplace and its integrations.

Do not pass go

With robust design tools like Webflow, it is becoming less compelling to need full control over a website's design, deployment, and codebase. At $20 / month / website (or a discounted $16/month if you pay yearly), most individuals should consider building and deploying with Webflow, and not on Azure.

In the world of WYSIWYGs—i.e. "what you see is what you get" no-code website builders—Webflow is amongst the most mature. Before proceeding, consider reviewing some of Chris Do's video tutorials on Webflow to see if it might be an easier option than deploying your own server.

Initial considerations

1.  When considering solutions, I am primarily considering cost, simplicity, and ease of maintenance for custom blog setup and deployment. I manage 7 different websites, so am also looking for an affordable solution to maintain them. These sites get cumulatively about 1,000 unique visitors per month, but I'm also considering which solutions can handle increased traffic with time.

2.  Most websites I manage are simple, static HTML—either custom or customized from a template on ThemeForest.

3.  Some websites I manage are blogs on the open source platform Ghost—a no-code (or low-code) platform that we will deploy in this tutorial. This article was deployed with Ghost.

4.  Knowledge in Git, Bash, GitHub, and modern web programming (JavaScript, HTML/CSS) is not required, but certainly helps.

Other options

Before continuing, it is important to consider some alternative services that might be better fit for your use case:

1.  Azure Container Instance requires that you have Docker experience and package your website(s) up as containers. You publish your container(s) to Azure Container Registry (or Docker Registry). ACI is compelling if you plan to scale your web application later (using AKS or similar). Plans start at about $32 / month when running continuously, and containers have tremendous benefit over a typical virtual machine when it comes to scale. This article also does a great job comparing ACI vs. virtual machines.

2.  Azure Storage with Azure CDN allows you to host any static HTML website at extremely affordable rates, but for any server side code—e.g. a simple contact form or a blog content management system—you'll be out of luck. If you are deploying basic HTML code and nothing else, consider this tutorial.

3.  Azure Virtual Machine Scale Sets allow you to automatically scale instances, but require additional configuration of a load balancer to direct network traffic, and typically recommend automated approaches to building and releasing your code. You can host static or dynamic web applications on a virtual machine scale set, and pricing starts at about $15 / month.

Setting up an Azure virtual machine

1.  Go to portal.azure.com and create or log in with a Live ID or GitHub account.

2.  Once logged in, search for "virtual machine" in the search bar:

`

(New users on Azure will be presented with three options, the first of which will require your credit card information prior to proceeding, though you will start with a $200 free credit and Azure will not automatically charge you. Select 'Start', and once you have accepted the terms and conditions, an Azure "subscription" will be created for you and you will be redirected back to the Azure Portal. For a walkthrough, start with these docs. Come back to this tutorial and search again for "virtual machine" once you are signed up.)

4.   This brings a browse view of your existing virtual machines. Select 'Add'

5.  At this point, you'll be prompted for some basic information. You'll want to name your virtual machine, select a Linux image such as Ubuntu 18.04, and select a Size.

6.  For Size, you can sort on cost. For anything less than 2 vCPUs, you'll likely get away with 3-5 users accessing a basic HTML site simultaneously, but will need to increase size should you wish to download large files, packages, or updates on your virtual machine. Select a B2s or higher for minimal disruption. The blogging platform Ghost recommends at least 1GB RAM.

(AWS offers cheaper options using its click-to-deploy option Lightsail, and there are many private hosting providers that will offer considerably cheaper prices.  Microsoft does not win on pricing at the time of this post.)

7.  Ensure SSH is your authentication type and that under Inbound port rules you have HTTP (Port 80) and SSL (Port 443) as allowed. This allows traffic to Port 80 and Port 443 so that your website can be reached at http://yourname.com and https://yourname.com. We'll configure SSL on the server directly later on.

(You can also select Port 22—the port used to connect to an instance via SSH. We will enable this port later on for specific IP addresses by adding a security group rule, rather than expose it to the entire Internet).

8.  Click on 'Review + create', and then 'Create'. You will be prompted to download a private key. Download it and store it in a safe location, as it is how you will access your virtual machine.

Connecting to your virtual machine

9.  Click Go to resource once your deployment succeeds (this should take about 2 minutes).

10.   Select the 'Networking' menu item, and then 'Add inbound port rule'. We'll be adding a rule for Port 22, which will enable us to connect to our instance.

11.  Before adding your inbound port rule, you will need to find your IPv4 address, which you can get by typing 'my IP address' into Google or going to whatismyip.com. Select Source of type 'IP Addresses', paste it into the 'Source IP addresses/CIDR ranges' field (where I have 100.100.100.100), and configure the fields as shown below. Then press 'Add'.

12.  Now that you have allowed your network to access your Azure VM, Select the 'Connect' menu item and then the 'SSH' tab.

13.  Open up 'Terminal' on a Mac, 'PowerShell' on a PC, or an SSH client of your choice. Recall where you saved your private key,and navigate to that directory. For example, if your private key is called azureuser.pem and is located in your user's Source folder, you can type on separate lines:

cd ~/Source
chmod 400 azureuser.pem

(You might need to right click and run your application as an Administrator, or type ‘sudo’ prior to setting the above file permissions. The chmod command will grant read access to owners-only.)

14.  Steps 3 and 4 in the Azure portal should walk you through the next command which combines your username and public IP address for the instance in a final command to execute, ultimately granting you access to your virtual machine:

20.  Once you run step 4 (above), you should be successfully connected to your instance!

In the next part, we'll install the underlying components necessary for a Ghost blog, we'll purchase a domain name, we'll purchase and attach a domain name to your VM, and we'll successfully create your blog! Go to Part 2

Part 0 / Part 1 / Part 2 / Part 3

Enjoying these posts? Subscribe for more