Azure Hosting - CosmicCubicle/PariahBot GitHub Wiki

Azure Hosting

Running PariahBot on Microsoft Azure, on one small virtual machine. Both install methods work on it: the container (Container Installation) or systemd (Host Installation). This page sets up the machine; the install itself is the same as anywhere else.

Complete Bot Setup first, because you'll need the token and application ID.

Why a VM, and not Container Apps, Container Instances or App Service

  • The database needs a local disk. It's one SQLite file in WAL mode. Container Apps, Container Instances and App Service keep files across restarts only on Azure Files, a network filesystem, and SQLite's WAL mode doesn't work on network filesystems. The database can be corrupted or locked.
  • Exactly one copy may run. Two copies logged in with one token both answer every command and both run moderation, alerts and pollers. Container Apps can run an old and a new revision side by side, and scale rules can add replicas, which makes that easy to get wrong.
  • Nothing connects in. The bot holds one long-lived connection out to Discord. It doesn't serve web requests, which is what those services are built around.
  • One small VM is the cheapest option anyway.

1. Create the VM

In the Azure portal, open Virtual machines → Create → Azure virtual machine:

Basics

Setting Value
Resource group Create new: pariahbot. Deleting the group later removes everything below
Virtual machine name pariahbot
Region Any; one near you is fine
Availability options No infrastructure redundancy required
Image Ubuntu Server 24.04 LTS, x64 (or Arm64 for an Arm size). Both setup scripts use apt-get, so use Ubuntu
Size A small B-series size, e.g. Standard_B1ms (1 vCPU, 2 GiB). Standard_B1s (1 GiB) runs the bot, with less headroom
Authentication type SSH public key
Username azureuser
SSH public key source Generate new key pair (download it when asked), or use one you already have
Public inbound ports Allow selected ports, SSH (22) only

Disks: Standard SSD is plenty, and Delete with VM keeps clean-up simple.

Networking: the defaults (a new virtual network, a public IP, a basic network security group) are fine.

Management: make sure Enable auto-shutdown is off, or the bot goes offline every night.

Then Review + create → Create, and download the private key when asked.

Restrict SSH to your own address. Once it's created, open the VM → Networking (or Network settings), select the SSH inbound rule, and set Source to My IP address.

Don't open any other ports, including the dashboard's. The bot only connects out, and the dashboard listens on the VM's own 127.0.0.1, so it's reached through an SSH or Cloudflare Tunnel (step 4).

2. Connect

The VM's Overview shows its public IP address. From your computer:

chmod 400 pariahbot_key.pem      # macOS and Linux; PowerShell doesn't need it
ssh -i pariahbot_key.pem azureuser@<public-ip>

Bring the system up to date first:

sudo apt-get update && sudo apt-get upgrade -y
sudo reboot        # if it says a restart is required; then reconnect

3. Install the bot

git clone https://github.com/CosmicCubicle/PariahBot.git
cd PariahBot

Then one of:

sudo ./deploy/container-setup.sh     # container: see Container Installation
sudo ./deploy/setup.sh               # systemd: see Host Installation

Run it as azureuser with sudo, not from a root shell. With systemd, azureuser becomes the account the bot runs under. Answer the questions as the install page describes, then invite the bot (Bot-Setup) if you haven't yet.

To keep the bot on the newest code in main without logging in, answer yes when the script offers its update job. The systemd one is a cron job that syncs with main (see Host Installation → Auto-update job); the container one pulls new images of main. You can turn either on later by rerunning the script.

Both installs start again on their own when the VM restarts.

4. The admin dashboard (optional)

If you turned it on, the setup script printed the redirect URL to register. Reach the dashboard with an SSH tunnel from your computer:

ssh -i pariahbot_key.pem -L 8080:localhost:8080 azureuser@<public-ip>

and open http://localhost:8080. Use your own port if it isn't 8080. For a public https:// address instead, use a Cloudflare Tunnel: see Admin-Dashboard → Making it public. Neither needs a network security group change.

5. Backups

Azure Backup covers the whole VM. Open the VM → Backup, create or pick a Recovery Services vault, and choose a daily policy. Snapshots of the disk (Disks → the OS disk → Create snapshot) work too, for a one-off copy.

A backup taken while the bot runs is like a sudden power cut, and SQLite is built to come back from one. For a copy that's exact to the moment, use the stop-and-copy steps on the install page you used; both have a Data and backups section.

Keep a copy of hom.env somewhere safe too, such as a password manager, so a lost key or VM doesn't lose the credentials.

Costs

The VM is billed while it's running, and its disk and public IP while they exist. Stop it from the portal (deallocate) to stop paying for compute; shutting it down from inside the VM doesn't. Check current prices for your region with the Azure pricing calculator, and set a budget alert under Cost Management → Budgets.

Keeping it patched

Ubuntu installs security updates on its own (unattended-upgrades). Log in now and then to run sudo apt-get upgrade and reboot when it asks. The bot starts again by itself. Bot updates come from the install's own update job; see the install page.

⚠️ **GitHub.com Fallback** ⚠️