Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use template parameters to start triggers post deployment #433

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,8 @@ function Compare-TriggerAdditionalProperties {
}

function Update-TriggerTemplate {
param([string]$templateJson,
param(
[string]$templateJson,
[PSCustomObject]$templateParameters
)

Expand Down Expand Up @@ -495,7 +496,8 @@ $triggersDeployed = Get-SortedTriggers -DataFactoryName $DataFactoryName -Resour
if ($PreDeployment -eq $true) {
#Stop trigger only if there is change in payload
$triggersToStop = $triggersDeployed | Where-Object { $_.Name -in $triggerNamesInTemplate -and $_.RuntimeState -ne 'Stopped' } `
| Where-Object { $triggerName = $_.Name;
| Where-Object {
$triggerName = $_.Name;
$triggerInTemplate = $triggersInTemplate | Where-Object { $_.name.Substring(37, $_.name.Length - 40) -eq $triggerName };
Compare-TriggerPayload -triggerDeployed $_ -triggerInTemplate $triggerInTemplate -templateParameters $templateParameters
} `
Expand Down Expand Up @@ -650,7 +652,12 @@ else {
#Start active triggers - after cleanup efforts
$triggersRunning = $triggersDeployed | Where-Object { $_.RuntimeState -eq 'Started' } | ForEach-Object { $_.Name }

$triggersToStart = $triggersInTemplate | Where-Object { $_.properties.runtimeState -eq "Started" -and $_.name.Substring(37, $_.name.Length - 40) -notin $triggersRunning } `
$updatedTriggersInTemplate = $triggersInTemplate | ForEach-Object {
$jsonTrigger = ConvertTo-Json -InputObject $_ -Depth 10 -EscapeHandling Default
Update-TriggerTemplate -templateJson $jsonTrigger -templateParameters $templateParameters
} | ConvertFrom-Json -Depth 10

$triggersToStart = $updatedTriggersInTemplate | Where-Object { $_.properties.runtimeState -eq "Started" -and $_.name.Substring(37, $_.name.Length - 40) -notin $triggersRunning } `
| Where-Object { $_.properties.pipelines.Count -gt 0 -or $_.properties.pipeline.pipelineReference -ne $null } | ForEach-Object {
New-Object PSObject -Property @{
Name = $_.name.Substring(37, $_.name.Length - 40)
Expand Down