Skip to content

Commit

Permalink
Move to one-line error messages, aka.ms recovery link (#83)
Browse files Browse the repository at this point in the history
* move to required modules

* error msg pass 1

* single line error messages pass 2

* error message corrections

* version bump

* missed file
  • Loading branch information
mbrat2005 authored Oct 3, 2023
1 parent e198905 commit 429b499
Show file tree
Hide file tree
Showing 16 changed files with 37 additions and 183 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'AzureBasicLoadBalancerUpgrade'

# Version number of this module.
ModuleVersion = '2.2.0'
ModuleVersion = '2.2.1'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ function AddLoadBalancerBackendAddressPool {
$StdLoadBalancer | Add-AzLoadBalancerBackendAddressPoolConfig -Name $basicBackendAddressPool.Name > $null
}
catch {
$message = @"
[AddLoadBalancerBackendAddressPool] An error occured when adding a backend pool to the new Standard LB '$($StdLoadBalancer.Name)'. To recover
address the following error, and try again specifying the -FailedMigrationRetryFilePath parameter and Basic Load Balancer backup
State file located either in this directory or the directory specified with -RecoveryBackupPath. `nError message: $_
"@
$message = "[AddLoadBalancerBackendAddressPool] An error occured when adding a backend pool to the new Standard LB '$($StdLoadBalancer.Name)'. To recover, address the cause of the following error, then follow the steps at https://aka.ms/basiclbupgradefailure to retry the migration."
log 'Error' $message -terminateOnError
}
}
Expand All @@ -29,11 +25,7 @@ function AddLoadBalancerBackendAddressPool {
$StdLoadBalancer | Set-AzLoadBalancer > $null
}
catch {
$message = @"
[AddLoadBalancerBackendAddressPool] An error occured when saving the added backend pools to the new Standard LB '$($StdLoadBalancer.Name)'. To recover
address the following error, and try again specifying the -FailedMigrationRetryFilePath parameter and Basic Load Balancer backup
State file located either in this directory or the directory specified with -RecoveryBackupPath. `nError message: $_
"@
$message = "[AddLoadBalancerBackendAddressPool] An error occured when saving the added backend pools to the new Standard LB '$($StdLoadBalancer.Name)'. To recover, address the cause of the following error, then follow the steps at https://aka.ms/basiclbupgradefailure to retry the migration."
log 'Error' $message -terminateOnError
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ function _MigrateHealthProbe{
}
}
catch {
$message = @"
[_MigrateHealthProbe] An error occured migrating a health probe to the VMSS. To recover
address the following error, and try again specifying the -FailedMigrationRetryFilePath parameter and Basic Load Balancer backup
State file located either in this directory or the directory specified with -RecoveryBackupPath. `nError message: $_
"@
$message = "[_MigrateHealthProbe] An error occured migrating a health probe to the VMSS. To recover, address the cause of the following error, then follow the steps at https://aka.ms/basiclbupgradefailure to retry the migration. Error: $_"
log 'Error' $message -terminateOnError
}
log -Message "[_MigrateHealthProbe] Migrating Health Probes completed"
Expand Down Expand Up @@ -113,11 +109,7 @@ function _MigrateNetworkInterfaceConfigurationsVmss {
$genericListSubResource.Add($subResource)
}
catch {
$message = @"
[_MigrateNetworkInterfaceConfigurationsVmss] An error occured creating a new VMSS IP Config. To recover
address the following error, and try again specifying the -FailedMigrationRetryFilePath parameter and Basic Load Balancer backup
State file located either in this directory or the directory specified with -RecoveryBackupPath. `nError message: $_
"@
$message = "[_MigrateNetworkInterfaceConfigurationsVmss] An error occured creating a new VMSS IP Config. To recover, address the cause of the following error, then follow the steps at https://aka.ms/basiclbupgradefailure to retry the migration. Error: $_"
log 'Error' $message -terminateOnError
}
}
Expand Down Expand Up @@ -156,7 +148,6 @@ function BackendPoolMigrationVmss {
}
catch {
$message = "[BackendPoolMigrationVmss] An error occured while updating the VMSS to associate it with the standard load balancer's backend pool. To recover address the following error, and try again specifying the -FailedMigrationRetryFilePath parameter and Basic Load Balancer backup State file located either in this directory or the directory specified with -RecoveryBackupPath. To manually complete the migration, add the VMSS to the appropriate backend pools and check that the VMSS Upgrade Policy mode is correct. `nError message: $_"

log 'Error' $message -terminateOnError
}

Expand All @@ -175,7 +166,6 @@ function BackendPoolMigrationVmss {
}
catch {
$message = "[BackendPoolMigrationVmss] An error occured while restoring the VMSS Upgrade Policy Mode. To recover address the following error, and try again specifying the -FailedMigrationRetryFilePath parameter and Basic Load Balancer backup State file located either in this directory or the directory specified with -RecoveryBackupPath. To manually complete the migration, the VMSS Upgrade Policy mode matches the mode in the VMSS state file export. `nError message: $_"

log 'Error' $message -terminateOnError
}

Expand Down Expand Up @@ -228,11 +218,7 @@ function BackendPoolMigrationVM {
$nic = Get-AzNetworkInterface -ResourceId $nicRecord.Name
}
catch {
$message = @"
[BackendPoolMigrationVmss] An error occured getting the Network Interface '$($nicRecord.Name)'. Check that the NIC exists. To recover
address the following error, and try again specifying the -FailedMigrationRetryFilePath parameter and Basic Load Balancer backup
State file located either in this directory or the directory specified with -RecoveryBackupPath. `nError message: $_
"@
$message = "[BackendPoolMigrationVmss] An error occured getting the Network Interface '$($nicRecord.Name)'. Check that the NIC exists. To recover, address the cause of the following error, then follow the steps at https://aka.ms/basiclbupgradefailure to retry the migration. Error: $_"
log 'Error' $message -terminateOnError
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ function GetVmssFromBasicLoadBalancer {
$vmss = Get-AzResource -ResourceId $vmssId | Get-AzVmss
}
catch {
$message = @"
[GetVmssFromBasicLoadBalancer] An error occured when getting VMSS '$($vmss.Name)' in resource group '$($vmss.ResourceGroupName)'. To recover
address the following error, and try again specifying the -FailedMigrationRetryFilePath parameter and Basic Load Balancer backup
State file located either in this directory or the directory specified with -RecoveryBackupPath. `nError message: $_
"@
$message = "[GetVmssFromBasicLoadBalancer] An error occured when getting VMSS '$($vmss.Name)' in resource group '$($vmss.ResourceGroupName)'. To recover, address the cause of the following error, then follow the steps at https://aka.ms/basiclbupgradefailure to retry the migration. Error: $_"
log 'Error' $message -terminateOnError
}
log -Message "[GetVmssFromBasicLoadBalancer] VMSS loaded Name $($vmss.Name) from RG $($vmss.ResourceGroupName)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ function _MigrateNetworkInterfaceConfigurations {
}
}
catch {
$message = @"
[_MigrateNetworkInterfaceConfigurations] An error occured creating a new VMSS IP Config. To recover
address the following error, and try again specifying the -FailedMigrationRetryFilePath parameter and Basic Load Balancer backup
State file located either in this directory or the directory specified with -RecoveryBackupPath. `nError message: $_
"@
$message = "[_MigrateNetworkInterfaceConfigurations] An error occured creating a new VMSS IP Config. To recover, address the cause of the following error, then follow the steps at https://aka.ms/basiclbupgradefailure to retry the migration. Error: $_"
log 'Error' $message -terminateOnError
}
}
Expand Down Expand Up @@ -112,9 +108,7 @@ function InboundNatPoolsMigration {
$StdLoadBalancer | Add-AzLoadBalancerInboundNatPoolConfig @inboundNatPoolConfig > $null
}
catch {
$message = "[InboundNatPoolsMigration] An error occured when adding Inbound NAT Pool config '$($pool.name)' to the new Standard
Load Balancer. The script will continue. MANUALLY CREATE THE FOLLOWING INBOUND NAT POOL CONFIG ONCE THE SCRIPT COMPLETES.
`n$($inboundNatPoolConfig | ConvertTo-Json -Depth 5)$_$_"
$message = "[InboundNatPoolsMigration] An error occured when adding Inbound NAT Pool config '$($pool.name)' to the new Standard Load Balancer. The script will continue. MANUALLY CREATE THE FOLLOWING INBOUND NAT POOL CONFIG ONCE THE SCRIPT COMPLETES. `n$($inboundNatPoolConfig | ConvertTo-Json -Depth 5) $_"
log 'Warning' $message
}
}
Expand All @@ -134,11 +128,7 @@ function InboundNatPoolsMigration {
}
}
catch {
$message = @"
[InboundNatPoolsMigration] An error occured when adding Inbound NAT Pool config '$($pool.name)' to the new Standard Load Balancer. The script
will continue. MANUALLY CREATE THE FOLLOWING INBOUND NAT POOL CONFIG ONCE THE SCRIPT COMPLETES.
`n$($StdLoadBalancer | Get-AzLoadBalancerInboundNatPoolConfig | ConvertTo-Json -Depth 5)$_
"@
$message = "[InboundNatPoolsMigration] An error occured when adding Inbound NAT Pool config '$($pool.name)' to the new Standard Load Balancer. The script will continue. MANUALLY CREATE THE FOLLOWING INBOUND NAT POOL CONFIG ONCE THE SCRIPT COMPLETES. `n$($StdLoadBalancer | Get-AzLoadBalancerInboundNatPoolConfig | ConvertTo-Json -Depth 5)$_"
log 'Warning' $message
}

