Project · 3 parts · 2026

Deploying a disposable WireGuard server on Azure

A throwaway WireGuard VPN server on Azure: a small Ubuntu VM created when needed and destroyed afterwards, for next to nothing. Each building block is validated by hand before being automated with Terraform and cloud-init.

  • Azure
  • WireGuard
  • PowerShell
  • Terraform
  • cloud-init

What this is about

This series documents, as a set of articles, how to set up a disposable WireGuard VPN server on Azure: a small Ubuntu VM you create when you need it (public Wi-Fi, traveling, access from another region…) and destroy afterwards, for next to nothing. No VPN provider subscription and no server running for nothing: you keep control of the infrastructure and the traffic, end to end.

The approach is deliberately educational and transparent: each building block is first validated by hand (PowerShell to create the Azure resources, WireGuard configured manually on the VM) before being automated with Terraform and cloud-init. The choices, the dead ends and the mistakes along the way are documented just as much as the solutions that were kept.

Architecture

Architecturally, it is very simple: a client machine, an Azure VM, and a WireGuard tunnel between the two.

CLIENTAZURE · RESOURCE GROUPVIRTUAL NETWORK · SUBNETClient deviceWireGuard clientPublic IPstatic + DNS labelNSGUDP 51820 openSSH: admin IP onlyNICIP forwarding onUbuntu VMWireGuard serverKey Vaultsecret storeUDP 51820encrypted WireGuard tunnelserver private key
Overview: a WireGuard client, the Azure components around the VM, and the encrypted tunnel.

Around the VM, a few essential Azure components:

  • A resource group that holds everything, and that you simply delete to make the whole thing disappear.
  • A virtual network and its subnet.
  • An NSG whose only two inbound rules define the exposed surface: UDP 51820 (WireGuard) open, and SSH restricted to the administrator’s public IP.
  • A static public IP with a DNS label (FQDN), used as the endpoint by the clients.
  • A network interface with IP forwarding enabled: without it, Azure drops all the traffic relayed for the VPN clients.

Later, when provisioning this infrastructure gets automated, an Azure Key Vault joins in to store the server’s private key, so that it is not regenerated on every new deployment, which would invalidate the existing client configurations.

The articles

  1. 01Manual tests with PowerShell

    Deploying the whole infrastructure with PowerShell (resource group, VNet, NSG, public IP, NIC, VM), then configuring WireGuard by hand on the VM: keys, wg0.conf, forwarding, NAT, a first client and tests. Understanding every piece before automating.

  2. 02Terraform and cloud-initsoon

    The same deployment, fully automated: the infrastructure described with Terraform, and WireGuard configured on first boot by an idempotent cloud-init script.

  3. 02aWiring Terraform to Azure

    Creating a dedicated identity for Terraform on Azure: key pair and certificate, Service Principal, and RBAC permissions narrowed by a condition to contain the blast radius.

  4. 03Adding an Azure Key Vaultsoon

    Storing the server's private key in an Azure Key Vault, so it survives redeployments without invalidating client configurations.

© 2026 Louis Lecat