I enjoyed @Kevin Kho’s talk at MS build. In the demo, ADF triggers a flow run using a Databricks notebook job to hit the Prefect GraphQL API, using python's
requests
library. Is there a way to trigger a flow run directly from ADF (without databricks as an intermediary)?
upvote 1
k
Kevin Kho
05/28/2021, 8:28 PM
Hi @Tom Baldwin! Thanks for watching! I tried using the Web Activity ADF step to send a request directly but was not successful. I didn’t try hard enough though. You shouldn’t need Python to hit the API endpoint if you can use curl
Kevin Kho
05/28/2021, 8:31 PM
Kevin Kho
05/28/2021, 8:32 PM
I mean this guy. You need to add the appropriate token under the settings there.
t
Tom Baldwin
05/28/2021, 8:36 PM
Thanks, I see. I'm actually not that familiar with ADF, but we are exploring using it as a launcher for some of our Prefect flows. Good to know that this connection ought to be possible in principle!
k
Kevin Kho
05/28/2021, 8:36 PM
This would be the basic Python code snippet:
Copy code
import requests
query = """query {
flow {
name
id
}
}"""
url = '<https://api.prefect.io>'
<http://requests.post|requests.post>(url, json={'query': query}, headers={"authorization": "Bearer insert_token_here",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"})
Kevin Kho
05/28/2021, 8:39 PM
Is your use case that you’re on Azure already and have pipelines there?
t
Tom Baldwin
05/28/2021, 8:57 PM
Yes, we run both Airflow and Prefect on Azure VMs, but it is a client's Azure account and sometimes they prefer us to build things for them in ADF. So I'm curious about ways to use both tools together.
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.