Artificial Intelligence (AI) Azure

vLLM on Ubuntu 24.04 on Azure User Guide

| Product: vLLM on Ubuntu 24.04 LTS on Azure

Overview

This guide covers the deployment and configuration of vLLM on Ubuntu 24.04 on Azure using cloudimg Azure Marketplace images. vLLM is a high-throughput, memory-efficient inference and serving engine for large language models. Its PagedAttention scheduler delivers leading serving throughput, and it exposes an OpenAI-compatible REST API (/v1/chat/completions, /v1/completions, /v1/models) so existing OpenAI SDK code works unchanged.

The image installs the pinned vLLM release into a dedicated Python virtual environment at /opt/vllm and runs it under systemd. The vLLM server binds to loopback only (127.0.0.1:8000) with its native API-key authentication enabled; nginx is the sole network-facing surface and terminates TLS on port 443 while independently enforcing the same per-VM bearer API key.

GPU required. vLLM serves models on an NVIDIA GPU. Launch this image on an Azure NC or ND-series (Ampere or newer) NVIDIA GPU VM and add the NVIDIA GPU Driver Extension; vllm.service then serves the model on the GPU (Step 3 shows how to start it once the driver is in). On a VM with no GPU the service intentionally does not start — it logs a clear diagnostic rather than falling back to a broken state. See Step 3 to enable GPU acceleration.

Security by design — no anonymous access, no default login. vLLM's OpenAI-compatible API ships open, so an exposed port is an open model API for anyone who can reach it. On the very first boot, this image generates a per-VM bearer API key and writes it into both the vLLM service environment and the nginx auth map, and it regenerates a fresh self-signed TLS certificate for this specific VM (the certificate Subject Alternative Names hold the VM's hostname and the address Azure reports for the VM; with a Standard SKU public IP that is the private address, see Issue the certificate for your public address under Step 6). Anonymous requests to the inference API return HTTP 401 with a WWW-Authenticate: Bearer challenge; only the per-VM key is accepted. The open GET /health endpoint stays available for load-balancer probes. The key is written to /root/vllm-credentials.txt (mode 0600, root only). No shared or default key ships in the image.

What is included:

  • vLLM installed into a dedicated Python 3.12 virtual environment at /opt/vllm, run under systemd as the unprivileged vllm system user

  • The vLLM server bound to loopback only (127.0.0.1:8000) — never directly network exposed — with its native API-key authentication enabled

  • nginx terminating TLS on :443 and enforcing a per-VM bearer API key on the inference API; GET /health stays open for health probes

  • Port :80 returns a 301 redirect to HTTPS for every path except an unauthenticated /health endpoint (HTTP 200)

  • A per-VM bearer API key generated on first boot and stored in /root/vllm-credentials.txt (0600) — no anonymous access, no shared default key

  • A self-signed TLS certificate regenerated per VM on first boot (SAN holds the hostname and the address Azure reports for the VM, which is the private address with a Standard SKU public IP) — replace it with your own CA-signed certificate for production

  • A small open-weights starter model (Qwen/Qwen2.5-1.5B-Instruct, Apache-2.0) set as the default model and staged in the HuggingFace cache at /var/lib/vllm/hf/hub. On its first start on a GPU VM vLLM still downloads the model's weights (about 3 GB) from huggingface.co into /var/lib/vllm/hf, so the VM needs outbound HTTPS (see Step 8)

  • A best-effort update to the latest vLLM release on first boot (offline-safe: ships a working pinned build regardless)

  • Ubuntu 24.04 LTS base with latest security patches applied at build time

  • Azure Linux Agent for seamless cloud integration and SSH key injection

  • cloudimg's support team on hand 24 hours a day by email (support@cloudimg.co.uk), with a guaranteed response within 24 hours

Prerequisites

  • Active Azure subscription, SSH public key, VNet + subnet in target region

  • Subscription to the vLLM listing on Azure Marketplace

Recommended virtual machine size: vLLM requires an NVIDIA GPU for inference, and its default attention backend requires Ampere or newer (the A10 and the A100). The older Turing/T4 generation (the NCasT4_v3 sizes) is not supported. A good starting point is Standard_NC24ads_A100_v4 (24 vCPU, 220 GB RAM, one NVIDIA A100 80 GB); the A10-based NVadsA10_v5 sizes also work well. Not every NV size has an NVIDIA GPU: the NVv4 sizes (such as Standard_NV4as_v4) carry AMD GPUs, and vLLM cannot use them. Larger models and higher concurrency need more GPU memory. The image installs and configures correctly on any VM size, but real inference only runs once the VM has an NVIDIA GPU and driver.

