Deployment guide

Datasette

Overview

Datasette is an open-source tool, created by Simon Willison, for exploring and publishing data. Point it at one or more SQLite databases and it serves an instant web UI and JSON API over them. Faceted browsing, full-text search and ad-hoc SQL queries are built in, with no schema design or front-end work required.

The SecureAnyCloud image installs Datasette 0.65.2 into a Python virtualenv at /opt/datasette/venv. It runs as a dedicated datasette system user, bound to loopback behind an nginx reverse proxy on TCP 80 with HTTP Basic auth. A unique web password is generated on the first boot of every VM.

What you get:

  • Datasette 0.65.2 in a virtualenv at /opt/datasette/venv, plus the datasette-vega charting plugin
  • The Datasette web UI and JSON API, fronted by nginx on :80
  • nginx HTTP Basic auth (Datasette has no built-in authentication) with a per-VM password in a root-only file
  • A dedicated Azure data disk at /var/lib/datasette that holds all SQLite databases. It is separate from the OS disk and re-provisioned with every VM
  • A bundled demo.db sample database (countries, cities and a sensor time series), so the UI shows real data immediately
  • datasette.service and nginx.service as systemd units, enabled and active
  • 24/7 SecureAnyCloud support

Prerequisites

  • An active Azure subscription, an SSH key pair, and a VNet plus subnet in the target region
  • A VM size of Standard_B2ms (2 vCPU / 8 GiB RAM) as a good starting point. Scale up for larger databases and more concurrent users
  • NSG inbound rules that allow 22/tcp from your management network and 80/tcp for the web UI and API. For public exposure, front the VM with TLS (see Enabling HTTPS)

Step 1 - Deploy from the Azure Marketplace

Sign in to the Azure Portal and choose Create a resource. Search the Marketplace for Datasette by SecureAnyCloud, and select Create.

On the Basics tab, pick your subscription, resource group, region and size. Under Administrator account, choose SSH public key and paste your key. Under Inbound port rules, allow SSH (22) and HTTP (80).

Review the dedicated data disk on the Disks tab. Then select Review + create, followed by Create.

Step 2 - Deploy from the Azure CLI

# Accept the Marketplace terms once per subscription (required before the first CLI deploy)
az vm image terms accept --urn sac1647283583153:datasette-ubuntu-24-04:default:latest
az vm create \
  --resource-group <your-rg> \
  --name datasette \
  --image sac1647283583153:datasette-ubuntu-24-04:default:latest \
  --size Standard_B2ms \
  --admin-username azureuser \
  --ssh-key-values ~/.ssh/id_ed25519.pub \
  --vnet-name <your-vnet> --subnet <your-subnet> \
  --public-ip-sku Standard
az vm open-port --resource-group <your-rg> --name datasette --port 80 --priority 1010

Step 3 - Connect to your VM

ssh azureuser@<vm-public-ip>

Step 4 - Confirm the services are running

systemctl is-active datasette.service nginx.service

Both services report active. Datasette starts in seconds and immediately serves every *.db file under /var/lib/datasette.

Step 5 - Retrieve your web password

The admin password is generated uniquely on the first boot of your VM and written to a root-only file. Read the file with:

sudo cat /root/datasette-credentials.txt

The file contains DATASETTE_ADMIN_USER (admin) and DATASETTE_ADMIN_PASSWORD, plus the URLs for the web UI and API. Store the password somewhere safe.

Step 6 - Check the health endpoint

nginx serves an unauthenticated health endpoint for load balancers and probes. Query it with:

curl -s http://localhost/health

It returns ok.

Step 7 - Open the web UI

Browse to http://<vm-public-ip>/ and sign in as admin with the password from Step 5. The image ships a demo.db sample database with three tables: countries, cities and sensor_readings. The UI shows real data out of the box.

Click demo to see its tables and row counts:

Open the countries table. Datasette's faceted browsing lets you click a column (here continent) to see counts per value and filter instantly. The column headers sort, and the results stay shareable as a URL:

The Custom SQL query box runs any read-only SELECT against the database. It returns a result table that you can export as JSON or CSV:

