Prefect
Overview
Prefect is a Python workflow orchestration platform. It turns any Python function into an observable, schedulable workflow with retries, caching, concurrency limits and event-driven automation. You monitor every flow run, deployment and work pool from a web UI.
This SecureAnyCloud image installs Prefect 3.7.5 in a dedicated Python virtualenv. It runs the Prefect server as a systemd service, bound to loopback behind an nginx reverse proxy on port 80 with HTTP Basic auth.
What you get:
- Prefect 3.7.5 in a Python virtualenv at
/opt/prefect/venv - The Prefect server (UI and API) on
:80via nginx, with HTTP Basic auth - A unique admin password, generated on the first boot of every VM and stored in a root-only file (Prefect Server has no built-in auth)
- A dedicated Azure data disk at
/var/lib/prefectthat holds the SQLite state database (flow runs, deployments, config). It is separate from the OS disk and re-provisioned with every VM prefect-server.serviceandnginx.serviceas systemd units, enabled and active- 24/7 SecureAnyCloud support
Prerequisites
- An active Azure subscription, an SSH key pair, and a VNet with a subnet in the target region
- NSG inbound rules that allow
22/tcpfrom your management network and80/tcpfor the UI and API. Front the UI with TLS for public exposure (see Enabling HTTPS)
Standard_B2ms (2 vCPU, 8 GiB RAM) is a good starting point. Scale up for many concurrent flow runs.
Step 1 - Deploy from the Azure Marketplace
Sign in to the Azure Portal. Choose Create a resource, search the Marketplace for Prefect by SecureAnyCloud, 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 select Review + create and 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:prefect-ubuntu-24-04:default:latest
az vm create \
--resource-group <your-rg> \
--name prefect \
--image sac1647283583153:prefect-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 prefect --port 80 --priority 1010Step 3 - Connect to your VM
ssh azureuser@<vm-public-ip>Step 4 - Confirm the services are running
systemctl is-active prefect-server.service nginx.serviceBoth services report active. The Prefect server runs a database migration on first boot, and then serves the UI and API.
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/prefect-credentials.txtThis file contains PREFECT_ADMIN_USER (admin), PREFECT_ADMIN_PASSWORD and the URLs. Store the password in a safe place.
Step 6 - Check the health endpoint
nginx serves an unauthenticated health endpoint for load balancers and probes. Request it:
curl -s http://localhost/healthThe endpoint returns ok.
Step 7 - Open the Prefect UI
Browse to http://<vm-public-ip>/ and sign in as admin with the password from Step 5. The dashboard summarises recent flow-run activity. The Runs, Flows, Deployments and Work Pools pages let you drill into every pipeline.
The Runs page charts and lists every flow run with its state. Open a run to see its task runs, timeline and logs.
Step 8 - Confirm the API from the command line
The Prefect API is available behind the same Basic auth. Confirm that it is healthy and report how many flow runs it is tracking:
curl -s -u admin:<PREFECT_ADMIN_PASSWORD> http://localhost/api/health; echo
curl -s -u admin:<PREFECT_ADMIN_PASSWORD> -X POST -H 'Content-Type: application/json' -d '{}' http://localhost/api/flow_runs/count; echo/api/health returns true, and the count endpoint returns the number of flow runs.
Step 9 - Point a client or worker at the server
On your laptop or a worker machine, install Prefect and point it at this server's API. The credentials go in the URL. Then run a flow:
pip install prefect==3.7.5 prefect config set PREFECT_API_URL="http://admin:<password>@<vm-public-ip>/api"
# my_flow.py from prefect import flow @flow(log_prints=True) def hello(name: str = "world"): print(f"Hello {name} from Prefect on Azure!") if __name__ == "__main__": hello()Run python my_flow.py, and the run appears in the UI. To run flows on a schedule, create a work pool and deploy them with prefect deploy.
Step 10 - Confirm state lives on the dedicated disk
The Prefect home and its SQLite database are stored on the dedicated Azure data disk, so they survive OS changes and can be resized independently:
findmnt /var/lib/prefectThe 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 terminates plain HTTP on port 80. For public exposure, put a certificate in front of it. Add a DNS name for the VM, and then choose one of two options:
- Use the companion SecureAnyCloud nginx-ssl-certbot image as a TLS reverse proxy.
- Install certbot and extend the existing nginx site with a listen 443 ssl; server block.
Keep the Prefect server bound to loopback, so that the only public surface is the authenticated, TLS-terminated proxy.
Maintenance
- Backups: snapshot the
/var/lib/prefectdata disk to back up flow runs and deployments. - Database: the image uses SQLite, which suits a single server. For high throughput, migrate
PREFECT_HOME/the API to PostgreSQL. - Upgrades: run
sudo /opt/prefect/venv/bin/pip install -U prefect, and thensudo systemctl restart prefect-server. - Security patches: unattended-upgrades remains enabled, so the OS continues to receive security updates automatically.
Support
SecureAnyCloud provides 24/7 expert support for this image. Contact sales@secureanycloud.com.
Deploy on Azure
Launch Prefect 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
Overview
This image runs Prefect, the open source Python framework for building, running and observing resilient data workflows. You turn ordinary Python functions into orchestrated flows with retries, scheduling, caching, concurrency limits and an observability UI, with no boilerplate.
Prefect 3.7.5 is installed into a dedicated Python virtual environment. The server runs under a systemd service that starts it on boot and restarts it on failure.
What you get:
- Prefect 3.7.5 in a dedicated Python virtual environment under
/opt/prefect, run by an unprivilegedprefectsystem account - A systemd service that starts the server on boot and restarts it on failure
- The server data directory,
PREFECT_HOME, at/var/lib/prefect. It holds the embedded SQLite metadata database, the server logs and storage, on a dedicated, independently resizable EBS data volume that survives an operating system disk reimage - A single node server on the embedded SQLite database, so no external database is required
- The server bound to the loopback interface only (
127.0.0.1:4200), and never exposed directly - An nginx reverse proxy that publishes the server API and the web UI on port 80 behind HTTP Basic authentication. It forwards the WebSocket upgrade and connection headers that the Prefect UI needs for its live event and log streams
- An admin password generated on the first boot of every deployed instance and written to
/root/prefect-credentials.txtwith mode 0600, so that only the root user can read it - An unauthenticated
/api/healthendpoint through the proxy, so that external health checks and load balancers can reach it
The open source Prefect server ships with no built-in authentication, which is why the server stays on loopback behind the authenticated proxy. Two instances launched from the same Amazon Machine Image never share a password.
Prerequisites
Before you deploy this image you need:
- An Amazon Web Services account where you can launch EC2 instances
- IAM permissions to launch instances, create security groups, and subscribe to AWS Marketplace products
- An EC2 key pair in the target Region for SSH access to the instance
- A VPC and subnet in the target Region, with a security group allowing inbound port 22 from your management network and port 80 for the Prefect server and UI
- The AWS CLI (version 2) installed locally if you plan to deploy from the command line
Launch the Instance from the AWS Marketplace
Sign in to the AWS Management Console, open the EC2 service, and select Launch instance. Under Application and OS Images, choose AWS Marketplace AMIs and search for Prefect. Select the SecureAnyCloud listing and choose Select, then Continue on the subscription summary.
Pick an instance type of t3.medium or larger. Choose your EC2 key pair under Key pair (login). Under Network settings, select your VPC and subnet, and create or select a security group that opens port 22 from your management network and port 80 for the Prefect server and UI. Leave the root volume at the default size or larger.
Select Launch instance. First-boot initialisation takes a short time after the instance state becomes Running and the status checks pass. This is when the per-instance admin password is generated and the server runs its first database migrations.
Launch the Instance from the AWS CLI
The following block launches an instance from the SecureAnyCloud Prefect Marketplace AMI into an existing subnet and security group. Replace <ami-id> with the AMI ID shown on the Marketplace listing. Replace <key-name> with your EC2 key pair name and <subnet-id> with your subnet ID. Replace <security-group-id> with a security group that opens ports 22 and 80 as described above.
aws ec2 run-instances \
--image-id <ami-id> \
--instance-type t3.medium \
--key-name <key-name> \
--subnet-id <subnet-id> \
--security-group-ids <security-group-id> \
--tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=prefect}]'When the instance reaches the Running state and its status checks pass, note its public IP address or DNS name. You can find it in the EC2 console or with aws ec2 describe-instances.
Connect to Your Instance
Connect over SSH using your key pair and the login user for your operating system variant. For Ubuntu 24.04, the login user is ubuntu:
ssh -i <key-name>.pem ubuntu@<public-ip>Retrieve the Admin Password
The Prefect UI admin password is unique to your instance. It was generated on first boot. Read it as root:
sudo cat /root/prefect-credentials.txtThe file lists the UI URL, the admin user (admin) and the generated password, along with a ready-to-paste PREFECT_API_URL for connecting workers and clients. Keep this password in a safe place.
Sign In to the Prefect UI
The Prefect server and UI are served on port 80 by nginx behind HTTP Basic authentication. In a browser, go to:
http://<instance-public-ip>/Sign in as admin with the password from the credentials file when prompted. The dashboard gives you a live overview of your flow runs, task runs and work pools, updated in real time over the proxied WebSocket connection.
Open Runs in the left navigation to see every flow run and task run. Filter by state, flow, deployment, work pool or tag, and drill into the logs and timeline of an individual run.
Open Work Pools to create and manage the pools that workers poll for scheduled deployment runs. Pools let you route work to the infrastructure you choose.
Confirm Prefect Is Running
Over SSH, confirm that the server and the nginx proxy are active, check the API health endpoint, and confirm the listening ports:
sudo systemctl is-active prefect nginx curl -s http://127.0.0.1:4200/api/health
sudo ss -tlnp | grep -E ':(80|4200) 'You should see both services reported as active and the health endpoint returning true. The server listens on 127.0.0.1:4200 (loopback only), and nginx listens on port 80.
Confirm the installed Prefect version with the bundled virtual environment:
/opt/prefect/venv/bin/prefect versionWrite and Run Your First Flow
Prefect turns plain Python functions into orchestrated flows and tasks. Create a file etl.py on the instance and run it with the bundled virtual environment, so that the run is recorded against the local server. The following example defines a flow with three tasks and runs it three times:
cat > /tmp/etl.py <<'PYEOF' from prefect import flow, task @task def extract(): return [1, 2, 3, 4, 5] @task def transform(data): return [x * 10 for x in data] @task def load(data): return sum(data) @flow(name="example-etl-pipeline") def etl_pipeline(): raw = extract() clean = transform(raw) return load(clean) if __name__ == "__main__": print(etl_pipeline()) PYEOF PREFECT_API_URL=http://127.0.0.1:4200/api /opt/prefect/venv/bin/python /tmp/etl.pyEach run appears immediately in the Runs view of the UI with its state, logs and timeline. To add retries, caching and concurrency limits to a task, add the matching arguments to the @task decorator. No extra infrastructure is needed.
Connect Workers and Clients
To submit work from another machine or to run a worker, point the Prefect client at this server through the authenticating proxy. The credentials file prints the exact URL. It has the form below, where <password> is the generated admin password and <instance-public-ip> is this instance's public address:
prefect config set PREFECT_API_URL=http://admin:<password>@<instance-public-ip>/apiA worker started against a work pool polls the server for scheduled deployment runs and executes them on its own infrastructure. Create a work pool from the Work Pools view in the UI, or with the bundled CLI on the instance. Then start a worker against it from wherever your code should run.
Install Extra Python Packages
Your flows often need extra libraries. Install them into the bundled virtual environment, so that the server process and flows run with /opt/prefect/venv/bin/python can import them. The virtual environment lives at /opt/prefect/venv and is owned by the prefect service account. Confirm that you are using the bundled pip:
/opt/prefect/venv/bin/pip --versionThen install whatever your flows need, for example sudo /opt/prefect/venv/bin/pip install pandas requests. The virtual environment lives on the dedicated data volume, so your installed packages persist independently of the operating system disk.
The Data Volume
The server data directory, PREFECT_HOME, lives on a dedicated EBS volume mounted at /var/lib/prefect. This keeps the embedded SQLite metadata database, the server logs and the storage off the operating system disk, and lets you resize or snapshot the volume independently. Confirm the mount:
df -h /var/lib/prefectTo grow the data store, expand the EBS volume in the AWS console. Then grow the filesystem on the instance with sudo resize2fs on the underlying device. The directory is owned by the prefect service account.
Enable HTTPS
nginx serves the Prefect server and UI over plain HTTP on port 80. For production use, place them behind TLS.
Obtain a certificate for your domain. For example, use a managed certificate on an Application Load Balancer in front of the instance, or install Certbot on the instance for your-domain.
Then configure nginx to listen on 443 with your certificate and proxy to 127.0.0.1:4200, exactly as the bundled site does for port 80. Keep the HTTP Basic authentication and the WebSocket upgrade headers in place. Restrict the security group so that ports 80 and 443 are reachable only from the networks that need the server and UI.
Backup and Maintenance
Back up the server by snapshotting the /var/lib/prefect EBS volume. The snapshot captures the embedded SQLite metadata database, logs and storage.
Apply operating system security updates with sudo apt-get update && sudo apt-get upgrade, and reboot when a new kernel is installed. The Prefect server and nginx start automatically on boot. The server runs its database migrations automatically when a new Prefect version introduces a schema change.
Support
This image is published and supported by SecureAnyCloud. Support covers deployment, connecting workers and deployments, work pools, scheduling, retries and caching, TLS, authentication and performance tuning. Contact SecureAnyCloud through the support channel listed on the AWS Marketplace listing.
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.
Deploy on AWS
Launch Prefect on AWS with 24/7 support from SecureAnyCloud.
View on Marketplace
Need Help?
Our support team is available 24/7.
sales@secureanycloud.com