/azure-dev-bootstrap

An updated developer sandbox for Ubuntu 22.04 LTS, Node, Python and Go, accessible via Tailscale

Primary LanguageMakefileMIT LicenseMIT

azure-dev-bootstrap

A quick hack to run an Azure Development Instance with a few tools pre-installed and accessible via TailScale.

What

This is an Azure Resource Manager template that automatically deploys a development instance running Ubuntu 22.04 and a small set of development tools, namely pyenv, nodenv, Go and Docker CE.

The template defaults to deploying a Standard_B8ms VM with a relatively large Premium SSD disk size (P10, 128GB). It also deploys (and mounts) an Azure File Share on the machine with (very) permissive access at /srv, which makes it quite easy to keep copies of your work between VM instantiations.

After the first login, you can add your own SSH key (do not use the generated one other than for initial login - it won't pollute your config, and is meant for single-shot use) and remove both the public IP address and the NSG rule that allows SSH access (which defaults to your current outbound public IPv4 address) and use TailScale to access the instance.

Why

I needed a baseline template for remote development sandboxes, and I wanted it done purely through the CLI with reproducible results.

Roadmap

  • Make Makefile self-documenting
  • Automatically set up Tailscale with --authkey to remove need for open SSH port in NSG
  • tweak some defaults
  • remove unused packages from cloud-config
  • tweak Makefile
  • remove unnecessary files from repo and trim history
  • fork from azure-stable-diffusion, new README

Makefile commands

  • make help - shows a list of available commands
  • make keys - generates an SSH key for provisioning
  • make deploy-storage - deploys shared storage
  • make params - generates ARM template parameters
  • make deploy-compute - deploys VM
  • make view-deployment - view deployment status
  • make watch-deployment - watch deployment progress
  • make ssh - opens an SSH session to the instance and sets up TCP forwarding to localhost
  • make tail-cloud-init - opens an SSH session and tails the cloud-init log
  • make list-endpoints - list DNS aliases
  • make destroy-environment - destroys the entire environment (should not be the default)
  • make destroy-compute - destroys only the compute resources (should be the default if you want to save costs)
  • make destroy-storage - destroys the storage (should be avoided)

Recommended Sequence

az login
make keys
make deploy-storage
AZURE_TAILSCALE_AUTHKEY=<your auth key> make params
make deploy-compute
make view-deployment
# Go to the Azure portal and check the deployment progress

# Clean up after we're done working for the day, to save costs (preserves storage)
make destroy-compute

# Clean up the whole thing (destroys storage as well)
make destroy-environment

Requirements

Azure Cloud Shell (which includes all the below in bash mode) or:

  • Python 3
  • The Azure CLI (pip install -U -r requirements.txt will install it)
  • GNU make (you can just read through the Makefile and type the commands yourself)

Deployment Notes

Pro Tip: You can set STORAGE_ACCOUNT_GROUP and STORAGE_ACCOUNT_NAME inside an .env file if you want to use a pre-existing storage account. As long as you use make to do everything, the value will be automatically overridden.

Disclaimers

Keep in mind that this is not meant to be used as a production service.