Skip to content

Instantly share code, notes, and snippets.

@Gorgoras
Created September 6, 2019 13:58
Show Gist options
  • Save Gorgoras/1fe534fd9b454412f81c8203c773c483 to your computer and use it in GitHub Desktop.
Save Gorgoras/1fe534fd9b454412f81c8203c773c483 to your computer and use it in GitHub Desktop.
Call ADF pipeline with parameters, authenticating with a user or with a service principal.
from azure.mgmt.datafactory import DataFactoryManagementClient
from azure.common.credentials import UserPassCredentials #To login with user and pass, use this.
from azure.common.credentials import ServicePrincipalCredentials #To login with service principal (appid and client secret) use this
subscription_id = "subsID"
#Use only one of these, depending on how you want to login.
credentials = UserPassCredentials(username="user@yourdomain.com", password="yourpass") #To login with user and pass
credentials = ServicePrincipalCredentials(client_id='appid', secret='client secret', tenant='tenantid') #To login with serv ppal
adf_client = DataFactoryManagementClient(credentials, subscription_id)
rg_name = "resource group name"
df_name = "data factory name"
p_name = "pipeline name"
params = {
"Param1":"value1",
"Param2":"value2"
}
adf_client.pipelines.create_run(rg_name, df_name, p_name, params)
@saviourofdp
Copy link

Thanks for this - it was exactly what I was looking for. However I think the API may have changed and I needed to use named parameters to get this to work for me

adf_client.pipelines.create_run(
    resource_group_name = rg_name, 
    factory_name = df_name, 
    pipeline_name = p_name, 
    parameters = params
)

@Sushrutha2012
Copy link

how to call a trigger instead using params

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment