From d41510d5282eb84d6d612eb9857dda94a4884cbc Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 4 Aug 2021 16:03:26 -0700 Subject: [PATCH 1/7] Fix New-TestResources.ps1 to run pre/post deployment script --- .../TestResources/New-TestResources.ps1 | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/eng/common/TestResources/New-TestResources.ps1 b/eng/common/TestResources/New-TestResources.ps1 index a38155cba85..f4f526869cd 100644 --- a/eng/common/TestResources/New-TestResources.ps1 +++ b/eng/common/TestResources/New-TestResources.ps1 @@ -167,9 +167,11 @@ try { Get-ChildItem -Path $root -Filter "$_" -Recurse | ForEach-Object { Write-Verbose "Found template '$($_.FullName)'" if ($_.Extension -eq '.bicep') { - $templateFiles += (BuildBicepFile $_) + $templateFile = @{originalFilePath = $_.FullName; jsonFilePath = (BuildBicepFile $_)} + $templateFiles += $templateFile } else { - $templateFiles += $_.FullName + $templateFile = @{originalFilePath = $_.FullName; jsonFilePath = $_.FullName} + $templateFiles += $templateFile } } } @@ -457,8 +459,8 @@ try { # Deploy the templates foreach ($templateFile in $templateFiles) { # Deployment fails if we pass in more parameters than are defined. - Write-Verbose "Removing unnecessary parameters from template '$templateFile'" - $templateJson = Get-Content -LiteralPath $templateFile | ConvertFrom-Json + Write-Verbose "Removing unnecessary parameters from template '$($templateFile.jsonFilePath)'" + $templateJson = Get-Content -LiteralPath $templateFile.jsonFilePath | ConvertFrom-Json $templateParameterNames = $templateJson.parameters.PSObject.Properties.Name $templateFileParameters = $templateParameters.Clone() @@ -469,20 +471,20 @@ try { } } - $preDeploymentScript = $templateFile | Split-Path | Join-Path -ChildPath 'test-resources-pre.ps1' + $preDeploymentScript = $templateFile.originalFilePath | Split-Path | Join-Path -ChildPath 'test-resources-pre.ps1' if (Test-Path $preDeploymentScript) { Log "Invoking pre-deployment script '$preDeploymentScript'" &$preDeploymentScript -ResourceGroupName $ResourceGroupName @PSBoundParameters } - Log "Deploying template '$templateFile' to resource group '$($resourceGroup.ResourceGroupName)'" + Log "Deploying template '$($templateFile.jsonFilePath)' to resource group '$($resourceGroup.ResourceGroupName)'" $deployment = Retry { $lastDebugPreference = $DebugPreference try { if ($CI) { $DebugPreference = 'Continue' } - New-AzResourceGroupDeployment -Name $BaseName -ResourceGroupName $resourceGroup.ResourceGroupName -TemplateFile $templateFile -TemplateParameterObject $templateFileParameters -Force:$Force + New-AzResourceGroupDeployment -Name $BaseName -ResourceGroupName $resourceGroup.ResourceGroupName -TemplateFile $templateFile.jsonFilePath -TemplateParameterObject $templateFileParameters -Force:$Force } catch { Write-Output @' ##################################################### @@ -498,7 +500,7 @@ try { if ($deployment.ProvisioningState -eq 'Succeeded') { # New-AzResourceGroupDeployment would've written an error and stopped the pipeline by default anyway. - Write-Verbose "Successfully deployed template '$templateFile' to resource group '$($resourceGroup.ResourceGroupName)'" + Write-Verbose "Successfully deployed template '$($templateFile.jsonFilePath)' to resource group '$($resourceGroup.ResourceGroupName)'" } $serviceDirectoryPrefix = $serviceName.ToUpperInvariant() + "_" @@ -536,7 +538,7 @@ try { Write-Host 'File option is supported only on Windows' } - $outputFile = "$templateFile.env" + $outputFile = "$($templateFile.jsonFilePath).env" $environmentText = $deploymentOutputs | ConvertTo-Json; $bytes = ([System.Text.Encoding]::UTF8).GetBytes($environmentText) @@ -574,15 +576,15 @@ try { } } - $postDeploymentScript = $templateFile | Split-Path | Join-Path -ChildPath 'test-resources-post.ps1' + $postDeploymentScript = $templateFile.originalFilePath | Split-Path | Join-Path -ChildPath 'test-resources-post.ps1' if (Test-Path $postDeploymentScript) { Log "Invoking post-deployment script '$postDeploymentScript'" &$postDeploymentScript -ResourceGroupName $ResourceGroupName -DeploymentOutputs $deploymentOutputs @PSBoundParameters } - if ($templateFile.EndsWith('.compiled.json')) { - Write-Verbose "Removing compiled bicep file $templateFile" - Remove-Item $templateFile + if ($templateFile.jsonFilePath.EndsWith('.compiled.json')) { + Write-Verbose "Removing compiled bicep file $($templateFile.jsonFilePath)" + Remove-Item $templateFile.jsonFilePath } } From 965ec79b3fe59aa49a46c93ad06a0a394995983a Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 4 Aug 2021 16:34:34 -0700 Subject: [PATCH 2/7] Revert "Fix New-TestResources.ps1 to run pre/post deployment script" This reverts commit d41510d5282eb84d6d612eb9857dda94a4884cbc. --- .../TestResources/New-TestResources.ps1 | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/eng/common/TestResources/New-TestResources.ps1 b/eng/common/TestResources/New-TestResources.ps1 index f4f526869cd..a38155cba85 100644 --- a/eng/common/TestResources/New-TestResources.ps1 +++ b/eng/common/TestResources/New-TestResources.ps1 @@ -167,11 +167,9 @@ try { Get-ChildItem -Path $root -Filter "$_" -Recurse | ForEach-Object { Write-Verbose "Found template '$($_.FullName)'" if ($_.Extension -eq '.bicep') { - $templateFile = @{originalFilePath = $_.FullName; jsonFilePath = (BuildBicepFile $_)} - $templateFiles += $templateFile + $templateFiles += (BuildBicepFile $_) } else { - $templateFile = @{originalFilePath = $_.FullName; jsonFilePath = $_.FullName} - $templateFiles += $templateFile + $templateFiles += $_.FullName } } } @@ -459,8 +457,8 @@ try { # Deploy the templates foreach ($templateFile in $templateFiles) { # Deployment fails if we pass in more parameters than are defined. - Write-Verbose "Removing unnecessary parameters from template '$($templateFile.jsonFilePath)'" - $templateJson = Get-Content -LiteralPath $templateFile.jsonFilePath | ConvertFrom-Json + Write-Verbose "Removing unnecessary parameters from template '$templateFile'" + $templateJson = Get-Content -LiteralPath $templateFile | ConvertFrom-Json $templateParameterNames = $templateJson.parameters.PSObject.Properties.Name $templateFileParameters = $templateParameters.Clone() @@ -471,20 +469,20 @@ try { } } - $preDeploymentScript = $templateFile.originalFilePath | Split-Path | Join-Path -ChildPath 'test-resources-pre.ps1' + $preDeploymentScript = $templateFile | Split-Path | Join-Path -ChildPath 'test-resources-pre.ps1' if (Test-Path $preDeploymentScript) { Log "Invoking pre-deployment script '$preDeploymentScript'" &$preDeploymentScript -ResourceGroupName $ResourceGroupName @PSBoundParameters } - Log "Deploying template '$($templateFile.jsonFilePath)' to resource group '$($resourceGroup.ResourceGroupName)'" + Log "Deploying template '$templateFile' to resource group '$($resourceGroup.ResourceGroupName)'" $deployment = Retry { $lastDebugPreference = $DebugPreference try { if ($CI) { $DebugPreference = 'Continue' } - New-AzResourceGroupDeployment -Name $BaseName -ResourceGroupName $resourceGroup.ResourceGroupName -TemplateFile $templateFile.jsonFilePath -TemplateParameterObject $templateFileParameters -Force:$Force + New-AzResourceGroupDeployment -Name $BaseName -ResourceGroupName $resourceGroup.ResourceGroupName -TemplateFile $templateFile -TemplateParameterObject $templateFileParameters -Force:$Force } catch { Write-Output @' ##################################################### @@ -500,7 +498,7 @@ try { if ($deployment.ProvisioningState -eq 'Succeeded') { # New-AzResourceGroupDeployment would've written an error and stopped the pipeline by default anyway. - Write-Verbose "Successfully deployed template '$($templateFile.jsonFilePath)' to resource group '$($resourceGroup.ResourceGroupName)'" + Write-Verbose "Successfully deployed template '$templateFile' to resource group '$($resourceGroup.ResourceGroupName)'" } $serviceDirectoryPrefix = $serviceName.ToUpperInvariant() + "_" @@ -538,7 +536,7 @@ try { Write-Host 'File option is supported only on Windows' } - $outputFile = "$($templateFile.jsonFilePath).env" + $outputFile = "$templateFile.env" $environmentText = $deploymentOutputs | ConvertTo-Json; $bytes = ([System.Text.Encoding]::UTF8).GetBytes($environmentText) @@ -576,15 +574,15 @@ try { } } - $postDeploymentScript = $templateFile.originalFilePath | Split-Path | Join-Path -ChildPath 'test-resources-post.ps1' + $postDeploymentScript = $templateFile | Split-Path | Join-Path -ChildPath 'test-resources-post.ps1' if (Test-Path $postDeploymentScript) { Log "Invoking post-deployment script '$postDeploymentScript'" &$postDeploymentScript -ResourceGroupName $ResourceGroupName -DeploymentOutputs $deploymentOutputs @PSBoundParameters } - if ($templateFile.jsonFilePath.EndsWith('.compiled.json')) { - Write-Verbose "Removing compiled bicep file $($templateFile.jsonFilePath)" - Remove-Item $templateFile.jsonFilePath + if ($templateFile.EndsWith('.compiled.json')) { + Write-Verbose "Removing compiled bicep file $templateFile" + Remove-Item $templateFile } } From ffdaf0949f14b781004269590b9e04d2c4041003 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 4 Aug 2021 16:03:26 -0700 Subject: [PATCH 3/7] Fix New-TestResources.ps1 to run pre/post deployment script --- .../TestResources/New-TestResources.ps1 | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/eng/common/TestResources/New-TestResources.ps1 b/eng/common/TestResources/New-TestResources.ps1 index a38155cba85..f4f526869cd 100644 --- a/eng/common/TestResources/New-TestResources.ps1 +++ b/eng/common/TestResources/New-TestResources.ps1 @@ -167,9 +167,11 @@ try { Get-ChildItem -Path $root -Filter "$_" -Recurse | ForEach-Object { Write-Verbose "Found template '$($_.FullName)'" if ($_.Extension -eq '.bicep') { - $templateFiles += (BuildBicepFile $_) + $templateFile = @{originalFilePath = $_.FullName; jsonFilePath = (BuildBicepFile $_)} + $templateFiles += $templateFile } else { - $templateFiles += $_.FullName + $templateFile = @{originalFilePath = $_.FullName; jsonFilePath = $_.FullName} + $templateFiles += $templateFile } } } @@ -457,8 +459,8 @@ try { # Deploy the templates foreach ($templateFile in $templateFiles) { # Deployment fails if we pass in more parameters than are defined. - Write-Verbose "Removing unnecessary parameters from template '$templateFile'" - $templateJson = Get-Content -LiteralPath $templateFile | ConvertFrom-Json + Write-Verbose "Removing unnecessary parameters from template '$($templateFile.jsonFilePath)'" + $templateJson = Get-Content -LiteralPath $templateFile.jsonFilePath | ConvertFrom-Json $templateParameterNames = $templateJson.parameters.PSObject.Properties.Name $templateFileParameters = $templateParameters.Clone() @@ -469,20 +471,20 @@ try { } } - $preDeploymentScript = $templateFile | Split-Path | Join-Path -ChildPath 'test-resources-pre.ps1' + $preDeploymentScript = $templateFile.originalFilePath | Split-Path | Join-Path -ChildPath 'test-resources-pre.ps1' if (Test-Path $preDeploymentScript) { Log "Invoking pre-deployment script '$preDeploymentScript'" &$preDeploymentScript -ResourceGroupName $ResourceGroupName @PSBoundParameters } - Log "Deploying template '$templateFile' to resource group '$($resourceGroup.ResourceGroupName)'" + Log "Deploying template '$($templateFile.jsonFilePath)' to resource group '$($resourceGroup.ResourceGroupName)'" $deployment = Retry { $lastDebugPreference = $DebugPreference try { if ($CI) { $DebugPreference = 'Continue' } - New-AzResourceGroupDeployment -Name $BaseName -ResourceGroupName $resourceGroup.ResourceGroupName -TemplateFile $templateFile -TemplateParameterObject $templateFileParameters -Force:$Force + New-AzResourceGroupDeployment -Name $BaseName -ResourceGroupName $resourceGroup.ResourceGroupName -TemplateFile $templateFile.jsonFilePath -TemplateParameterObject $templateFileParameters -Force:$Force } catch { Write-Output @' ##################################################### @@ -498,7 +500,7 @@ try { if ($deployment.ProvisioningState -eq 'Succeeded') { # New-AzResourceGroupDeployment would've written an error and stopped the pipeline by default anyway. - Write-Verbose "Successfully deployed template '$templateFile' to resource group '$($resourceGroup.ResourceGroupName)'" + Write-Verbose "Successfully deployed template '$($templateFile.jsonFilePath)' to resource group '$($resourceGroup.ResourceGroupName)'" } $serviceDirectoryPrefix = $serviceName.ToUpperInvariant() + "_" @@ -536,7 +538,7 @@ try { Write-Host 'File option is supported only on Windows' } - $outputFile = "$templateFile.env" + $outputFile = "$($templateFile.jsonFilePath).env" $environmentText = $deploymentOutputs | ConvertTo-Json; $bytes = ([System.Text.Encoding]::UTF8).GetBytes($environmentText) @@ -574,15 +576,15 @@ try { } } - $postDeploymentScript = $templateFile | Split-Path | Join-Path -ChildPath 'test-resources-post.ps1' + $postDeploymentScript = $templateFile.originalFilePath | Split-Path | Join-Path -ChildPath 'test-resources-post.ps1' if (Test-Path $postDeploymentScript) { Log "Invoking post-deployment script '$postDeploymentScript'" &$postDeploymentScript -ResourceGroupName $ResourceGroupName -DeploymentOutputs $deploymentOutputs @PSBoundParameters } - if ($templateFile.EndsWith('.compiled.json')) { - Write-Verbose "Removing compiled bicep file $templateFile" - Remove-Item $templateFile + if ($templateFile.jsonFilePath.EndsWith('.compiled.json')) { + Write-Verbose "Removing compiled bicep file $($templateFile.jsonFilePath)" + Remove-Item $templateFile.jsonFilePath } } From cefef4c361ab1a13deeb2109472cb9c8dc5fc4aa Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 4 Aug 2021 16:34:34 -0700 Subject: [PATCH 4/7] Revert "Fix New-TestResources.ps1 to run pre/post deployment script" This reverts commit d41510d5282eb84d6d612eb9857dda94a4884cbc. --- .../TestResources/New-TestResources.ps1 | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/eng/common/TestResources/New-TestResources.ps1 b/eng/common/TestResources/New-TestResources.ps1 index f4f526869cd..a38155cba85 100644 --- a/eng/common/TestResources/New-TestResources.ps1 +++ b/eng/common/TestResources/New-TestResources.ps1 @@ -167,11 +167,9 @@ try { Get-ChildItem -Path $root -Filter "$_" -Recurse | ForEach-Object { Write-Verbose "Found template '$($_.FullName)'" if ($_.Extension -eq '.bicep') { - $templateFile = @{originalFilePath = $_.FullName; jsonFilePath = (BuildBicepFile $_)} - $templateFiles += $templateFile + $templateFiles += (BuildBicepFile $_) } else { - $templateFile = @{originalFilePath = $_.FullName; jsonFilePath = $_.FullName} - $templateFiles += $templateFile + $templateFiles += $_.FullName } } } @@ -459,8 +457,8 @@ try { # Deploy the templates foreach ($templateFile in $templateFiles) { # Deployment fails if we pass in more parameters than are defined. - Write-Verbose "Removing unnecessary parameters from template '$($templateFile.jsonFilePath)'" - $templateJson = Get-Content -LiteralPath $templateFile.jsonFilePath | ConvertFrom-Json + Write-Verbose "Removing unnecessary parameters from template '$templateFile'" + $templateJson = Get-Content -LiteralPath $templateFile | ConvertFrom-Json $templateParameterNames = $templateJson.parameters.PSObject.Properties.Name $templateFileParameters = $templateParameters.Clone() @@ -471,20 +469,20 @@ try { } } - $preDeploymentScript = $templateFile.originalFilePath | Split-Path | Join-Path -ChildPath 'test-resources-pre.ps1' + $preDeploymentScript = $templateFile | Split-Path | Join-Path -ChildPath 'test-resources-pre.ps1' if (Test-Path $preDeploymentScript) { Log "Invoking pre-deployment script '$preDeploymentScript'" &$preDeploymentScript -ResourceGroupName $ResourceGroupName @PSBoundParameters } - Log "Deploying template '$($templateFile.jsonFilePath)' to resource group '$($resourceGroup.ResourceGroupName)'" + Log "Deploying template '$templateFile' to resource group '$($resourceGroup.ResourceGroupName)'" $deployment = Retry { $lastDebugPreference = $DebugPreference try { if ($CI) { $DebugPreference = 'Continue' } - New-AzResourceGroupDeployment -Name $BaseName -ResourceGroupName $resourceGroup.ResourceGroupName -TemplateFile $templateFile.jsonFilePath -TemplateParameterObject $templateFileParameters -Force:$Force + New-AzResourceGroupDeployment -Name $BaseName -ResourceGroupName $resourceGroup.ResourceGroupName -TemplateFile $templateFile -TemplateParameterObject $templateFileParameters -Force:$Force } catch { Write-Output @' ##################################################### @@ -500,7 +498,7 @@ try { if ($deployment.ProvisioningState -eq 'Succeeded') { # New-AzResourceGroupDeployment would've written an error and stopped the pipeline by default anyway. - Write-Verbose "Successfully deployed template '$($templateFile.jsonFilePath)' to resource group '$($resourceGroup.ResourceGroupName)'" + Write-Verbose "Successfully deployed template '$templateFile' to resource group '$($resourceGroup.ResourceGroupName)'" } $serviceDirectoryPrefix = $serviceName.ToUpperInvariant() + "_" @@ -538,7 +536,7 @@ try { Write-Host 'File option is supported only on Windows' } - $outputFile = "$($templateFile.jsonFilePath).env" + $outputFile = "$templateFile.env" $environmentText = $deploymentOutputs | ConvertTo-Json; $bytes = ([System.Text.Encoding]::UTF8).GetBytes($environmentText) @@ -576,15 +574,15 @@ try { } } - $postDeploymentScript = $templateFile.originalFilePath | Split-Path | Join-Path -ChildPath 'test-resources-post.ps1' + $postDeploymentScript = $templateFile | Split-Path | Join-Path -ChildPath 'test-resources-post.ps1' if (Test-Path $postDeploymentScript) { Log "Invoking post-deployment script '$postDeploymentScript'" &$postDeploymentScript -ResourceGroupName $ResourceGroupName -DeploymentOutputs $deploymentOutputs @PSBoundParameters } - if ($templateFile.jsonFilePath.EndsWith('.compiled.json')) { - Write-Verbose "Removing compiled bicep file $($templateFile.jsonFilePath)" - Remove-Item $templateFile.jsonFilePath + if ($templateFile.EndsWith('.compiled.json')) { + Write-Verbose "Removing compiled bicep file $templateFile" + Remove-Item $templateFile } } From 250e34f7768716b4571a146de79290d5b27507cd Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Fri, 6 Aug 2021 10:42:29 -0700 Subject: [PATCH 5/7] Changing template file path in log msg for clarity --- eng/common/TestResources/New-TestResources.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/TestResources/New-TestResources.ps1 b/eng/common/TestResources/New-TestResources.ps1 index f4f526869cd..16f8ff9bf4c 100644 --- a/eng/common/TestResources/New-TestResources.ps1 +++ b/eng/common/TestResources/New-TestResources.ps1 @@ -477,7 +477,7 @@ try { &$preDeploymentScript -ResourceGroupName $ResourceGroupName @PSBoundParameters } - Log "Deploying template '$($templateFile.jsonFilePath)' to resource group '$($resourceGroup.ResourceGroupName)'" + Log "Deploying template '$($templateFile.originalFilePath)' to resource group '$($resourceGroup.ResourceGroupName)'" $deployment = Retry { $lastDebugPreference = $DebugPreference try { From 196e5bf27a92283a9b759045f7c84ff8859b0999 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 12 Aug 2021 15:02:17 -0700 Subject: [PATCH 6/7] rebase --- eng/common/TestResources/New-TestResources.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/TestResources/New-TestResources.ps1 b/eng/common/TestResources/New-TestResources.ps1 index a38155cba85..c309945b4df 100644 --- a/eng/common/TestResources/New-TestResources.ps1 +++ b/eng/common/TestResources/New-TestResources.ps1 @@ -475,7 +475,7 @@ try { &$preDeploymentScript -ResourceGroupName $ResourceGroupName @PSBoundParameters } - Log "Deploying template '$templateFile' to resource group '$($resourceGroup.ResourceGroupName)'" + Log "Deploying template '$($templateFile.originalFilePath)' to resource group '$($resourceGroup.ResourceGroupName)'" $deployment = Retry { $lastDebugPreference = $DebugPreference try { From 663f2f8168cb1aa8e97426613dbf30034c87fe1d Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 12 Aug 2021 15:23:41 -0700 Subject: [PATCH 7/7] Resolve conflict --- .../TestResources/New-TestResources.ps1 | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/eng/common/TestResources/New-TestResources.ps1 b/eng/common/TestResources/New-TestResources.ps1 index c309945b4df..60f9f2bf2c0 100644 --- a/eng/common/TestResources/New-TestResources.ps1 +++ b/eng/common/TestResources/New-TestResources.ps1 @@ -167,9 +167,11 @@ try { Get-ChildItem -Path $root -Filter "$_" -Recurse | ForEach-Object { Write-Verbose "Found template '$($_.FullName)'" if ($_.Extension -eq '.bicep') { - $templateFiles += (BuildBicepFile $_) + $templateFile = @{originalFilePath = $_.FullName; jsonFilePath = (BuildBicepFile $_)} + $templateFiles += $templateFile } else { - $templateFiles += $_.FullName + $templateFile = @{originalFilePath = $_.FullName; jsonFilePath = $_.FullName} + $templateFiles += $templateFile } } } @@ -457,8 +459,8 @@ try { # Deploy the templates foreach ($templateFile in $templateFiles) { # Deployment fails if we pass in more parameters than are defined. - Write-Verbose "Removing unnecessary parameters from template '$templateFile'" - $templateJson = Get-Content -LiteralPath $templateFile | ConvertFrom-Json + Write-Verbose "Removing unnecessary parameters from template '$($templateFile.jsonFilePath)'" + $templateJson = Get-Content -LiteralPath $templateFile.jsonFilePath | ConvertFrom-Json $templateParameterNames = $templateJson.parameters.PSObject.Properties.Name $templateFileParameters = $templateParameters.Clone() @@ -469,7 +471,7 @@ try { } } - $preDeploymentScript = $templateFile | Split-Path | Join-Path -ChildPath 'test-resources-pre.ps1' + $preDeploymentScript = $templateFile.originalFilePath | Split-Path | Join-Path -ChildPath 'test-resources-pre.ps1' if (Test-Path $preDeploymentScript) { Log "Invoking pre-deployment script '$preDeploymentScript'" &$preDeploymentScript -ResourceGroupName $ResourceGroupName @PSBoundParameters @@ -482,7 +484,7 @@ try { if ($CI) { $DebugPreference = 'Continue' } - New-AzResourceGroupDeployment -Name $BaseName -ResourceGroupName $resourceGroup.ResourceGroupName -TemplateFile $templateFile -TemplateParameterObject $templateFileParameters -Force:$Force + New-AzResourceGroupDeployment -Name $BaseName -ResourceGroupName $resourceGroup.ResourceGroupName -TemplateFile $templateFile.jsonFilePath -TemplateParameterObject $templateFileParameters -Force:$Force } catch { Write-Output @' ##################################################### @@ -498,7 +500,7 @@ try { if ($deployment.ProvisioningState -eq 'Succeeded') { # New-AzResourceGroupDeployment would've written an error and stopped the pipeline by default anyway. - Write-Verbose "Successfully deployed template '$templateFile' to resource group '$($resourceGroup.ResourceGroupName)'" + Write-Verbose "Successfully deployed template '$($templateFile.jsonFilePath)' to resource group '$($resourceGroup.ResourceGroupName)'" } $serviceDirectoryPrefix = $serviceName.ToUpperInvariant() + "_" @@ -536,7 +538,7 @@ try { Write-Host 'File option is supported only on Windows' } - $outputFile = "$templateFile.env" + $outputFile = "$($templateFile.jsonFilePath).env" $environmentText = $deploymentOutputs | ConvertTo-Json; $bytes = ([System.Text.Encoding]::UTF8).GetBytes($environmentText) @@ -574,15 +576,15 @@ try { } } - $postDeploymentScript = $templateFile | Split-Path | Join-Path -ChildPath 'test-resources-post.ps1' + $postDeploymentScript = $templateFile.originalFilePath | Split-Path | Join-Path -ChildPath 'test-resources-post.ps1' if (Test-Path $postDeploymentScript) { Log "Invoking post-deployment script '$postDeploymentScript'" &$postDeploymentScript -ResourceGroupName $ResourceGroupName -DeploymentOutputs $deploymentOutputs @PSBoundParameters } - if ($templateFile.EndsWith('.compiled.json')) { - Write-Verbose "Removing compiled bicep file $templateFile" - Remove-Item $templateFile + if ($templateFile.jsonFilePath.EndsWith('.compiled.json')) { + Write-Verbose "Removing compiled bicep file $($templateFile.jsonFilePath)" + Remove-Item $templateFile.jsonFilePath } } @@ -760,4 +762,4 @@ Run this in an Azure DevOps CI (with approrpiate variables configured) before executing live tests. The script will output variables as secrets (to enable log redaction). -#> +#> \ No newline at end of file