Azure Data Factory - Complex Java based ETL to Codeless Pipeline

%3CLINGO-SUB%20id%3D%22lingo-sub-358040%22%20slang%3D%22en-US%22%3EAzure%20Data%20Factory%20-%20Complex%20Java%20based%20ETL%20to%20Codeless%20Pipeline%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-358040%22%20slang%3D%22en-US%22%3E%3CP%20style%3D%22text-align%3A%20justify%3B%22%3EAzure%20Data%20factory%20(ADF)%20is%20a%20fully%20managed%20data%20integration%20tool%20that%20helps%20to%20build%2C%20manage%20and%20orchestrate%20complex%20jobs.%20The%20brand%20new%20UX%20experience%20in%20ADF%20V2%20is%20so%20intuitive%20%26amp%3B%20effortless%20in%20creating%20ADF%E2%80%99s%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdata-factory%2Fconcepts-pipelines-activities%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Epipelines%3C%2FA%3E%2C%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdata-factory%2Fconcepts-pipelines-activities%23data-movement-activities%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Eactivities%3C%2FA%3Eand%20other%20constructs.%20Anyone%20can%20easily%20pick%20up%20this%20tool%20and%20be%20fully%20productive%20in%20few%20days.%20From%20a%20feature%20set%20perspective%2C%20it%20has%20built-in%20connectors%20to%2065%2B%20data%20stores%2C%20works%20very%20well%20in%20a%20hybrid%20environment%20and%20has%20control%20flow%20elements%20to%20design%20even%20most%20complex%20ETL%20workflows.%20More%20information%20about%20ADF%20can%20be%20found%20in%20the%20%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fen-in%2Fservices%2Fdata-factory%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Elink%3C%2FA%3E%3CSPAN%3E.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F84630i33C5474898663F23%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22ADF.png%22%20title%3D%22ADF.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3EI%20wanted%20to%20call%20out%20the%20journey%20one%20of%20the%20customers%20had%20gone%20through%20with%20ADF%20adoption%20and%20how%20it%20modernized%20their%20ETL%20workflow%20and%20the%20best%20part-%20without%20writing%20a%20single%20line%20of%20code!%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3ETheir%20legacy%20data%20integration%20job%20was%20coded%20in%20Java%2C%20spanning%20more%20than%201000%2B%20lines%20and%20scheduled%20as%20batch%20job%20in%20ETL%20virtual%20machine.%20Java%20code%20had%20many%20modules%20(like%20RestAPI%20calls%2C%20storing%20data%20to%20a%20Database%2C%20looping%2Flookup%20on%2C%20retry%20mechanism%20%26amp%3B%20some%20basic%20level%20of%20logging.%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3ETeam%20wanted%20to%20have%20a%20faster%20deployment%20with%20minimalistic%20code%20changes%20to%20their%20codebase.%20Even%20then%20I%20was%20confident%20ADF%20can%20easily%20find%20its%20own%20way%20to%20glory%20once%20tried.%20With%20almost%20no%20prior%20experience%2C%20customer%20was%20able%20to%20use%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdata-factory%2Fcopy-data-tool%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ECopy%20Data%3C%2FA%3Ewizard%20to%20call%20RestAPI%2C%20transform%20data%20%26amp%3B%20and%20store%20to%20database.%20This%20was%20equivalent%20to%20hundreds%20of%20lines%20of%20code%20in%20java.%20And%20thereafter%2C%20customer%20was%20really%20impressed%20with%20the%20richness%20ADF%20provides%20in%20user%20experience%20and%20its%20powerful%20integration%20features.%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3EIn%20the%20end%2C%20entire%20Java%20code%20was%20effortlessly%20translated%20to%20a%20single%20ADF%20pipeline%20with%20zero%20coding%20and%20triggers%20on%20a%20pre-defined%20schedule%20%26amp%3B%20on%20new%20blob%20creation%20event.%20As%20an%20added%20advantage%2C%20ETL%20server%20hosting%20Java%20code%20were%20discarded%2C%20helping%20customer%20to%20reduce%20the%20cost.%20And%20special%20credits%20to%20Abhishek%20Narain%20%E2%80%93%20Program%20Manager%20for%20Azure%20Data%20Factory%2C%20who%20pitched%20in%20every%20time%20whenever%20we%20had%20small%20issues%20with%20ADF%E2%80%99s%20activities%20%26nbsp%3B(there%20is%20no%20better%20place%20than%20Microsoft%20when%20it%20comes%20to%20collaborative%20effort%20).There%20were%20some%20good%20learnings%20%26amp%3B%20tricks%20that%20we%20learned%2C%20which%20might%20be%20helpful%20for%20other%20folks%20such%20as%3A%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CSTRONG%3E1)%20Mapping%20Event%20Trigger%20variables%20to%20Copy%20activity%3C%2FSTRONG%3E%3A%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3EFor%20those%20who%20do%20not%20know%2C%20%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fen-us%2Fblog%2Fevent-trigger-based-scheduling-in-azure-data-factory%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EEvent%20driven%20architecture%3C%2FA%3E(EDA)%20is%20a%20common%20data%20integration%20pattern%20that%20involves%20production%2C%20detection%2C%20consumption%20and%20reaction%20to%20events.%20I%20had%20a%20little%20difficulty%20while%20trying%20to%20connect%20all%20pieces%20together%20for%20mapping%20event%20trigger%20variables%20for%20blob%20creation.%20Abhishek%20had%20explained%20what%20needs%20to%20be%20done%20and%20we%20thought%20it%20will%20be%20helpful%20for%20others%20also%20to%20know%20these%20steps.%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3EBelow%20is%20a%20snippet%20of%20ADF%20pipeline%20that%20gets%20triggered%20whenever%20a%20blob%20is%20uploaded%20to%20the%20container%20which%20is%20continuously%20polled%20by%20ADF.%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F84632iE18F3A4137A363B8%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22MainPipe.png%22%20title%3D%22MainPipe.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3EAt%20first%2C%20let%20us%20start%20with%20creating%20a%20few%20parameters%20for%20the%20Pipeline%20itself.%26nbsp%3B%20For%20a%20simple%20analogy%2C%20I%20would%20compare%20these%20to%20%E2%80%9Cglobal%20variables%E2%80%9D%20in%20your%20programing%20code%2C%20which%20have%20global%20scope%2C%20i.e.%20available%20to%20all%20functions%20inside%20it.%20And%20functions%20can%20be%20considered%20to%20be%20ADF%E2%80%99s%20activities.%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F84633i78975A77B05475AB%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22PipeParameter.png%22%20title%3D%22PipeParameter.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3EIn%20the%20above%20parameters%2C%20most%20important%20ones%20are%20%E2%80%9Cpipeline_SourceFolderName%E2%80%9D%20and%20%E2%80%9Cpipeline_SourceFileName%E2%80%9D%20%2C%20which%20will%20be%20populated%20by%20ADF%E2%80%99s%20event%20triggers%20(%20which%20is%20explained%20below).%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3ENow%20let's%20go%20define%20input%20data%20set.%20In%20my%20use-cases%2C%20json%20file%20uploaded%20into%20a%20container%20is%20defined%20as%20input%20dataset.%20Trigger%20will%20be%20polling%20above%20container%20for%20new%20blob%20creation%20and%20subsequently%20triggers%20the%20ADF%20pipeline.%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3EUnder%20your%20input%20data%20set%2C%20you%20need%20to%20define%202%20more%20parameters.%20These%20are%20only%20in%20the%20scope%20of%20this%20dataset%20and%20are%20not%20visible%20outside%20the%20scope.%20These%20are%20not%20the%20same%20as%20pipeline%20parameters%20which%20were%20defined%20above%20(%20I%20have%20named%20it%20differently%20to%20avoid%20confusion).%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F84634iA441F4AEDCCA2A07%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22DatasetParam.png%22%20title%3D%22DatasetParam.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3EThe%20above%202%20dataset%20parameters%20are%20then%20used%20to%20mention%20the%20File%20path%20in%20the%20connection%20tab%20of%20the%20dataset%20as%20shown%20below.%20These%20expressions%20can%20be%20picked%20by%20using%20a%20dynamic%20content%20pop-up.%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F84635iF4DD926AEEDE99C9%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22DatasetMapping.png%22%20title%3D%22DatasetMapping.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3ENow%20let's%20go%20to%20the%20Pipeline%20Canvas%20and%20drag%20a%20Copy%20Activity.%20In%20this%20example%20I%20have%20named%20it%20%E2%80%9CCopyDataToSQLDWH%E2%80%9D%20since%20blobs%20(json%20file)%20are%20parsed%20and%20ingested%20into%20SQL%20DWH.%20%26nbsp%3BConfiguration%20of%20source%20%26amp%3B%20sink%20are%20covered%20well%20in%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdata-factory%2Fcopy-data-tool%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ECopy%20Wizard%3C%2FA%3Etutorial%2C%20so%20I%20am%20not%20repeating%20it.However%2C%20the%20key%20piece%20here%20is%20to%20link%20input%20dataset%E2%80%99s%20parameters%20with%20pipeline%E2%80%99s%20parameters%20under%20the%20Source%20tab%20as%20show%20below%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F84636i31A525BD58E501AA%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22PipeLineMapping.png%22%20title%3D%22PipeLineMapping.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3EJust%20to%20recap%2C%20what%20has%20been%20mapped%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%20style%3D%22text-align%3A%20justify%3B%22%3EPipeline%20parameter%20for%20Source%20Folder%20Name%20and%20File%20Name%20(basically%20the%20container%20name%20%26amp%3B%20blob%20name)%3C%2FLI%3E%0A%3CLI%20style%3D%22text-align%3A%20justify%3B%22%3EDefined%20Input%20Dataset%E2%80%99s%20parameter%20and%20mapped%20file%20path%20in%20its%20connection%20tab%3C%2FLI%3E%0A%3CLI%20style%3D%22text-align%3A%20justify%3B%22%3EIn%20Pipeline%20Canvas%2C%20in%20Copy%20Activity%E2%80%99s%20Source%20tab%2C%20mapped%20input%20dataset%E2%80%99s%20parameters%20with%20pipeline%E2%80%99s%20parameters%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3EAt%20this%20stage%2C%20you%20have%20mapped%20parameters%20between%20pipeline%20%26amp%3B%20activities.%20And%20as%20the%20final%20stage%2C%20we%20will%20have%20to%20map%20pipeline%20parameters%20to%20trigger%20variables.%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3EClick%20on%20the%20%E2%80%98Trigger%E2%80%99%20button%20to%20create%20an%20Event%20Trigger%20and%20specify%20the%20blob%20name%20%26amp%3B%20folder%20path%20to%20poll%20for%20new%20blob%20creation.%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20894px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F84637i25C61C521CF5FBE5%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22EditTrigger.png%22%20title%3D%22EditTrigger.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3EAnd%20in%20the%20next%20window%2C%20the%20final%20step%20is%20to%20map%20Pipeline%E2%80%99s%20parameters%20to%20dynamic%20value%20generated%20by%20trigger%20which%20are%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%40triggerBody().folderPath%20%3A%20Returns%20the%20container%20path%20on%20which%20trigger%20is%20polling%20for%20new%20files%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%40triggerBody().fileName%20%3A%20Returns%20the%20file%20name%20of%20the%20blob%20which%20is%20picked%20for%20processing.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F84638iA4DCCEEA251C924B%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22EditTrigger2.png%22%20title%3D%22EditTrigger2.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAnd%20that%E2%80%99s%20it.%20After%20successfully%20publishing%20ADF%2C%20whenever%20a%20.json%20file%20(I%20have%20given%20.json%20as%20file%20ending%20path)%20is%20uploaded%20%2C%20ADF%20is%20triggered%20automatically.%20It%20copies%20the%20JSON%20files%20to%20SQL%20DWH%20and%20if%20the%20copy%20activity%20is%20successful%2C%20then%20sends%20email%20by%20posting%20to%20a%20REST%20API%3B%20else%20sends%20error%20message.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CU%3E%3CSTRONG%3E2)%20Power%20of%20Parameter%20%26amp%3B%20Expressio%3C%2FSTRONG%3En%3C%2FU%3E%3A%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdata-factory%2Fcontrol-flow-expression-language-functions%23expressions%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EExpressions%3C%2FA%3Ecan%20appear%20anywhere%20in%20a%20JSON%20string%20value%20and%20always%20result%20in%20another%20JSON%20value.%20If%20a%20JSON%20value%20is%20an%20expression%2C%20the%20body%20of%20the%20expression%20is%20extracted%20by%20removing%20the%20at-sign%20(%40).%20It%20gives%20so%20much%20freedom%20to%20make%20ADF%20pipeline%20modularized.%20It%20helps%20you%20to%20build%20dynamic%20content%2C%20minimize%20repetitions%2C%20minimal%20changes%20in%20code%20deployment%2C%20conditional%20execution%20and%20the%20list%20goes%20on.%20I%20have%20put%20some%20examples%20below%3A%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CU%3ECreating%20dynamic%20message%20content%20with%20runtime%20details%3C%2FU%3E%3C%2FP%3E%0A%3CP%3E%7B%3C%2FP%3E%0A%3CP%3E%3CEM%3E%22message%22%3A%20%22%40%7Bactivity('CopyDataToSQLDWH').output.dataWritten%7D%22%2C%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3E%22dataFactoryName%22%3A%20%22%40%7Bconcat(pipeline().DataFactory%2C'-%20Success')%7D%22%2C%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3E%22pipelineName%22%3A%20%22%40%7Bpipeline().Pipeline%7D%22%2C%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3E%22pipelineRunId%22%3A%20%22%40%7Bpipeline().RunId%7D%22%2C%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3E%22receiver%22%3A%20%22%40pipeline().parameters.receiver%22%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%7D%3C%2FP%3E%0A%3CP%3E%7B%3C%2FP%3E%0A%3CP%3E%3CEM%3E%22message%22%3A%20%22%40%7Bactivity('CopyDataToSQLDWH').error.message%7D%22%2C%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3E%22dataFactoryName%22%3A%20%22%40%7Bconcat(pipeline().DataFactory%2C'-%20Error')%7D%22%2C%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3E%22pipelineName%22%3A%20%22%40%7Bpipeline().Pipeline%7D%22%2C%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3E%22pipelineRunId%22%3A%20%22%40%7Bpipeline().RunId%7D%22%2C%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3E%22receiver%22%3A%20%22%40pipeline().parameters.receiver%22%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%7D%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CU%3EParameterizing%20Key%20Vault%20to%20a%20Blob%20LinkedService%3C%2FU%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3E%7B%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3E%22name%22%3A%20%22ArchiveBlob%22%2C%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3E%22properties%22%3A%20%7B%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3E%22linkedServiceName%22%3A%20%7B%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3E%22referenceName%22%3A%20%22AzureBlobStorage%22%2C%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3E%22type%22%3A%20%22LinkedServiceReference%22%2C%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3E%22parameters%22%3A%7B%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3E%22key_vault_for_archive_blob%22%3A%20%7B%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3E%22value%22%3A%20%22%40dataset().key_vault_for_archive_blob%22%2C%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3E%22type%22%20%3A%20%22Expression%22%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3E%7D%7D%7D%2C%7D%7D%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CU%3EDeducing%20new%20blob%20filename%26nbsp%3B%20by%20concatenating%20Pipeline%20Runtime%20Id%20to%20blob%20name%3C%2FU%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3E%40concat(pipeline().parameters.pipeline_SourceFileName%2C'-'%2Cpipeline().RunId)%3C%2FEM%3E%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-358040%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20Data%20Factory%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