Expand All @@ -156,21 +146,11 @@ function InboundNatPoolsMigration {
catch {
$exceptionType = (($_.Exception.Message -split 'ErrorCode:')[1] -split 'ErrorMessage:')[0].Trim()
if($exceptionType -eq "MaxUnhealthyInstancePercentExceededBeforeRollingUpgrade"){
$message = @"
[InboundNatPoolsMigration] An error occured when attempting to update VMSS upgrade policy back to $($vmss.UpgradePolicy.Mode).
Looks like some instances were not healthy and in orther to change the VMSS upgra policy the majority of instances
must be healthy according to the upgrade policy. The module will continue but it will be required to change the VMSS
Upgrade Policy manually. `nError message: $_
"@
$message = "[InboundNatPoolsMigration] An error occured when attempting to update VMSS upgrade policy back to $($vmss.UpgradePolicy.Mode). Looks like some instances were not healthy and in orther to change the VMSS upgra policy the majority of instances must be healthy according to the upgrade policy. The module will continue but it will be required to change the VMSS Upgrade Policy manually. `nError message: $_"
log 'Error' $message -terminateOnError
}
else {
$message = @"
[InboundNatPoolsMigration] An error occured when attempting to update VMSS network config on the new Standard
LB backend pool membership. To recover address the following error, and try again specifying the
-FailedMigrationRetryFilePath parameter and Basic Load Balancer backup State file located either in
this directory or the directory specified with -RecoveryBackupPath. `nError message: $_
"@
$message = "[InboundNatPoolsMigration] An error occured when attempting to update VMSS network config on the new Standard LB backend pool membership. To recover address the following error, and try again specifying the -FailedMigrationRetryFilePath parameter and Basic Load Balancer backup State file located either in this directory or the directory specified with -RecoveryBackupPath. `nError message: $_"
log 'Error' $message -terminateOnError
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,7 @@ function LoadBalacingRulesMigration {
$StdLoadBalancer | Add-AzLoadBalancerRuleConfig @loadBalancingRuleConfig > $null
}
catch {
$message = @"
[LoadBalacingRulesMigration] An error occured when adding Load Balancing Rule '$($loadBalancingRule.Name)' to new Standard load
balancer '$($StdLoadBalancer.Name)'. To recover, address the following error, delete the standard LB, redeploy the Basic
load balancer from the backup 'ARMTemplate-$($BasicLoadBalancer.Name)-$($BasicLoadBalancer.ResourceGroupName)...' file, add backend
pool membership back (see the backup '$('State-' + $BasicLoadBalancer.Name + '-' + $BasicLoadBalancer.ResourceGroupName + '...')' state
file for original pool membership), and retry the migration. Error: $_
"@
$message = "[LoadBalacingRulesMigration] An error occured when adding Load Balancing Rule '$($loadBalancingRule.Name)' to new Standard load balancer '$($StdLoadBalancer.Name)'. To recover, address the following error, delete the standard LB, and follow the process at https://aka.ms/basiclbupgradefailure to retry migration. Error: $_"
log "Error" $message -terminateOnError
}
}
Expand All @@ -47,12 +41,7 @@ function LoadBalacingRulesMigration {
Set-AzLoadBalancer -LoadBalancer $StdLoadBalancer > $null
}
catch {
$message = @"
[LoadBalacingRulesMigration] An error occured when adding Load Balancing Rules configuration to new Standard load
balancer '$($StdLoadBalancer.Name)'. To recover address the following error, and try again specifying the
-FailedMigrationRetryFilePath parameter and Basic Load Balancer backup State file located either in this directory
or the directory specified with -RecoveryBackupPath. `nError message: $_
"@
$message = "[LoadBalacingRulesMigration] An error occured when adding Load Balancing Rules configuration to new Standard load balancer '$($StdLoadBalancer.Name)'. To recover address the following error, https://aka.ms/basiclbupgradefailure. `nError message: $_"
log "Error" $message -terminateOnError
}
log -Message "[LoadBalacingRulesMigration] LoadBalacing Rules Migration Completed"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ function NatRulesMigration {
}
}
catch {
$message = @"
[NatRulesMigration] Failed to check if inbound nat rule config '$($inboundNatRule.Name)' was created for an Inbound NAT Pool. Migration will continue, FAILED RULE WILL
NEED TO BE MANUALLY ADDED to the load balancer. Error: $_
"@
$message = "[NatRulesMigration] Failed to check if inbound nat rule config '$($inboundNatRule.Name)' was created for an Inbound NAT Pool. Migration will continue, FAILED RULE WILL NEED TO BE MANUALLY ADDED to the load balancer. Error: $_"
log "Error" $message
}

Expand Down Expand Up @@ -64,10 +61,7 @@ function NatRulesMigration {
$StdLoadBalancer | Add-AzLoadBalancerInboundNatRuleConfig @inboundNatRuleConfig > $null
}
catch {
$message = @"
[NatRulesMigration] Failed to add inbound nat rule config '$($inboundNatRule.Name)' to new standard load balancer '$($stdLoadBalancer.Name)' in resource
group '$($StdLoadBalancer.ResourceGroupName)'. Migration will continue, FAILED RULE WILL NEED TO BE MANUALLY ADDED to the load balancer. Error: $_
"@
$message = "[NatRulesMigration] Failed to add inbound nat rule config '$($inboundNatRule.Name)' to new standard load balancer '$($stdLoadBalancer.Name)' in resource group '$($StdLoadBalancer.ResourceGroupName)'. Migration will continue, FAILED RULE WILL NEED TO BE MANUALLY ADDED to the load balancer. Error: $_"
log "Error" $message
}
}
Expand All @@ -88,12 +82,7 @@ function NatRulesMigration {
}
}
catch {
$message = @"
[NatRulesMigration] Failed to update new standard load balancer '$($stdLoadBalancer.Name)' in resource
group '$($StdLoadBalancer.ResourceGroupName)' after attempting to add migrated inbound NAT rule
configurations. Migration will continue, INBOUND NAT RULES WILL NEED TO BE MANUALLY ADDED to the load
balancer. Error: $_
"@
$message = "[NatRulesMigration] Failed to update new standard load balancer '$($stdLoadBalancer.Name)' in resource group '$($StdLoadBalancer.ResourceGroupName)' after attempting to add migrated inbound NAT rule configurations. Migration will continue, INBOUND NAT RULES WILL NEED TO BE MANUALLY ADDED to the load balancer. Error: $_"
log "Error" $message
}
log -Message "[NatRulesMigration] Nat Rules Migration Completed"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,7 @@ function _AddLBNSGSecurityRules {
Set-AzNetworkSecurityGroup -NetworkSecurityGroup $nsg > $null
}
catch {
$message = @"
[NsgCreationVmss] An error occured while adding security rules to NSG '$($nsg.Name)'. TRAFFIC FROM LOAD BALANCER TO BACKEND POOL MEMBERS WILL
BE BLOCKED UNTIL AN NSG WITH AN ALLOW RULE IS CREATED! To recover, manually rules in NSG '$("NSG-"+$vmss.Name)' which allows traffic
to the backend ports on the VM/VMSS and associate the NSG with the VM, VMSS, or subnet. Error: $_
"@
$message = "[NsgCreationVmss] An error occured while adding security rules to NSG '$($nsg.Name)'. TRAFFIC FROM LOAD BALANCER TO BACKEND POOL MEMBERS WILL BE BLOCKED UNTIL AN NSG WITH AN ALLOW RULE IS CREATED! To recover, manually rules in NSG '$("NSG-"+$vmss.Name)' which allows traffic to the backend ports on the VM/VMSS and associate the NSG with the VM, VMSS, or subnet. Error: $_ "
log 'Error' $message -terminateOnError
}
}
Expand Down Expand Up @@ -255,11 +251,7 @@ function NsgCreationVmss {
$nsg = New-AzNetworkSecurityGroup -ResourceGroupName $vmss.ResourceGroupName -Name ("nsg-" + $vmss.Name) -Location $vmss.Location -Force
}
catch {
$message = @"
[NsgCreationVmss] An error occured while creating NSG '$("nsg-"+$vmss.Name)'. TRAFFIC FROM LOAD BALANCER TO BACKEND POOL MEMBERS WILL
BE BLOCKED UNTIL AN NSG WITH AN ALLOW RULE IS CREATED! To recover, manually create an NSG which allows traffic to the
backend ports on the VM/VMSS and associate it with the VM, VMSS, or subnet. Error: $_
"@
$message = "[NsgCreationVmss] An error occured while creating NSG '$("nsg-"+$vmss.Name)'. TRAFFIC FROM LOAD BALANCER TO BACKEND POOL MEMBERS WILL BE BLOCKED UNTIL AN NSG WITH AN ALLOW RULE IS CREATED! To recover, manually create an NSG which allows traffic to the backend ports on the VM/VMSS and associate it with the VM, VMSS, or subnet. Error: $_"
log 'Error' $message -terminateOnError
}

Expand Down Expand Up @@ -289,11 +281,7 @@ function NsgCreationVmss {
}
}
catch {
$message = @"
[NsgCreationVmss] An error occured while updating VMSS '$($vmss.name)' to associate the new NSG '$("NSG-"+$vmss.Name)'. TRAFFIC FROM LOAD BALANCER TO
BACKEND POOL MEMBERS WILL BE BLOCKED UNTIL AN NSG WITH AN ALLOW RULE IS CREATED! To recover, manually associate NSG '$("NSG-"+$vmss.Name)'
with the VM, VMSS, or subnet. Error: $_
"@
$message = "[NsgCreationVmss] An error occured while updating VMSS '$($vmss.name)' to associate the new NSG '$("NSG-"+$vmss.Name)'. TRAFFIC FROM LOAD BALANCER TO BACKEND POOL MEMBERS WILL BE BLOCKED UNTIL AN NSG WITH AN ALLOW RULE IS CREATED! To recover, manually associate NSG '$("NSG-"+$vmss.Name)' with the VM, VMSS, or subnet. Error: $_"
log 'Error' $message -terminateOnError
}

Expand Down
Loading

0 comments on commit 429b499

Please sign in to comment.