简体   繁体   English

Azure 数据工厂管道 - 如果内部活动失败

[英]Azure Data Factory pipeline - if fails on inner activity

I have developed an Azure Data Factory pipeline that checks the schema of files in the data lake.我开发了一个 Azure 数据工厂管道,用于检查数据湖中文件的架构。 I have 15 files in the "templates format" and I check them against files received from customers.我有 15 个“模板格式”文件,我根据从客户那里收到的文件检查它们。 I have both xlsx and CSV files.我有 xlsx 和 CSV 文件。

在此处输入图片说明

First I take all file names from the template folder and iterate them.首先,我从模板文件夹中获取所有文件名并迭代它们。 I need to check if the current file is excel, as when I need to define whether a file is an xlsx or CSV.我需要检查当前文件是否为 excel,就像我需要定义文件是 xlsx 还是 CSV 一样。

在此处输入图片说明

I want to handle both types of issues.我想处理这两类问题。 First when a schema of the received file is different from the schema of the template.首先,当接收到的文件的模式与模板的模式不同时。 And second when I have not received this file at all.其次,我根本没有收到这个文件。 So in the Set Variable activity, I use this code.所以在 Set Variable 活动中,我使用了这段代码。 So I can use it in switch activity.所以我可以在 switch 活动中使用它。

@concat('Excel',
if(equals(activity('Get Metadata of excel bronze').Status,'Succeeded'),' True' , ' False'),
if(equals(activity('Get Metadata of excel bronze').Status,activity('Get Metadata of excel 
template').Status),' True' , ' False')
)

在此处输入图片说明

However, when I have not received a file and I have a template "Get a metadata of excel" the template fails and the whole "Is Excel" activity fails.但是,当我没有收到文件并且我有一个模板“获取 excel 的元数据”时,模板失败并且整个“是 Excel”活动失败。 Is there a possibility to force if the activity to not fail on error?如果活动不会因错误而失败,是否有可能强制执行? An error is expected in this pipeline.此管道中预计会出现错误。

在此处输入图片说明

You can add a new activity upon failure so that even Get Metadata fails, pipeline keeps running the next steps.您可以在失败时添加新活动,以便即使Get Metadata失败,管道也会继续运行后续步骤。

在此处输入图片说明

Note : When you are connecting 2 different activity outputs to a new activity (set variable activity) as input, the Set Variable activity only runs when both inputs are successful and fails to run if any one of the input activities is failed.注意:当您将 2 个不同的活动输出连接到一个新活动(设置变量活动)作为输入时, Set Variable活动仅在两个输入都成功时运行,如果任何一个输入活动失败则运行失败。

在此处输入图片说明

The workaround is to connect the Get Metadata outputs to 2 different activities.解决方法是将 Get Metadata 输出连接到 2 个不同的活动。

For each Get Metadata activity, add set variable activity (or any other required activity) on success and failure individually to run the pipeline without stopping when error occur.对于每个Get Metadata活动,在成功和失败时单独添加设置变量活动(或任何其他所需的活动)以在发生错误时不停止运行管道。

在此处输入图片说明

Pipeline runs even when Get Metadata2 fails when connected to other activity upon failure.即使在 Get Metadata2 失败时连接到其他活动失败时,管道也会运行。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM