Application Development Azure

Streamlit on Ubuntu 24.04 on Azure User Guide

| Product: Streamlit on Ubuntu 24.04 LTS on Azure

Overview

Streamlit is the fastest way to build and share data apps. Write a Python script and Streamlit turns it into an interactive web app - charts, dataframes, widgets, maps and more - with no front-end code. It is the go-to framework for data scientists and ML engineers building dashboards, internal tools and model demos. The cloudimg image installs Streamlit 1.58.0 in a dedicated Python virtualenv, serves a sample dashboard app as a systemd service bound to loopback behind an nginx reverse proxy on port 80 with HTTP Basic auth, persists the app and its data on a dedicated Azure data disk, and generates a unique login password on the first boot of every VM. Backed by 24/7 cloudimg support.

What is included:

  • Streamlit 1.58.0 in a Python virtualenv at /opt/streamlit/venv (with pandas and numpy)
  • A sample interactive dashboard app at /var/lib/streamlit/app.py
  • nginx on :80 fronting the loopback Streamlit server with HTTP Basic auth and websocket proxying
  • A dedicated Azure data disk at /var/lib/streamlit holding the app and its data - separate from the OS disk and re-provisioned with every VM
  • streamlit.service + nginx.service as systemd units, enabled and active
  • 24/7 cloudimg support

Prerequisites

An active Azure subscription, an SSH key pair, and a VNet + subnet in the target region. Standard_B2ms (2 vCPU / 8 GiB RAM) is a good starting point; scale up for heavier apps. NSG inbound: allow 22/tcp from your management network and 80/tcp for the app (front with TLS for public exposure - see Enabling HTTPS).

Step 1 - Deploy from the Azure Marketplace

Sign in to the Azure Portal, choose Create a resource, search the Marketplace for Streamlit by cloudimg, and select Create. On Basics 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 Review + create -> Create.

Step 2 - Deploy from the Azure CLI

az vm create \
  --resource-group <your-rg> \
  --name streamlit \
  --image <marketplace-image-urn> \
  --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 streamlit --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 streamlit.service nginx.service

Both services report active. Streamlit starts in a few seconds.

Step 5 - Retrieve your password

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

sudo cat /root/streamlit-credentials.txt

This file contains STREAMLIT_ADMIN_USER (admin) and STREAMLIT_ADMIN_PASSWORD, plus the app URL. Store the password somewhere safe.

Step 6 - Check the health endpoint

nginx serves an unauthenticated health endpoint for load balancers and probes:

curl -s http://localhost/health

It returns ok.

Step 7 - Open the app

Browse to http://<vm-public-ip>/ and sign in as admin with the password from Step 5. The bundled sample app demonstrates Streamlit's building blocks - a sidebar with interactive widgets, metrics, a live line chart and a dataframe. Move the sliders and the app reruns instantly.

Streamlit sample dashboard with sidebar controls, metrics and a live chart

Scroll down for the chart and the data table:

Streamlit live line chart and dataframe

Step 8 - Confirm the server from the command line

Streamlit exposes a health endpoint behind the same Basic auth. Confirm it is serving:

curl -s -u admin:<STREAMLIT_ADMIN_PASSWORD> http://localhost/_stcore/health; echo

It returns ok.

Step 9 - Deploy your own app

Replace the sample script with your own Streamlit app and restart the service:

# edit /var/lib/streamlit/app.py with your Streamlit code, then:
sudo systemctl restart streamlit

Install any extra Python packages your app needs into the bundled virtualenv:

sudo /opt/streamlit/venv/bin/pip install <your-packages>
sudo systemctl restart streamlit

The app reloads and your new dashboard is served at the same URL behind the same auth.

Step 10 - Confirm the app lives on the dedicated disk

Your app and its data are stored on the dedicated Azure data disk so they survive OS changes and can be resized independently:

findmnt /var/lib/streamlit

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

Enabling HTTPS

The nginx reverse proxy terminates plain HTTP on port 80. For public exposure, put a certificate in front of it - add a DNS name for the VM and use the companion cloudimg nginx-ssl-certbot image as a TLS reverse proxy, or install certbot and extend the existing nginx site with a listen 443 ssl; server block. Keep Streamlit bound to loopback so the only public surface is the authenticated, TLS-terminated proxy, which already forwards the websocket Streamlit needs.

Maintenance

  • Your app: edit /var/lib/streamlit/app.py (or point the service at a different file) and sudo systemctl restart streamlit.
  • Packages: install into /opt/streamlit/venv with its pip.
  • Backups: snapshot the /var/lib/streamlit data disk.
  • Upgrades: sudo /opt/streamlit/venv/bin/pip install -U streamlit then sudo systemctl restart streamlit.
  • Security patches: unattended-upgrades remains enabled so the OS continues to receive security updates automatically.

Support

cloudimg provides 24/7 expert support for this image. Contact support@cloudimg.co.uk.