From 530ddf1f392c6a1afd9198db9334014b9eff47c1 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Wed, 11 Nov 2020 13:36:05 -0800 Subject: [PATCH] Sync eng/common directory with azure-sdk-tools for PR 1188 (#17488) * Add debug flag to arm deployment command * Only set debug preference when $CI is true Co-authored-by: Ben Broderick Phillips --- eng/common/TestResources/New-TestResources.ps1 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/eng/common/TestResources/New-TestResources.ps1 b/eng/common/TestResources/New-TestResources.ps1 index 4c03816c12843..3d3f95b561a41 100644 --- a/eng/common/TestResources/New-TestResources.ps1 +++ b/eng/common/TestResources/New-TestResources.ps1 @@ -308,7 +308,7 @@ if ($CI) { if ($EnvironmentVariables.ContainsKey('AZURE_RESOURCEGROUP_NAME') -and ` $EnvironmentVariables['AZURE_RESOURCEGROUP_NAME'] -ne $ResourceGroupName) { - Write-Warning ("Overwriting 'EnvironmentVariables.AZURE_RESOURCEGROUP_NAME' with value " + + Write-Warning ("Overwriting 'EnvironmentVariables.AZURE_RESOURCEGROUP_NAME' with value " + "'$($EnvironmentVariables['AZURE_RESOURCEGROUP_NAME'])' " + "to new value '$($ResourceGroupName)'") } $EnvironmentVariables['AZURE_RESOURCEGROUP_NAME'] = $ResourceGroupName @@ -385,7 +385,15 @@ foreach ($templateFile in $templateFiles) { Log "Deploying template '$templateFile' to resource group '$($resourceGroup.ResourceGroupName)'" $deployment = Retry { - New-AzResourceGroupDeployment -Name $BaseName -ResourceGroupName $resourceGroup.ResourceGroupName -TemplateFile $templateFile -TemplateParameterObject $templateFileParameters + $lastDebugPreference = $DebugPreference + try { + if ($CI) { + $DebugPreference = "Continue" + } + New-AzResourceGroupDeployment -Name $BaseName -ResourceGroupName $resourceGroup.ResourceGroupName -TemplateFile $templateFile -TemplateParameterObject $templateFileParameters + } finally { + $DebugPreference = $lastDebugPreference + } } if ($deployment.ProvisioningState -eq 'Succeeded') {