Hello @arkiboys ,
Thanks for the ask and using Microsoft Q&A platform .
As we understand the ask here is to invoke a existing pipeline from pyspark . Please do let me know if that not accurate.
You can use the REST API call to the invoke the pipeline from the pyspark . The API which you will need to invoke is Pipeline - Create Pipeline Run
You will need a
- Service prinicipal ( client ID and client secret ) and this service prinicipal should have acess on the workspace .
- Tenantid
- Workspace Name
It has two steps
- Get the bearer token
- Execute the API
https://learn.microsoft.com/en-us/rest/api/synapse/data-plane/pipeline/create-pipeline-run
The below code will return the runid of the pipeline which you are trying to invoke .
import http.client
import json
conn = http.client.HTTPSConnection("login.microsoftonline.com")
payload = 'grant_type=client_credentials&client_id={Yourclientid}&client_secret={client secret}&resource=https%3A%2F%2Fdev.azuresynapse.net%2F'
conn.request("POST"
, "/{tenantID}/oauth2/token"
, payload
, headers)
res = conn.getresponse()
data = res.read()
Response = json.loads(data)
AccessToken = Response["access_token"]conn = http.client.HTTPSConnection("{YourWorkspace}.dev.azuresynapse.net")
payload = ''
headers = {
'Authorization': ' Bearer '+ AccessToken
}
conn.request("POST", "/pipelines/Eventtrigger/createRun?api-version=2020-12-01", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Please do let me if you have any queries .
Thanks
Himanshu
-------------------------------------------------------------------------------------------------------------------------
- Please don't forget to click on
or upvote
button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
- Want a reminder to come back and check responses? Here is how to subscribe to a notification
- If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators