Azure PowerShell代码循环管道中的数据集

时间:2017-11-30 15:20:51

标签: powershell azure azure-powershell azure-data-factory

我在下面的代码中循环遍历Azure datafactory中的数据集

Get-AzureRmDataFactoryDataset -ResourceGroupName "ADF" -DataFactoryName "WikiADF" 

但是,我需要遍历属于特定管道的数据集。 无法掌握它。

2 个答案:

答案 0 :(得分:1)

可以从同一工厂内的多个管道引用数据集,因此要查找特定管道引用的数据集,您需要分析该管道本身。每个管道都有一个活动列表,每个活动都有一个输入和输出列表,每个列表都是一个数据集参考。

答案 1 :(得分:0)

以上的约瑟夫评论,这是代码。

#Put your Data Factory name and Resource group here and pipeline
$RG = "asdf"
$DFname = "asdfasdf"
$Pipeline = "CopyPipeline-sdfas"
#Once per session - comment out to save time
#Login-AzureRmAccount

# Once, select a default subscription for your current session
#Get-AzureRmSubscription
#Set-AzureRmContext -SubscriptionId "asdfasdfasdfasdfasd"

# One time per computer - comment out to save time
# Register-AzureRmResourceProvider -ProviderNamespace Microsoft.DataFactory

# Debug option: List all DF in a resource group for debugging if needed
#Get-AzureRmDataFactory -ResourceGroupName $RG

# Find the Data Factory
$df= Get-AzureRmDataFactory -ResourceGroupName $RG -Name $DFname
if ($df -eq $null) { Write-Host "Data Factory " $DFname " cannot be found. Check spelling and resource group name. Error: " $_ -BackgroundColor:Red }

$activities = (Get-AzureRmDataFactoryPipeline -ResourceGroupName $RG -Name $Pipeline -DataFactoryName $DFname).Properties.Activities

$DataSets = [System.Collections.ArrayList]@()
ForEach($activity in $activities)
{
    ForEach($tempDS in $activity.Inputs) { 
        Write-Host "temp ds name: " + $tempDS.Name 
        $DataSets.Add($tempDS) 
    }
    ForEach($tempDS in $activity.Outputs) { 
        Write-Host "temp ds name output: " + $tempDS.Name 
        $DataSets.Add($tempDS) 
    }
    #ForEach($tempDS in $activity.Outputs) { $AllDataSetNames.Add($tempDS.Name) }
    #Write-Host "Input Activity: " + $activity.Inputs.ForEach('Name') 
    #Write-Host "Output Activity: " + $activity.Outputs.ForEach('Name') 
}

Write-Host "all datasets:"
$DataSets.ForEach('Name')