Azure Data factory (ADF) is a fully managed data integration tool that helps to build, manage and orchestrate complex jobs. The brand new UX experience in ADF V2 is so intuitive & effortless in creating ADF’s pipelines, activities and other constructs. Anyone can easily pick up this tool and be fully productive in few days. From a feature set perspective, it has built-in connectors to 65+ data stores, works very well in a hybrid environment and has control flow elements to design even most complex ETL workflows. More information about ADF can be found in the link.

 

ADF.png

 

I wanted to call out the journey one of the customers had gone through with ADF adoption and how it modernized their ETL workflow and the best part- without writing a single line of code!

Their legacy data integration job was coded in Java, spanning more than 1000+ lines and scheduled as batch job in ETL virtual machine. Java code had many modules (like RestAPI calls, storing data to a Database, looping/lookup on, retry mechanism & some basic level of logging.

Team wanted to have a faster deployment with minimalistic code changes to their codebase. Even then I was confident ADF can easily find its own way to glory once tried. With almost no prior experience, customer was able to use Copy Data wizard to call RestAPI, transform data & and store to database. This was equivalent to hundreds of lines of code in java. And thereafter, customer was really impressed with the richness ADF provides in user experience and its powerful integration features.

In the end, entire Java code was effortlessly translated to a single ADF pipeline with zero coding and triggers on a pre-defined schedule & on new blob creation event. As an added advantage, ETL server hosting Java code were discarded, helping customer to reduce the cost. And special credits to Abhishek Narain – Program Manager for Azure Data Factory, who pitched in every time whenever we had small issues with ADF’s activities  (there is no better place than Microsoft when it comes to collaborative effort ).There were some good learnings & tricks that we learned, which might be helpful for other folks such as:

 

1) Mapping Event Trigger variables to Copy activity:

For those who do not know, Event driven architecture (EDA) is a common data integration pattern that involves production, detection, consumption and reaction to events. I had a little difficulty while trying to connect all pieces together for mapping event trigger variables for blob creation. Abhishek had explained what needs to be done and we thought it will be helpful for others also to know these steps.

Below is a snippet of ADF pipeline that gets triggered whenever a blob is uploaded to the container which is continuously polled by ADF.

 

MainPipe.png

 

At first, let us start with creating a few parameters for the Pipeline itself.  For a simple analogy, I would compare these to “global variables” in your programing code, which have global scope, i.e. available to all functions inside it. And functions can be considered to be ADF’s activities.

 

PipeParameter.png

 

In the above parameters, most important ones are “pipeline_SourceFolderName” and “pipeline_SourceFileName” , which will be populated by ADF’s event triggers ( which is explained below).

Now let's go define input data set. In my use-cases, json file uploaded into a container is defined as input dataset. Trigger will be polling above container for new blob creation and subsequently triggers the ADF pipeline.

Under your input data set, you need to define 2 more parameters. These are only in the scope of this dataset and are not visible outside the scope. These are not the same as pipeline parameters which were defined above ( I have named it differently to avoid confusion).

 

DatasetParam.png

 

 

The above 2 dataset parameters are then used to mention the File path in the connection tab of the dataset as shown below. These expressions can be picked by using a dynamic content pop-up.

 

 

