@@ -48,19 +48,31 @@ param(
4848
4949 [switch ]$Destroy ,
5050
51- [ValidateSet (' trace ' , ' debug ' , ' info ' , ' warn ' , ' error ' , ' silent ' )]
52- [string ]$LogLevel = ' info '
51+ [ValidateSet (' Info ' , ' Verbose ' , ' Debug ' )]
52+ [string ]$LogLevel = ' Info '
5353)
5454
5555$ErrorActionPreference = ' Stop'
56- $maskingHelpers = Join-Path $PSScriptRoot ' Masking.Helpers.ps1'
57- . $maskingHelpers
56+ $VerbosePreference = if ($LogLevel -in @ (' Verbose' , ' Debug' )) { ' Continue' } else { ' SilentlyContinue' }
57+ $DebugPreference = if ($LogLevel -eq ' Debug' ) { ' Continue' } else { ' SilentlyContinue' }
58+ Import-Module (Join-Path $PSScriptRoot ' MaskingHelpers.psm1' ) - Force
59+
60+ # Map this script's LogLevel (Info/Verbose/Debug) to the apiops CLI log level
61+ # values used in the printed example command.
62+ function Get-ApiopsLogLevelLocal ([string ]$ScriptLogLevel ) {
63+ switch ($ScriptLogLevel ) {
64+ ' Verbose' { return ' warn' }
65+ ' Debug' { return ' debug' }
66+ default { return ' info' }
67+ }
68+ }
69+ $apiopsLogLevel = Get-ApiopsLogLevelLocal - ScriptLogLevel $LogLevel
5870
5971# ---------------------------------------------------------------------------
6072# Destroy path
6173# ---------------------------------------------------------------------------
6274if ($Destroy ) {
63- Write-Host " 🗑️ Deleting resource group '$ ( Mask - Identifier - Value $ResourceGroupName ) '..." - ForegroundColor Yellow
75+ Write-Host " 🗑️ Deleting resource group '$ ( Protect -Identifier - Value $ResourceGroupName ) '..." - ForegroundColor Yellow
6476 az group delete -- name $ResourceGroupName -- yes -- no- wait
6577 Write-Host " ✅ Deletion initiated (async). Resource group will be removed shortly." - ForegroundColor Green
6678 exit 0
@@ -83,7 +95,7 @@ if (-not $account) {
8395}
8496
8597$subscriptionId = $account.id
86- Write-Host " Subscription: $ ( $account.name ) ($ ( Mask - SubscriptionId - Value $subscriptionId ) )" - ForegroundColor Gray
98+ Write-Host " Subscription: $ ( $account.name ) ($ ( Protect -SubscriptionId - Value $subscriptionId ) )" - ForegroundColor Gray
8799
88100# Register required resource providers
89101Write-Host " 📋 Registering required resource providers..." - ForegroundColor Cyan
@@ -129,7 +141,7 @@ if (-not $allRegistered) {
129141Write-Host " ✅ Resource providers ready" - ForegroundColor Green
130142
131143# Create resource group if needed
132- Write-Host " 📦 Ensuring resource group '$ ( Mask - Identifier - Value $ResourceGroupName ) ' exists in '$Location '..." - ForegroundColor Cyan
144+ Write-Host " 📦 Ensuring resource group '$ ( Protect -Identifier - Value $ResourceGroupName ) ' exists in '$Location '..." - ForegroundColor Cyan
133145az group create -- name $ResourceGroupName -- location $Location -- output none
134146
135147# Deploy Bicep template
@@ -141,12 +153,28 @@ Write-Host ""
141153
142154$deploymentName = " source-apim-$ ( Get-Date - Format ' yyyyMMddHHmmss' ) "
143155
144- $result = az deployment group create `
145- -- resource- group $ResourceGroupName `
146- -- name $deploymentName `
147- -- template- file $bicepFile `
148- -- parameters skuName= $SkuName location= $Location publisherEmail= $PublisherEmail `
149- -- output json | ConvertFrom-Json
156+ $azVerbosity = @ ()
157+ switch ($LogLevel ) {
158+ ' Verbose' { $azVerbosity = @ (' --verbose' ) }
159+ ' Debug' { $azVerbosity = @ (' --debug' ) }
160+ }
161+
162+ $azReplacements = @ {
163+ $subscriptionId = Protect-SubscriptionId - Value $subscriptionId
164+ $ResourceGroupName = Protect-Identifier - Value $ResourceGroupName
165+ }
166+
167+ $raw = Invoke-MaskedAzCommand - Replacements $azReplacements - Command {
168+ az deployment group create `
169+ -- resource- group $ResourceGroupName `
170+ -- name $deploymentName `
171+ -- template- file $bicepFile `
172+ -- parameters skuName= $SkuName location= $Location publisherEmail= $PublisherEmail `
173+ -- output json `
174+ @azVerbosity
175+ }
176+
177+ $result = $raw | ConvertFrom-Json
150178
151179if ($LASTEXITCODE -ne 0 ) {
152180 Write-Error " Deployment failed. Check the Azure portal for details."
@@ -163,11 +191,11 @@ Write-Host ""
163191Write-Host " APIOps CLI extract command:" - ForegroundColor Cyan
164192Write-Host " "
165193Write-Host " npx apiops extract \"
166- Write-Host " --subscription-id $ ( Mask - SubscriptionId - Value $outputs.subscriptionId.value ) \"
167- Write-Host " --resource-group $ ( Mask - Identifier - Value $outputs.resourceGroupName.value ) \"
194+ Write-Host " --subscription-id $ ( Protect -SubscriptionId - Value $outputs.subscriptionId.value ) \"
195+ Write-Host " --resource-group $ ( Protect -Identifier - Value $outputs.resourceGroupName.value ) \"
168196Write-Host " --service-name $ ( $outputs.apimServiceName.value ) \"
169197Write-Host " --output-dir ./extracted \"
170- Write-Host " --log-level $LogLevel "
198+ Write-Host " --log-level $apiopsLogLevel "
171199Write-Host " "
172200Write-Host " Gateway URL: $ ( $outputs.gatewayUrl.value ) " - ForegroundColor Gray
173201Write-Host " Workspace deployed: $ ( $outputs.workspaceDeployed.value ) " - ForegroundColor Gray
0 commit comments