Skip to content

Commit de007b7

Browse files
committed
fix: local first deploy check
1 parent 0a30053 commit de007b7

5 files changed

Lines changed: 8 additions & 59 deletions

File tree

alz/local/scripts-bicep/bicep-first-deployment-check.ps1

Lines changed: 0 additions & 33 deletions
This file was deleted.

alz/local/scripts/bicep-deploy.ps1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,9 @@ while ($retryCount -lt $retryMax) {
139139

140140
if($finalSuccess -eq $false) {
141141
Write-Error "Deployment failed after $retryMax attempts..."
142-
exit 1
143142
}
144143

145144
Write-Host "<---------------------------------------------------------------------------->" -ForegroundColor DarkMagenta
146145
Write-Host "Completed $($whatIf ? "What If" : "Full") $displayName..." -ForegroundColor DarkMagenta
147146
Write-Host "<---------------------------------------------------------------------------->" -ForegroundColor DarkMagenta
148-
Write-Host ""
147+
Write-Host ""

alz/local/scripts/bicep-first-deployment-check.ps1

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,16 @@ param(
22
[string]$managementGroupId
33
)
44

5-
# Read the int-root management group name from the bicepparam file
6-
$intRootParamFile = "templates/core/governance/mgmt-groups/int-root/main.bicepparam"
7-
if (Test-Path $intRootParamFile) {
8-
$paramContent = Get-Content $intRootParamFile -Raw
9-
if ($paramContent -match 'managementGroupName:\s*[''"](\w+)[''"]+') {
10-
$intRootMgId = $matches[1]
11-
Write-Host "Found int-root management group name in param file: $intRootMgId"
12-
} else {
13-
Write-Warning "Could not parse managementGroupName from $intRootParamFile, using default 'alz'"
14-
$intRootMgId = "alz"
15-
}
16-
} else {
17-
Write-Warning "Int-root param file not found at $intRootParamFile, using default 'alz'"
18-
$intRootMgId = "alz"
19-
}
20-
215
$managementGroups = Get-AzManagementGroup
22-
$intRootMg = $managementGroups | Where-Object { $_.Name -eq $intRootMgId }
6+
$managementGroup = $managementGroups | Where-Object { $_.Name -eq $managementGroupId }
237

248
$firstDeployment = $true
259

26-
if ($null -eq $intRootMg) {
27-
Write-Warning "Cannot find the $intRootMgId Management Group, so assuming this is the first deployment. We must skip checking some deployments since their dependent resources do not exist yet."
10+
if($null -eq $managementGroup) {
11+
Write-Warning "Cannot find the $managementGroupId Management Group, so assuming this is the first deployment. We must skip checking some deployments since their dependent resources do not exist yet."
2812
} else {
29-
Write-Host "Found the $intRootMgId Management Group, so assuming this is not the first deployment."
13+
Write-Host "Found the $managementGroupId Management Group, so assuming this is not the first deployment."
3014
$firstDeployment = $false
3115
}
3216

33-
return $firstDeployment
17+
return $firstDeployment

alz/local/scripts/bicep-on-demand-folder.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@ New-Item -ItemType Directory -Path $targetFolderPath | Out-String | Write-Verbos
6262
Copy-Item -Path $sourceFolderPath -Destination $targetFolderPath -Recurse -Force | Out-String | Write-Verbose
6363

6464
Remove-Item -Path $tempFolder -Force -Recurse
65-
Write-Host "Successfully copied the files from the release artifact to the target path $targetPath..."
65+
Write-Host "Successfully copied the files from the release artifact to the target path $targetPath..."

alz/local/scripts/deploy-local.ps1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,4 @@ if($deployApproved -ne "yes") {
6060
-firstRunWhatIf ${script_file.firstRunWhatIf} `
6161
-firstDeployment $isFirstDeployment `
6262

63-
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
64-
%{ endfor ~}
63+
%{ endfor ~}

0 commit comments

Comments
 (0)