|
48 | 48 |
|
49 | 49 | [string]$Location = 'eastus2', |
50 | 50 |
|
| 51 | + [ValidateSet('Info', 'Verbose', 'Debug')] |
| 52 | + [string]$LogLevel = 'Verbose', |
| 53 | + |
51 | 54 | [Parameter(Mandatory)] |
52 | 55 | [string]$PublisherEmail, |
53 | 56 |
|
|
59 | 62 | ) |
60 | 63 |
|
61 | 64 | $ErrorActionPreference = 'Stop' |
| 65 | +$VerbosePreference = if ($LogLevel -in @('Verbose', 'Debug')) { 'Continue' } else { 'SilentlyContinue' } |
| 66 | +$DebugPreference = if ($LogLevel -eq 'Debug') { 'Continue' } else { 'SilentlyContinue' } |
62 | 67 |
|
63 | 68 | # Default to hard-delete on teardown unless explicitly disabled. |
64 | 69 | if (-not $PSBoundParameters.ContainsKey('HardDelete')) { |
@@ -255,19 +260,29 @@ try { |
255 | 260 |
|
256 | 261 | # --- Source deployment job --- |
257 | 262 | $sourceJob = Start-Job -Name 'DeploySource' -ScriptBlock { |
258 | | - param($script, $rg, $sku, $loc, $email, $transcriptFile) |
| 263 | + param($script, $rg, $sku, $loc, $email, $transcriptFile, $logLevel) |
259 | 264 | $ErrorActionPreference = 'Stop' |
260 | 265 | Start-Transcript -Path $transcriptFile -Force | Out-Null |
261 | 266 | try { |
262 | | - $result = & $script -ResourceGroupName $rg -SkuName $sku -Location $loc -PublisherEmail $email |
| 267 | + $scriptArgs = @{ |
| 268 | + ResourceGroupName = $rg |
| 269 | + SkuName = $sku |
| 270 | + Location = $loc |
| 271 | + PublisherEmail = $email |
| 272 | + } |
| 273 | + switch ($logLevel) { |
| 274 | + 'Verbose' { $scriptArgs.Verbose = $true } |
| 275 | + 'Debug' { $scriptArgs.Debug = $true } |
| 276 | + } |
| 277 | + $result = & $script @scriptArgs |
263 | 278 | if (-not $result -or -not $result.apimServiceName) { |
264 | 279 | throw "Source deployment returned no outputs" |
265 | 280 | } |
266 | 281 | return $result |
267 | 282 | } finally { |
268 | 283 | Stop-Transcript | Out-Null |
269 | 284 | } |
270 | | - } -ArgumentList $deploySourceScript, $SourceResourceGroup, $SkuName, $Location, $PublisherEmail, $sourceLogFile |
| 285 | + } -ArgumentList $deploySourceScript, $SourceResourceGroup, $SkuName, $Location, $PublisherEmail, $sourceLogFile, $LogLevel |
271 | 286 | Write-Host " ▶ Source deployment started" |
272 | 287 |
|
273 | 288 | # --- Target deployment job --- |
@@ -492,10 +507,16 @@ try { |
492 | 507 | $manifestFile = Join-Path $PSScriptRoot 'expected-structure.json' |
493 | 508 | $validateScript = Join-Path $PSScriptRoot 'Test-ExtractedArtifact.ps1' |
494 | 509 |
|
495 | | - & $validateScript ` |
496 | | - -ExtractedDir $ExtractOutputDir ` |
497 | | - -ManifestFile $manifestFile ` |
498 | | - -SkuName $SkuName |
| 510 | + $validateArgs = @{ |
| 511 | + ExtractedDir = $ExtractOutputDir |
| 512 | + ManifestFile = $manifestFile |
| 513 | + SkuName = $SkuName |
| 514 | + } |
| 515 | + switch ($LogLevel) { |
| 516 | + 'Verbose' { $validateArgs.Verbose = $true } |
| 517 | + 'Debug' { $validateArgs.Debug = $true } |
| 518 | + } |
| 519 | + & $validateScript @validateArgs |
499 | 520 |
|
500 | 521 | $validateExitCode = $LASTEXITCODE |
501 | 522 | $validateTimer.Stop() |
@@ -604,13 +625,19 @@ loggers: |
604 | 625 | Write-Phase "🔍" "PHASE 4 — Compare source and target APIM instances" |
605 | 626 | $verifyTimer = [System.Diagnostics.Stopwatch]::StartNew() |
606 | 627 |
|
607 | | - & $compareScript ` |
608 | | - -SourceSubscriptionId $sourceSubId ` |
609 | | - -SourceResourceGroup $sourceRg ` |
610 | | - -SourceApimName $sourceName ` |
611 | | - -TargetSubscriptionId $targetSubId ` |
612 | | - -TargetResourceGroup $targetRg ` |
613 | | - -TargetApimName $targetName |
| 628 | + $compareArgs = @{ |
| 629 | + SourceSubscriptionId = $sourceSubId |
| 630 | + SourceResourceGroup = $sourceRg |
| 631 | + SourceApimName = $sourceName |
| 632 | + TargetSubscriptionId = $targetSubId |
| 633 | + TargetResourceGroup = $targetRg |
| 634 | + TargetApimName = $targetName |
| 635 | + } |
| 636 | + switch ($LogLevel) { |
| 637 | + 'Verbose' { $compareArgs.Verbose = $true } |
| 638 | + 'Debug' { $compareArgs.Debug = $true } |
| 639 | + } |
| 640 | + & $compareScript @compareArgs |
614 | 641 |
|
615 | 642 | $verifyExitCode = $LASTEXITCODE |
616 | 643 | $verifyTimer.Stop() |
|
0 commit comments