<@ULVA73B9P> How do I deploy to a process worker, ...
# ask-marvin
c
@Marvin How do I deploy to a process worker, using a repository on Azure Devops
m
To deploy a flow to a Process Worker using a repository on Azure DevOps, follow these summarized steps: 1. Provision Infrastructure: Set up an Azure Container Registry (ACR) and create an identity with appropriate permissions to access the registry. Example excerpt:
Copy code
- Create an ACR registry for image hosting
   - Create an identity for Azure Container Instance to allow access to the registry
   - Create Azure Container Instance credentials
2. Set up CI/CD: Ensure your CI/CD pipeline on Azure DevOps builds and pushes Docker images for your flow code to ACR. Then, use the Prefect CLI to create or update deployments based on these images. Example of pushing image and updating deployment:
Copy code
Successfully built image '***/cicd-example:latest'
   Successfully pushed image '***/cicd-example:latest'
   Successfully created/updated all deployments!
3. Configure Prefect Cloud: Create credentials and necessary work pools in Prefect Cloud that link to your provisioned infrastructure. Example credential creation:
Copy code
Creating ACI credentials block
   ACI credentials block 'aci-push-pool-credentials' created in Prefect Cloud
   Assigning Contributor role to service account
   Creating Azure Container Registry
   Provisioning infrastructure... 100%
   Infrastructure successfully provisioned for 'my-aci-work-pool' work pool!
   Created work pool 'my-aci-work-pool'!
4. Start Local Process Worker: For local debugging, you can start a local process worker and update the deployment's work pool to target this local worker.
Copy code
prefect worker start -p my-local-machine
For a complete guide, refer to the detailed documentation in Prefect Docs: - Work Pools and Local Debugging: https://docs.prefect.io/latest/concepts/work-pools/ - CI/CD Guide: https://docs.prefect.io/latest/guides/ci-cd/ - Azure DevOps Deployment Example: https://docs.prefect.io/latest/guides/deployment/push-work-pools/ If you encounter specific issues, the GitHub issue tracker can be invaluable. Here's a relevant issue for reference: - Temp path issue in Process Worker on Windows I hope this helps. Feel free to ask more specific questions if needed.
c
@Marvin I am using Prefect 2.18.3 Server version, I need to use a Process worker (no docker)
m
Here’s how to deploy a flow to a Process Worker using Prefect 2.18.3 (Server Version) without relying on Docker: 1. Configure Environment Variables: Set your Prefect API URL and API key as environment variables:
Copy code
export PREFECT_API_URL='http://<YOUR-PREFECT-SERVER-URL>:4200/api'
   export PREFECT_API_KEY='<YOUR-API-KEY>'
2. Create a Work Pool: Ensure you have a work pool created in your Prefect environment to handle the Process Worker.
Copy code
prefect work-pool create "my-work-pool"
3. Start the Process Worker: Run the Process Worker associated with the created work pool. You can start the worker on your local machine.
Copy code
prefect worker start -p my-work-pool
4. Deploy Your Flow: When deploying your flow, specify the work pool you created. Here is an example of how you might create a deployment from your flow code:
Copy code
python
   from prefect import Flow
   
   with Flow("example-flow") as flow:
       # define your tasks here

   flow.deploy("example-flow-deployment",
               work_pool_name="my-work-pool")
Let's summarize the steps with practical details: 1. Set Environment
Copy code
export PREFECT_API_URL='http://<YOUR-PREFECT-SERVER-URL>:4200/api'
   export PREFECT_API_KEY='<YOUR-API-KEY>'
2. Create Work Pool
Copy code
prefect work-pool create "my-work-pool"
3. Start Worker Locally
Copy code
prefect worker start -p my-work-pool
4. Deploy Flow
Copy code
python
   from prefect import Flow

   with Flow("example-flow") as flow:
       pass  # Define your tasks

   flow.deploy("example-flow-deployment", work_pool_name="my-work-pool")
For further specifics, you can refer to the relevant pages in the Prefect documentation: - Prefect Deployment Guide: https://docs.prefect.io/latest/guides/prefect-deploy/ - Serverless Workers Guide: https://docs.prefect.io/latest/guides/deployment/serverless-workers/ This should comprehensively cover deploying a flow using a Process Worker in Prefect 2.18.3 Server version without requiring Docker. If any issue arises, leveraging the Prefect community and GitHub issue tracker can be beneficial.