让我先言一下,我是Logic Apps和Data Factory的新手。无论如何,我目前正在进行集成,其中一部分是我需要从Logic Apps触发数据工厂中的管道。我已经成功地做到了, one 部分我似乎无法弄清楚如何将参数传递给我的管道。我试过在“参数”和“参数”下改变JSON。 “触发”部分但到目前为止尚未点击任何内容。管道最终执行,但仅使用默认参数。
有人在这方面取得了成功吗?任何帮助表示赞赏。
答案 0 :(得分:2)
您可以使用逻辑应用程序的“创建管道运行”操作的body属性将参数传递给管道。与往常一样,请小心,因为此操作不仅在预览中,而且在任何MS文档中也找不到此解决方案。我只是根据其他类似动作的格式进行了有根据的猜测。
示例:
"Run_my_pipeline": {
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['azuredatafactory']['connectionId']"
}
},
"method": "post",
"body": {
"param1": "myParamValue",
"param2": "myParamValue"
},
"path": "...",
"queries": {
"x-ms-api-version": "2017-09-01-preview"
},
"authentication": "@parameters('$authentication')"
}
}
答案 1 :(得分:1)
正如我在评论中所说,我使用azure函数创建了一个解决方法。 Azure功能和逻辑应用程序协同工作。 在此链接上,您可以看到如何使用.net创建和管理管道 https://docs.microsoft.com/en-us/azure/data-factory/quickstart-create-data-factory-dot-net
如果你已经有ADF和管道,你只想运行它(使用管道)然后你可以
Dictionary<string, object> parameters = new Dictionary<string, object>
{
{"BoxSerialNumbers", req.BoxSerialNumbers},
{"StartDate", req.StartDate },
{"EndDate",req.EndDate },
{"Recipient", req.Recipient }
};//this is how you add initialaze parameters
var client = Authenticate(); //Authentication with azure
log.Info("Creating.");
CreateRunResponse runResponse = client.Pipelines.CreateRun(resourceGroup, dataFactoryName, "pipeline1", parameters);//run pipeline, you can do this async (it's better)
log.Info("Created.");
var response = new HttpResponseMessage();
if (client.PipelineRuns.Get(resourceGroup, 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;
public static DataFactoryManagementClient Authenticate()
{
var context = new AuthenticationContext("https://login.windows.net/" + tenantID);
ClientCredential cc = new ClientCredential(applicationID, authenticationKey);
AuthenticationResult result = context.AcquireTokenAsync("https://management.azure.com/", cc).Result;
ServiceClientCredentials cred = new TokenCredentials(result.AccessToken);
return new DataFactoryManagementClient(cred) { SubscriptionId = subscriptionID };
}
因此,在请求中,您可以从逻辑应用程序传递参数,使用runId可以检查状态。然后在逻辑应用程序中只需简单的HTTP请求即可调用此函数。希望这有助于某人。
答案 2 :(得分:1)
我使用了DraganB的解决方案,但呼叫签名已启用
CreateRunResponse runResponse = client.Pipelines.CreateRun(resourceGroup, dataFactoryName, "pipeline1", parameters);
已更改。较小的修改使此工作完美完成:
CreateRunResponse runResponse = client.Pipelines.CreateRun(resourceGroup, dataFactoryName, "pipeline1", parameters: parameters);
这是任何需要它的人的功能。
[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;
}