Step 1: Deploy from the Azure Portal

Search vLLM in Marketplace, select the cloudimg publisher, click Create, and choose an NC or ND-series GPU VM size. NSG rules: TCP 22 (admin), TCP 443 (inference API over HTTPS), and TCP 80 (HTTP to HTTPS redirect and health probe) from your client networks.

Step 2: Deploy from the Azure CLI

# Deploy on a GPU VM size (subscription <sub-id>). Replace the gallery image version.
RG="vllm-prod"; LOCATION="eastus"; VM_NAME="vllm-01"
IMAGE_URN="cloudimg1647283583153:vllm-ubuntu-24-04:default:latest"
SSH_KEY="$(cat ~/.ssh/id_rsa.pub)"
az group create --name "$RG" --location "$LOCATION"
az network vnet create -g "$RG" --name vllm-vnet --address-prefix 10.100.0.0/16 --subnet-name vllm-subnet --subnet-prefix 10.100.1.0/24
az network nsg create -g "$RG" --name vllm-nsg
az network nsg rule create -g "$RG" --nsg-name vllm-nsg --name allow-ssh --priority 100 \
  --source-address-prefixes "<your-mgmt-cidr>" --destination-port-ranges 22 --access Allow --protocol Tcp
az network nsg rule create -g "$RG" --nsg-name vllm-nsg --name allow-https --priority 110 \
  --destination-port-ranges 443 --access Allow --protocol Tcp
az network nsg rule create -g "$RG" --nsg-name vllm-nsg --name allow-http --priority 120 \
  --destination-port-ranges 80 --access Allow --protocol Tcp
# Accept the Marketplace terms once per subscription (required before the first CLI deploy)
az vm image terms accept --urn cloudimg1647283583153:vllm-ubuntu-24-04:default:latest

az vm create -g "$RG" --name "$VM_NAME" --image "$IMAGE_URN" \
  --size Standard_NC24ads_A100_v4 --admin-username azureuser --ssh-key-values "$SSH_KEY" \
  --vnet-name vllm-vnet --subnet vllm-subnet --nsg vllm-nsg --public-ip-sku Standard

Step 3: Enable GPU acceleration (NVIDIA GPU Driver Extension)

vLLM needs the NVIDIA driver present on the VM. On an NC/ND-series GPU VM, add the NVIDIA GPU Driver Extension, which installs the datacenter driver:

# Add the NVIDIA driver to the GPU VM you created in Step 2 (subscription <sub-id>).
az vm extension set -g "$RG" --vm-name "$VM_NAME" \
  --name NvidiaGpuDriverLinux --publisher Microsoft.HpcCompute --version 1.9 \
  --settings '{}'

If the extension does not install on your VM, install the driver from Canonical's prebuilt packages instead, then reboot:

sudo apt-get update
sudo apt-get install -y ubuntu-drivers-common
sudo ubuntu-drivers install
sudo reboot

vllm.service is enabled, so it starts on every boot once the driver is installed: after the sudo reboot above, or if the extension rebooted the VM, it is already running. If the VM was not rebooted, start it by hand. On the first boot, with no driver, the service gave up after three start attempts and stays failed until you do:

sudo systemctl reset-failed vllm.service
sudo systemctl restart vllm.service

Confirm the GPU is visible with nvidia-smi and the service is active with sudo systemctl status vllm.service.

Step 4: Confirm the service and retrieve the API key

SSH in as azureuser. vLLM is installed in the /opt/vllm venv; nginx fronts it on :443, and the vLLM server binds loopback :8000 only. First boot also starts a background update of vLLM to the newest release (vllm-latest-update.service, log /var/log/cloudimg-vllm-update.log). It can run for up to 15 minutes and replaces packages in the venv, so the import vllm line below can fail until it has finished. systemctl is-active vllm-latest-update.service prints inactive once it is done:

/opt/vllm/bin/python -c 'import vllm; print("vLLM", vllm.__version__)'
systemctl is-active nginx.service
systemctl is-enabled vllm.service
ss -tln | grep -E ':443 |:80 '

vLLM installed in the /opt/vllm venv with nginx.service active and vllm.service enabled (starts on a GPU VM); ss shows nginx public on :443 TLS and :80 while the vLLM server binds 127.0.0.1:8000 loopback only

