AzDataFactoryV2DataflowDependencies.psm1
<#
.SYNOPSIS This Command provide the list of Pipelines that depend on the Dataflow within an Azure Data Factory. .DESCRIPTION This function provides the list of Pipelines that depend on the Dataflow within an Azure Data Factory. .PARAMETER ResourceGroupName The resource group containing the DataFactory V2 .PARAMETER DataFactoryName The name of the DataFactory V2. .PARAMETER DataflowName The name of the Dataflow in the DataFactory V2. .EXAMPLE Get-AzDataFactoryV2DataflowDependencies -ResourceGroupName "<<RGName>>" -DataFactoryName "<<ADFV2Name>>" Get-AzDataFactoryV2DataflowDependencies -ResourceGroupName "<<RGName>>" -DataFactoryName "<<ADFV2Name>>" -DataflowName "<<DataflowName>>" #> Function Get-AzDataFactoryV2DataflowDependencies { Param ( [Parameter(Mandatory=$true)] [string] $ResourceGroupName , [Parameter(Mandatory=$true)] [string] $DataFactoryName , [Parameter(Mandatory=$false)] [string] $DataflowName ) $Regexpattern='"referenceName": "(.*?)",' $htDependee = @{} if(!$DataflowName) { $AllDataflow=Get-AzDataFactoryV2Dataflow -ResourceGroupName $ResourceGroupName -DataFactoryName $DataFactoryName } else { $AllDataflow=Get-AzDataFactoryV2Dataflow -ResourceGroupName $ResourceGroupName -DataFactoryName $DataFactoryName -Name $DataflowName } #This iteration is for Dataflows/power Queries leveraged within Pipelines $AllPipeline=Get-AzDataFactoryV2pipeline -ResourceGroupName $ResourceGroupName -DataFactoryName $DataFactoryName for ($i=0;$i -lt $AllDataflow.Count ; $i++) { $DSDependantObjects=@() for ($j=0;$j -lt $AllPipeline.Count ; $j++) { if($AllPipeline[$j].Activities.Dataflow.ReferenceName -eq $AllDataflow[$i].Name) #For outer activities { $DSDependantObjects=$DSDependantObjects+$AllPipeline[$j].Name } $InnerAdd=$AllPipeline[$j].Activities.AdditionalProperties #For Inner activities if($InnerAdd.count -gt '1'){ for ($n=0;$n -lt $InnerAdd.Count ; $n++) { $LSMatch=([regex]::Matches($InnerAdd[$n]["typeProperties"].ToString(),$Regexpattern).groups|Where-Object Name -Eq '1').value $LSMatch=$LSMatch |Select -Unique foreach ($ite in $LSMatch) { if($ite -eq $AllDataflow[$i].Name) { $DSDependantObjects=$DSDependantObjects+$AllPipeline[$j].Name } } } }#EndIf else { $LSMatch=([regex]::Matches($InnerAdd["typeProperties"].ToString(),$Regexpattern).groups|Where-Object Name -Eq '1').value $LSMatch=$LSMatch |Select -Unique foreach ($ite in $LSMatch) { if($ite -eq $AllDataflow[$i].Name) { $DSDependantObjects=$DSDependantObjects+$AllPipeline[$j].Name } } } } if($DSDependantObjects.count -ne 0) { if ($htDependee.ContainsKey($AllDataflow[$i].Name)) { FOREACH($LSDep in $DSDependantObjects){ if ($htDependee[$AllDataflow[$i].Name] -notcontains $LSDep) { $htDependee[$AllDataflow[$i].Name] += $LSDep } } } else{ FOREACH($LSDep in $DSDependantObjects){ if ($htDependee[$AllDataflow[$i].Name] -notcontains $LSDep) { $htDependee[$AllDataflow[$i].Name] += ,$LSDep } } } } } #PipelineEnd for ($i=0;$i -lt $AllDataflow.Count ; $i++) { if($htDependee.ContainsKey($AllDataflow[$i].Name)) { write-host $AllDataflow[$i].Name 'has' $($htDependee[$AllDataflow[$i].Name]).Count 'Dependencies' Write-Host $AllDataflow[$i].Name "is used in" $($htDependee[$AllDataflow[$i].Name]) `n } else { write-host $AllDataflow[$i].Name "has no / 0 Dependency" `n } } } Export-ModuleMember -Function Get-AzDataFactoryV2DataflowDependencies |