I am coping data from blob storage to SQL database. In source I have multiple files with different schema so when schema doesn’t match to destination table it fails copy data for that file.
I want pipeline to be succeeded even though one iteration of for each activity failed.
Please help me to resolve the issue.
2
Answers
Can you predict how the schema of the file differs when it fails? Suppose that, if the file is the correct schema, it will certainly have Column A; and if the file is not the correct schema, it will not have A. You can add steps prior to the copy so that you only try to copy if A is present. This is in fact what I am doing in a similar situation.
You can check for the presence of a any given column name by adding a
Get Metadata
activity to theFor Each
, then one of the Conditional activities with an expression that looks for that column and if true, does copy; if false, does nothing.My method is a bit more complicated, I have this logic in a pipeline that I then call from other pipelines. There is an extra
ForEach
for this reason. You could skip that. The use of the daisy-chained parameters so that this can be called from other pipelines to change the column name to search for makes it a bit less flexible, I don’t recommend trying to get it working the first time like this. But this will at least show the general idea.To make the pipeline succeed even after failure of single iteration, please handle a fail flow :
In this case, even if any iteration fails, the pipeline is in success state.