With the bundled datasette-vega plugin, you can render any table or query result as a chart. Open sensor_readings and click Show charting options. Then plot the time series as a line chart coloured by host:

Step 8 - Query the JSON API

Every page in Datasette has a JSON equivalent. Add .json to the URL. The API is behind the same Basic auth.

Confirm that Datasette is serving and report its version:

curl -s -u admin:<DATASETTE_ADMIN_PASSWORD> http://localhost/-/versions.json; echo

The response is a JSON object whose datasette.version field carries the running version (0.65.2). Fetch rows from a table as a JSON array:

curl -s -u admin:<DATASETTE_ADMIN_PASSWORD> 'http://localhost/demo/countries.json?_shape=array&_size=2'; echo

Each object is one row. Use _size to page, _sort/_sort_desc to order, and ?<column>=<value> to filter.

The API rejects requests without credentials (401) and returns the rows when you supply them (200):

Step 9 - Run SQL through the API

Run an arbitrary read-only SELECT through the API by passing it as the sql parameter on the database's JSON endpoint:

curl -s -u admin:<DATASETTE_ADMIN_PASSWORD> 'http://localhost/demo.json?sql=select+count(*)+as+n+from+cities&_shape=array'; echo

The response is [{"n": 14}]. Datasette permits only read-only queries, so the API is safe to expose to analysts behind the auth wall.

Step 10 - Add your own databases

Datasette serves every .db file in /var/lib/datasette. To publish your own data, copy a SQLite database onto the data disk and restart the service. From your workstation, run:

scp mydata.db azureuser@<vm-public-ip>:/tmp/mydata.db

Then run this on the VM:

sudo install -o datasette -g datasette -m 0644 /tmp/mydata.db /var/lib/datasette/mydata.db
sudo systemctl restart datasette.service

The new database appears in the web UI and at http://<vm-public-ip>/mydata within a couple of seconds.

You can also build a database in place under /var/lib/datasette with the sqlite3 CLI (installed on the image), or generate one with tools such as sqlite-utils.

Step 11 - Confirm data lives on the dedicated disk

All databases are stored on the dedicated Azure data disk, so they survive OS changes and can be resized independently. Confirm the mount with:

findmnt /var/lib/datasette

The mount is backed by a separate Azure data disk. The disk is captured into the image and re-provisioned on every VM.

Enabling HTTPS

The nginx reverse proxy serves plain HTTP on port 80. For public exposure, put a certificate in front of it. The simplest approach is to add a DNS name for the VM and use the companion SecureAnyCloud nginx-ssl-certbot image as a TLS reverse proxy.

Alternatively, install certbot and extend the existing nginx site (/etc/nginx/sites-available/sac-datasette) with a "listen 443 ssl;" server block and your certificate paths. Keep Datasette itself bound to loopback, so the only public surface is the authenticated, TLS-terminated proxy.

Maintenance

  • Configuration: the service launches Datasette through /opt/datasette/launch.sh. That script serves every *.db under /var/lib/datasette with the metadata in /opt/datasette/metadata.json. Edit those files, then run sudo systemctl restart datasette to apply changes.
  • Changing the web password: rewrite the htpasswd entry with sudo htpasswd -b /etc/nginx/.htpasswd admin '<new-password>', then run sudo systemctl reload nginx.
  • Backups: snapshot the /var/lib/datasette data disk, or copy individual .db files to Azure Blob Storage.
  • Upgrades: upgrade in the virtualenv with sudo /opt/datasette/venv/bin/pip install -U datasette, then restart the service.
  • Security patches: unattended-upgrades stays enabled, so the OS continues to receive security updates automatically.

Support

SecureAnyCloud provides 24/7 expert support for this image. Contact sales@secureanycloud.com.

Datasette is an open-source project created by Simon Willison and distributed under the Apache License 2.0. This image is produced by SecureAnyCloud and is not affiliated with or endorsed by the Datasette project.

Deploy on Azure

Launch Datasette on Ubuntu 24.04 LTS on Azure with 24/7 support from SecureAnyCloud.

View this image

Need Help?

Our support team is available 24/7.

sales@secureanycloud.com

Deploy on Azure