How to deploy a Prefect 2.0 agent to a single VM as your execution layer?

Prerequisites

AWS EC2

GCP Google Compute Engine

https://discourse.prefect.io/t/how-to-deploy-a-prefect-2-0-agent-to-a-vm-on-gcp-google-compute-engine-as-your-execution-layer/1096

Azure VM

https://discourse.prefect.io/t/how-to-deploy-a-prefect-2-0-agent-to-azure-vm-as-your-execution-layer/1097

How to ensure your agent gets restarted after VM gets shut down and rebooted?

https://discourse.prefect.io/t/how-to-ensure-your-agent-gets-restarted-after-vm-gets-shut-down-and-rebooted/1095

I’ve found that the easiest way to deploy an agent on a GCP VM is the following:

gcloud compute instances create-with-container prefect-agent \
		--container-image prefecthq/prefect:2-python3.8 \
		--container-mount-host-path=host-path=/var/run/docker.sock,mount-path=/var/run/docker.sock,mode=rw \
		--container-privileged \
		--container-env PREFECT_API_URL=${PREFECT_API_URL} \
		--container-env PREFECT_API_KEY=${PREFECT_API_KEY} \
		--container-command="prefect" \
		--container-arg="agent" \
		--container-arg="start" \
		--container-arg="-q" \
		--container-arg="YOUR-WORK-QUEUE" \
		--container-restart-policy='always' \
		--boot-disk-size="100Gi" \
		--machine-type="e2-micro" \
		--zone="europe-west4-a"
2 Likes

very cool! thanks so much for sharing :raised_hands:

The link mentioned earlier on Azure VM doesn’t seem to work.

https://discourse.prefect.io/t/how-to-deploy-a-prefect-2-0-agent-to-azure-vm-as-your-execution-layer/1097

Is there a publicly accessible link on how to setup a Prefect agent to run on Azure VM?

1 Like

This link also appears to be broken, sorry, returning a 404 error