Mastodon — P2 — Microsoft Azure VM

Tyler Fleming
4 min readDec 19, 2022

Deploying a VM within Azure to use with Mastodon, a multipart post.

Part 1: https://venivv.medium.com/mastodon-from-start-to-finish-d508376c06e4

I chose Microsoft Azure because I am familiar with the platform, both personally and professionally. It also doesn’t have annoying shortfalls like outbound ports being blocked like you may run into with VPS providers like Linode or Digital Ocean. That of course does come at a cost depending on the size of the box you want to use. I have chosen the B1ms for the size of the VM.

B1ms is about $15/m

I don’t plan on going over how to create an Office 365/Azure subscription and all that there are plenty of resources to do so online. Also it should be noted a shared CPU instance with 2GB RAM on Linode is ~$10/m, so there ARE additional costs running in Azure.

That being said in Azure if you turn off a VM you will NOT be billed for that machine, maybe implement a no social media Mastodon instance from certain time periods? (Interesting idea no?)

Deploying the VM within Azure

Once you are logged into the portal and have gotten your subscription setup the easiest way to get the machine deployed with your OS of choice (Ubuntu in this article) is by doing the following:

On the Azure Dashboard, you should see ‘Create a Resource’. Select that. Now Select Virtual machine, which will open a new pane to walk you through the VM creation process

Walking through the process, there are a few key things I recommend doing though. Mainly create a new resource group for anything and everything related to mastodon, this makes it more organized and easier for bill tracking purposes.

Key pieces of information that you want to double check for the deployment:

  • Resource Group -> Create New for keeping everything together
  • Region, select the one closest to you
  • Image, use Ubuntu Server 20.04 LTS — x64 Gen2
  • Size, I went with B1ms. B1s may be suitable for a handful of users
  • Authentication Type — Strongly recommend SSH public key, you can just copy and paste your own public key in.
  • Inbound Ports — with the dropdown select 80 and 443 as these are needed for Mastodon.
  • Go on to Disks -> You can pick just the Standard SSD. This is the OS Disk, a future post will go over how we are going to offload Mastodon data/cache to S3 storage.

You can click through the rest of the information but at this point you can click “Review + Create”, if everything looks good you can deploy the resouce and in about 2–3 mintues you’ll be able to SSH into your new Ubuntu instance.

TL:DR, I just want to deploy it

You can also deploy everything like I said above using an Azure template, my example is found here: https://github.com/tf-anguskong/mastodon-deployment/tree/main/Mastodon-Azure-Template

First you will want to use the search bar within the Azure Console; search ‘Deploy a custom template’ and select it. Then select ‘Build your own template in the editor’.

In the text box that pops up copy the contents of the template.json files from the GitHub repo in the box and select save. You will not be presented with a screen where you can edit the parameters.

Now click edit parameters and copy the contents of the parameters.json from GitHub and click save.

Verify the parameters and make sure you select the resource group from the template. This will be the end of the Azure deployment scenario.

Optional Step (If planning to deploy Portainer)

If you plan on deploying portainer for web interface administration of docker on the machine you will need to expose port 9443 to the internet. I also recommend making it so only your home IP can access port 9443 on the machine.

Navigate to the Virtual Machine -> Under Settings (on the left side) -> Networking, you’ll see the option to add an “Inbound Security Rule). Follow the screenshot below except update the Source IP Address to your home IP, you may have to update this every once in a while but only when/if you want to access Portainer.

Update the IP Address to your Home Public IP and Destination Port Range to 9443

--

--

Tyler Fleming

Follow me via Mastodon, @venivv@s.thecybernetwork.us