Hi, is there a way to trigger a flow run similar t...
# prefect-getting-started
j
Hi, is there a way to trigger a flow run similar to a webhook logic without using prefect cloud? I have all of my infrastructure on Azure, and I wanted to trigger a flow run when a file is created on datalake.
n
hi @João Vitor Bezerra - today you can hit
POST /create_flow_run_from_deployment
from within an azure function that you have setup to trigger when a file lands (im more familiar personally with SNS -> lambda personally, but should be roughly the same idea in azure) but stay tuned for an update in the relatively near future that will make this easier
j
hey Nate, thanks for the reply. The Azure part is straight forward, I will probably use 1. File Created => Bus Service 2. Bus Service => Azure Functions 3. This part is somewhat confusing though, Azure Functions -> Prefect. Ideally on step 3 we would use webhooks or expose some simple API, but I am not sure why we can’t use that webhook syntax when deploying “locally” (other than Prefect Cloud). Can you provide more instructions regarding your
POST /create_flow_run_from_deployment
My objective is to trigger a simple flow by an http request from an external service Many thanks once again!
Just to clarify, if you can point me to some post, provide any example or whatever helps me figure this out. being able to add this layer of observability to the functions triggers would really enhance the use case for me, thanks
n
hi @João Vitor Bezerra - for now, using prefect server you'd have to hit your own Prefect REST API from the azure function (3), POSTing parameters to
/create_flow_run_from_deployment
with some http client like curl / requests / httpx in your case you should be able to build your
parameters
/ call your existing deployments from within the azure function based on the features of the event you get from azure's
Bus Service
, and see your flow runs in the UI after (Events and Automations are currently cloud-only services - but in case it's ever useful) in cloud, when you curl a prefect webhook you're creating an
Event
that an
Automation
can listen for, observe, and/or take
action
in response to (if a
trigger
is activated) you could create a webhook with a jinja template to render the JSON your flow run needs for its
parameters
then point anything at that (e.g. GitHub API can send you github repo events) a
trigger
defines when to execute the
action
in terms of: • which types of
Event
you to
expect
to see with certain features (e.g.
my.webhook.called
with some label) • how many instances of those events we should see before doing something (
threshold
) an
action
is what do actually do when a
trigger
is activated / executed: •
Run a Deployment
is a common
action
so ultimately in cloud we also
POST
json serializable
parameters
to
/create_flow_run_from_deployment
but via the
Events
system instead
❤️ 1
j
Thank you SO much
catjam 1
137 Views