Retrieve the per-VM bearer API key (root-only file):

sudo grep '^VLLM_API_KEY=' /root/vllm-credentials.txt

Step 5: The security model — no default login

vLLM ships with no authentication, so this image never exposes it directly. nginx enforces the per-VM bearer key: the open health endpoint answers without auth, an anonymous inference request is rejected with 401, and only the per-VM key is accepted. Verify it on the VM (the -k flag skips the self-signed cert check; to check the certificate instead use --cacert /etc/nginx/tls/vllm.crt and run curl with sudo, because /etc/nginx/tls is root only, or use your own CA cert):

KEY="$(sudo grep '^VLLM_API_KEY=' /root/vllm-credentials.txt | cut -d= -f2-)"
echo -n 'open   /health          -> '; curl -sk -o /dev/null -w '%{http_code}\n' https://127.0.0.1/health
echo -n 'anon   /v1/models       -> '; curl -sk -o /dev/null -w '%{http_code}\n' https://127.0.0.1/v1/models
echo -n 'keyed  /v1/models       -> '; curl -sk -o /dev/null -w '%{http_code}\n' -H "Authorization: Bearer $KEY" https://127.0.0.1/v1/models

The open endpoint returns 200, the anonymous inference request returns 401, and the keyed request is accepted by nginx (it returns the model list as 200 once the GPU-backed vLLM upstream is serving; before then nginx forwards the accepted request and reports the upstream as unavailable).

The open /health endpoint returns HTTP 200; an anonymous GET /v1/models is rejected with HTTP 401 and a WWW-Authenticate: Bearer challenge; the same request with the per-VM bearer key is accepted by the nginx auth layer, proving no anonymous access and no default login

Step 6: GPU-required behaviour

vLLM is GPU-required. On a VM with no NVIDIA GPU, vllm.service does not start — it logs a clear diagnostic so the state is never ambiguous. After three attempts systemd stops retrying, so systemctl is-active vllm.service prints failed; that is expected on a VM with no GPU. Once the NVIDIA driver is present and the service is started (Step 3), it serves on the GPU.

vLLM is GPU-required: on a VM without an NVIDIA GPU the service refuses to start and logs a clear diagnostic pointing to the NVIDIA GPU Driver Extension and a recommended Ampere GPU size; on a customer NC/ND GPU VM the service starts and serves automatically

Issue the certificate for your public address

First boot puts the address Azure reports into the TLS certificate, the credentials file and the login banner. With a Standard SKU public IP (the Azure default, and the --public-ip-sku Standard in Step 2) the current image records the VM's private address (for example 10.100.1.4), so a client that trusts vllm.crt with --cacert (or an SDK that verifies TLS) refuses it at the public IP (curl: (60) SSL: no alternative certificate subject name matches). Check:

sudo grep '^VLLM_URL=' /root/vllm-credentials.txt

If it shows a private 10. address, issue a new certificate for the public IP on the VM. Azure's instance metadata service reports the public IP to the VM itself; nothing leaves the VM:

PUBLIC_IP=$(curl -s -H Metadata:true 'http://169.254.169.254/metadata/loadbalancer?api-version=2020-10-01' | grep -o '"frontendIpAddress":"[^"]*"' | head -1 | cut -d'"' -f4)
PRIV=$(hostname -I | awk '{print $1}'); echo "public $PUBLIC_IP, private $PRIV"
sudo openssl req -x509 -nodes -days 3650 -newkey rsa:2048 \
  -keyout /etc/nginx/tls/vllm.key -out /etc/nginx/tls/vllm.crt \
  -subj "/C=GB/O=cloudimg/CN=$PUBLIC_IP" \
  -addext "subjectAltName=IP:127.0.0.1,DNS:localhost,DNS:$(hostname -s),IP:$PRIV,IP:$PUBLIC_IP"
sudo chmod 0600 /etc/nginx/tls/vllm.key
sudo sed -i "s/\b$PRIV\b/$PUBLIC_IP/g" /root/vllm-credentials.txt /etc/update-motd.d/90-vllm
sudo systemctl restart nginx

For a DNS name, set PUBLIC_IP to the name and write DNS:$PUBLIC_IP in place of IP:$PUBLIC_IP. Your API key does not change. Copy the new /etc/nginx/tls/vllm.crt to your clients (the folder is root only, so sudo cat /etc/nginx/tls/vllm.crt prints it) and use --cacert vllm.crt in place of -k below.

