From e4107415b1fb3d1932577481e161b90d3b62b1a9 Mon Sep 17 00:00:00 2001 From: Hunter Williams Date: Mon, 29 Apr 2024 13:47:50 -0400 Subject: [PATCH] Get resources for all linked templates not just master --- .../PrePostDeploymentScript.Ver2.ps1 | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/SamplesV2/ContinuousIntegrationAndDelivery/PrePostDeploymentScript.Ver2.ps1 b/SamplesV2/ContinuousIntegrationAndDelivery/PrePostDeploymentScript.Ver2.ps1 index fef3e700..299453e9 100644 --- a/SamplesV2/ContinuousIntegrationAndDelivery/PrePostDeploymentScript.Ver2.ps1 +++ b/SamplesV2/ContinuousIntegrationAndDelivery/PrePostDeploymentScript.Ver2.ps1 @@ -544,8 +544,21 @@ try { Write-Host "##[warning] The script is not compatible with your current PowerShell version $($PSVersionTable.PSVersion). Use either PowerShell Core or at least PS version 7.0, otherwise the script may fail to compare the trigger payload and always stop/start the trigger(s)" } - $templateJson = Get-Content $ArmTemplate | ConvertFrom-Json - $resources = $templateJson.resources + if ($ArmTemplate.EndsWith("ArmTemplate_master.json")) { + $resources = @() + $templateFile = Get-ChildItem -Path $ArmTemplate + $linkedTemplateFiles = (Get-ChildItem -Path $templateFile.Directory.FullName -File -Filter "*.json").where({ + (@("ArmTemplate_master.json", "ArmTemplateParameters_master.json") -inotcontains $PSItem.Name) + } + ) + foreach ($linkedTemplateFile in $linkedTemplateFiles) { + $templateJson = Get-Content $linkedTemplateFile.FullName | ConvertFrom-Json + $resources += $templateJson.resources + } + } else { + $templateJson = Get-Content $ArmTemplate | ConvertFrom-Json + $resources = $templateJson.resources + } if (-not $ArmTemplateParameters) { $ArmTemplateParameters = Join-Path -Path (Split-Path $ArmTemplate -Parent) -ChildPath 'ArmTemplateParametersForFactory.json'