DatasetMapping.png

 

Now let's go to the Pipeline Canvas and drag a Copy Activity. In this example I have named it “CopyDataToSQLDWH” since blobs (json file) are parsed and ingested into SQL DWH.  Configuration of source & sink are covered well in Copy Wizard tutorial, so I am not repeating it.However, the key piece here is to link input dataset’s parameters with pipeline’s parameters under the Source tab as show below

 

PipeLineMapping.png

 

Just to recap, what has been mapped:

  • Pipeline parameter for Source Folder Name and File Name (basically the container name & blob name)
  • Defined Input Dataset’s parameter and mapped file path in its connection tab
  • In Pipeline Canvas, in Copy Activity’s Source tab, mapped input dataset’s parameters with pipeline’s parameters

At this stage, you have mapped parameters between pipeline & activities. And as the final stage, we will have to map pipeline parameters to trigger variables.

Click on the ‘Trigger’ button to create an Event Trigger and specify the blob name & folder path to poll for new blob creation.

 

 

EditTrigger.png

 

And in the next window, the final step is to map Pipeline’s parameters to dynamic value generated by trigger which are

@triggerBody().folderPath : Returns the container path on which trigger is polling for new files

@triggerBody().fileName : Returns the file name of the blob which is picked for processing.

 

EditTrigger2.png

 

