Switches

Switch activity in Azure Data Factory: Container with many IFs

,

(2019-October-16) Developing conditional logic of your Azure Data Factory control flow has been simplified with introducing of the Switch activity - https://docs.microsoft.com/en-us/azure/data-factory/control-flow-switch-activity. Official documentation resource states, this new data factory activity "provides the same functionality that a switch statement provides in programming languages". I would also add a more simplified definition of the Switch activity in Azure Data Factory: it is a container (or wrapper) for multiple IF conditions.

Image by Bruno Glätsch from Pixabay

If I didn't have Switch activity in the ADF, this would be my way to create logic with multiple conditions to process files based on a File_Action parameter-flag.

Where each of the IF conditions would have the following expressions to evaluate:

a) @equals(pipeline().parameters.FileAction,'move')

b) @equals(pipeline().parameters.FileAction,'copy')

c) @equals(pipeline().parameters.FileAction,'delete')

And each of IF activity containers would have the following list of sub-tasks:

a) Copy Data; Delete

b) Copy Data

c) Delete

However the new logical control flow for my ADF pipeline may look a bit simpler with only "Get Metadata" and "Switch" activities:

My Switch activity expression would be just set to my pipeline parameter value: @pipeline().parameters.FileAction

and on the next tab, I can define different cases that need to be evaluated:

You can also notice sub-tasks associated with each different case, "move" case has two tasks indeed.

And after executing this ADF pipeline with 'copy' value for FileAction parameter, you can even check how many files got copied.

The code of this ADF pipeline can be found here:

https://github.com/NrgFly/Azure-DataFactory/blob/master/Samples/pipeline/Workflow_Switch_activity_pl.json

Let me know what your thoughts are about this new ADF activity.

Original post (opens in new tab)

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating