I enjoyed <@U01QEJ9PP53>’s <talk at MS build>. In ...
# ask-community
t
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
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
I mean this guy. You need to add the appropriate token under the settings there.
t
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
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"})
Is your use case that you’re on Azure already and have pipelines there?
t
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.
k
Ah I see. Thanks!