Skip to content

Commit 77218dd

Browse files
committed
improve nat rule error handling
1 parent 685933f commit 77218dd

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

AzureBasicLoadBalancerUpgrade/module/AzureBasicLoadBalancerUpgrade/AzureBasicLoadBalancerUpgrade.psd1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'AzureBasicLoadBalancerUpgrade'
1313

1414
# Version number of this module.
15-
ModuleVersion = '2.5.38'
15+
ModuleVersion = '2.5.39'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()
@@ -107,7 +107,7 @@
107107
# IconUri = ''
108108

109109
# ReleaseNotes of this module
110-
ReleaseNotes = 'Add note for -multiLBConfig internal LB outbound connectivity warning.'
110+
ReleaseNotes = 'Improve NAT Rule migration logging and error handling.'
111111

112112
# Prerelease string of this module
113113
# Prerelease = 'beta'

AzureBasicLoadBalancerUpgrade/module/AzureBasicLoadBalancerUpgrade/modules/NatRulesMigration/NatRulesMigration.psm1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,15 @@ function NatRulesMigration {
145145
log "Error" $message
146146
}
147147
}
148-
log -Message "[NatRulesMigration] Saving Standard Load Balancer $($StdLoadBalancer.Name)"
148+
log -Message "[NatRulesMigration] Starting saving Standard Load Balancer $($StdLoadBalancer.Name)..."
149149

150150
if ($StdLoadBalancer.InboundNatRules.Count -eq 0) {
151151
log -Message "[NatRulesMigration] No NAT Rules to migrate. Skipping save."
152152
return
153153
}
154154
else {
155+
log -Message "[NatRulesMigration] $($StdLoadBalancer.InboundNatRules.Count) NAT Rules migrated. Saving Standard Load Balancer '$($StdLoadBalancer.Name)'..."
156+
155157
try {
156158
$ErrorActionPreference = 'Stop'
157159

@@ -163,7 +165,7 @@ function NatRulesMigration {
163165
}
164166

165167
If ($UpdateLBNATRulesJob.Error -or $UpdateLBNATRulesJob.State -eq 'Failed') {
166-
Write-Error $UpdateLBNATRulesJob.Error
168+
log -Severity Error -Message "Saving Standard Load Balancer $($StdLoadBalancer.Name) failed with the following errors: $($UpdateLBNATRulesJob.error; $UpdateLBNATRulesJob | Receive-Job). Migration will continue--to recover, manually add the NAT rules to the load balancer, then correct NAT Rule NIC membership after the script completes."
167169
}
168170
}
169171
catch {

0 commit comments

Comments
 (0)