And that’s it. After successfully publishing ADF, whenever a .json file (I have given .json as file ending path) is uploaded , ADF is triggered automatically. It copies the JSON files to SQL DWH and if the copy activity is successful, then sends email by posting to a REST API; else sends error message.

 

2) Power of Parameter & Expression:

Expressions can appear anywhere in a JSON string value and always result in another JSON value. If a JSON value is an expression, the body of the expression is extracted by removing the at-sign (@). It gives so much freedom to make ADF pipeline modularized. It helps you to build dynamic content, minimize repetitions, minimal changes in code deployment, conditional execution and the list goes on. I have put some examples below:

 

Creating dynamic message content with runtime details

{

"message": "@{activity('CopyDataToSQLDWH').output.dataWritten}",

"dataFactoryName": "@{concat(pipeline().DataFactory,'- Success')}",

"pipelineName": "@{pipeline().Pipeline}",

"pipelineRunId": "@{pipeline().RunId}",

"receiver": "@pipeline().parameters.receiver"

}

{

"message": "@{activity('CopyDataToSQLDWH').error.message}",

"dataFactoryName": "@{concat(pipeline().DataFactory,'- Error')}",

"pipelineName": "@{pipeline().Pipeline}",

"pipelineRunId": "@{pipeline().RunId}",

"receiver": "@pipeline().parameters.receiver"

}

 

Parameterizing Key Vault to a Blob LinkedService

{

"name": "ArchiveBlob",

"properties": {

"linkedServiceName": {

"referenceName": "AzureBlobStorage",

"type": "LinkedServiceReference",

"parameters":{

"key_vault_for_archive_blob": {

"value": "@dataset().key_vault_for_archive_blob",

"type" : "Expression"

}}},}}

 

Deducing new blob filename  by concatenating Pipeline Runtime Id to blob name

@concat(pipeline().parameters.pipeline_SourceFileName,'-',pipeline().RunId)

 

 

0 Replies