Skip to content

Instantly share code, notes, and snippets.

@SQLvariant
Last active September 14, 2022 17:45
Show Gist options
  • Save SQLvariant/3d54fb46801c9bff2c3029ad3a515e92 to your computer and use it in GitHub Desktop.
Save SQLvariant/3d54fb46801c9bff2c3029ad3a515e92 to your computer and use it in GitHub Desktop.
A simple script to change the retry counts on certain activities in ADF pipelines.
# Go to wherever the pipelines are.
$DownloadLocation = 'C:\temp\ADF\pipeline'
cd $DownloadLocation
# Just have a quick look.
$PipelinesContents = @()
foreach($PipelineFile in dir $DownloadLocation){
$PipelineContents = Get-Content -Path $PipelineFile | ConvertFrom-Json -Depth 20
$PipelinesContents += $PipelineContents
$PipelineFile = $null
}
$PipelinesContents | SELECT @{label='folder';expression ={$_.properties.folder.name}},
Name,
@{label='Activity Types';expression ={$_.properties.activities.type}},
@{label='Retry';expression ={$_.properties.activities.policy.retry}}
# Do the thing.
$Pipelines = dir $DownloadLocation
foreach($PipelineFile in $Pipelines){
$PipelineContents = Get-Content -Path $PipelineFile | ConvertFrom-Json -Depth 20
if($PipelineContents){
$PipelineContents.properties.activities.Where({ $_.type -in 'Copy', 'SqlServerStoredProcedure', 'WebActivity' })
| SELECT @{label='FileName';expression ={$PipelineContents.name}}, name, type, @{label='retry';expression ={$_.policy.retry}}
foreach($Activity in $PipelineContents.properties.activities.Where({ $_.type -in 'Copy', 'SqlServerStoredProcedure', 'WebActivity' }).Where({$_.policy.retry -eq 0}) ){
$Activity | SELECT name, type, @{label='retry';expression ={$_.policy.retry}}
$Activity.policy.retry = 3
}
#
# Save the results back to the file.
$ModofiedPipeline = $PipelineContents | ConvertTo-Json -Depth 20
Set-Content -Path $PipelineFile -Value $ModofiedPipeline
}
else{
"Skipping $($PipelineContents.name)"
}
$PipelineFile = $null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment