I used DraganB's solution but the call signature on
CreateRunResponse runResponse = client.Pipelines.CreateRun(resourceGroup, dataFactoryName, "pipeline1", parameters);
has changed. Minor edits make this work perfectly:
CreateRunResponse runResponse = client.Pipelines.CreateRun(resourceGroup, dataFactoryName, "pipeline1", parameters: parameters);
Here's the function for anyone that needs it.
[FunctionName("DatafactoryShim")]
public async static Task<HttpResponseMessage> Run(
[HttpTrigger(AuthorizationLevel.Function, "post")]
HttpRequestMessage req,
ExecutionContext context,
TraceWriter log
)
{
string messageBody = await req.Content.ReadAsStringAsync();
BlobToDatalakeFactoryParameters postValues = JsonHelper.ToClass<BlobToDatalakeFactoryParameters>(messageBody);
Dictionary<string, object> parameters = new Dictionary<string, object>
{
{"blobContainer", postValues.BlobContainer},
{"blobFolder", postValues.BlobFolder },
{"relativeDatalakeFolder", postValues.RelativeDatalakeFolder },
{"modelType", postValues.ModelType }
}; //this is how you add initialaze parameters
var client = Authenticate(); //Authentication with azure
string resourceGroup = ConfigurationManager.AppSettings["resourceGroup"];
string dataFactoryName = ConfigurationManager.AppSettings["dataFactoryName"];
string pipelineName = ConfigurationManager.AppSettings["pipelineName"];
Console.WriteLine("Creating pipeline run...");
CreateRunResponse runResponse = client.Pipelines.CreateRunWithHttpMessagesAsync(
resourceGroup,
dataFactoryName,
pipelineName,
parameters: parameters).Result.Body;
Console.WriteLine("Pipeline run ID: " + runResponse.RunId);
var response = new HttpResponseMessage();
if (client.PipelineRuns.Get(ConfigurationManager.AppSettings["resourceGroup"],
ConfigurationManager.AppSettings["dataFactoryName"], runResponse.RunId).Status.Equals("InProgress"))
{
response = new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StringContent(runResponse.RunId, Encoding.UTF8)
};
}
else
{
response = new HttpResponseMessage(HttpStatusCode.BadRequest)
{
Content =
new StringContent("Pipeline didn't started", Encoding.UTF8) //just some validation for function
};
}
return response;
}