Step 7: Call the OpenAI-compatible API

From a client that can reach the VM, list models and run a chat completion. Replace <vm-ip> with your VM public IP and <key> with the value from Step 4 (add --cacert with the VM certificate, or -k for the self-signed cert during testing):

# List the served models
curl -k -H "Authorization: Bearer <key>" https://<vm-ip>/v1/models

# Chat completion
curl -k -H "Authorization: Bearer <key>" -H "Content-Type: application/json" https://<vm-ip>/v1/chat/completions \
  -d '{"model":"Qwen/Qwen2.5-1.5B-Instruct","messages":[{"role":"user","content":"Say hello in one sentence."}]}'

A successful /v1/chat/completions call returns an OpenAI-style JSON response with a choices[0].message.content field containing the model's reply.

Step 8: Configuration and serving a different model

The service reads its model name and API key from /etc/vllm/vllm.env; the build staged the starter model in the HuggingFace cache under /var/lib/vllm/hf/hub (the folder belongs to the vllm user, so list it with sudo):

sudo sed 's/^VLLM_API_KEY=.*/VLLM_API_KEY=REDACTED/' /etc/vllm/vllm.env
sudo find -L /var/lib/vllm/hf -type f -name '*.safetensors' | sed 's#.*/hub/##'

The vLLM service environment file showing the served model and a masked per-VM API key; the pre-downloaded Qwen2.5-1.5B-Instruct starter model staged in the HuggingFace cache; and the root-only per-VM credentials file with the API key masked

On its first start vLLM does not load these staged weights. The unit runs vllm serve with --download-dir /var/lib/vllm/hf, one folder above hub, so vLLM first downloads the model's weights (about 3 GB) from huggingface.co into /var/lib/vllm/hf/models--Qwen--Qwen2.5-1.5B-Instruct. The VM needs outbound HTTPS for that, and a keyed /v1/models request answers 502 until the download and the model load have finished. Follow the progress with sudo journalctl -u vllm.service -f.

To serve a different model, edit MODEL in /etc/vllm/vllm.env and restart the service (larger models need more GPU memory). The model in this example is gated: accept its licence on Hugging Face and add a line HF_TOKEN=<your-token> to /etc/vllm/vllm.env first, or the download is refused (a model that is not gated needs no token):

# On the VM, as root — set MODEL to any HuggingFace model id (subscription <sub-id> example):
sudo sed -i 's#^MODEL=.*#MODEL=meta-llama/Llama-3.1-8B-Instruct#' /etc/vllm/vllm.env
sudo systemctl restart vllm.service

Step 9: Use with the OpenAI SDK

Point any OpenAI SDK, LangChain, or LlamaIndex client at the VM by setting the base URL and the per-VM key. The SDK checks the server certificate, so the client must first trust the VM's certificate (see Issue the certificate for your public address under Step 6) or the VM must have your own CA-signed certificate:

from openai import OpenAI
client = OpenAI(base_url="https://<vm-ip>/v1", api_key="<key>")
resp = client.chat.completions.create(
    model="Qwen/Qwen2.5-1.5B-Instruct",
    messages=[{"role": "user", "content": "Explain PagedAttention in one sentence."}],
)
print(resp.choices[0].message.content)

For production, replace the self-signed certificate at /etc/nginx/tls/vllm.crt and /etc/nginx/tls/vllm.key with your own CA-signed certificate (keep the same paths) and reload nginx, so clients can verify the endpoint without -k.

Step 10: Model storage and backups

The model cache lives at /var/lib/vllm/hf on the OS disk: the service downloads model weights there (its --download-dir). For large model libraries, attach a separate Azure managed data disk, format it and mount it at /var/lib/vllm/hf, so model weights sit on an independently sized and snapshot-able volume. Stop vllm.service first, copy the existing folder onto the disk, keep the owner vllm:vllm, add the mount to /etc/fstab, then start the service again. Changing HF_HOME in /etc/vllm/vllm.env does not move the weights, because --download-dir is fixed in the unit. Snapshot the disk with the Azure CLI on your own schedule.

Support

cloudimg's support team is on hand 24 hours a day by email (support@cloudimg.co.uk), with a guaranteed response within 24 hours. Contact support@cloudimg.co.uk for help with vLLM deployment, model selection, GPU sizing, throughput tuning, quantization, the OpenAI-compatible API, TLS termination, and scaling.

All product and company names are trademarks or registered trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them.