Skip to content

Commit 2b756ee

Browse files
authored
support unconfigured lb (#140)
1 parent 39e3aeb commit 2b756ee

File tree

5 files changed

+74
-14
lines changed

5 files changed

+74
-14
lines changed

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.4.22'
15+
ModuleVersion = '2.4.23'
1616

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

109109
# ReleaseNotes of this module
110-
ReleaseNotes = 'Added validation check for customers using floating IP and non-primary IP configurations.'
110+
ReleaseNotes = 'Added support for basic LBs with no child resources.'
111111

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

AzureBasicLoadBalancerUpgrade/module/AzureBasicLoadBalancerUpgrade/modules/Start-AzBasicLoadBalancerUpgrade/Start-AzBasicLoadBalancerUpgrade.psm1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,19 @@ function Start-AzBasicLoadBalancerUpgrade {
439439
RestoreExternalLBMigrationEmpty @standardScenarioParams
440440
}
441441
}
442+
'none' {
443+
if ((!$PSBoundParameters.ContainsKey("FailedMigrationRetryFilePathLB"))) {
444+
InternalLBMigrationEmpty @standardScenarioParams -RecoveryBackupPath $RecoveryBackupPath
445+
}
446+
else {
447+
RestoreInternalLBMigrationEmpty @standardScenarioParams
448+
}
449+
}
442450
}
443451
}
452+
default {
453+
log -Severity 'Error' -Message "[Start-AzBasicLoadBalancerUpgrade] Unexpected backend type '$($migrationConfig.scenario.ExternalOrInternal)' for Basic Load Balancer '$($migrationConfig.BasicLoadBalancer.Name)' in Resource Group '$($migrationConfig.BasicLoadBalancer.ResourceGroupName)'. Migration failed." -terminateOnError
454+
}
444455
}
445456

446457
$migrationConfigsCompleted++

AzureBasicLoadBalancerUpgrade/module/AzureBasicLoadBalancerUpgrade/modules/ValidateScenario/ValidateScenario.psm1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,11 @@ Function Test-SupportedMigrationScenario {
156156

157157
# detecting if source load balancer is internal or external-facing
158158
log -Message "[Test-SupportedMigrationScenario] Determining if LB is internal or external based on FrontEndIPConfiguration[0]'s IP configuration"
159-
If (![string]::IsNullOrEmpty($BasicLoadBalancer.FrontendIpConfigurations[0].PrivateIpAddress)) {
159+
If ([string]::IsNullOrEmpty($BasicLoadBalancer.FrontendIpConfigurations[0])) {
160+
log -Message "[Test-SupportedMigrationScenario] FrontEndIPConfiguiration[0] is empty--this load balancer has no configuration (sigh)."
161+
$scenario.ExternalOrInternal = 'None'
162+
}
163+
ElseIf (![string]::IsNullOrEmpty($BasicLoadBalancer.FrontendIpConfigurations[0].PrivateIpAddress)) {
160164
log -Message "[Test-SupportedMigrationScenario] FrontEndIPConfiguiration[0] is assigned a private IP address '$($BasicLoadBalancer.FrontendIpConfigurations[0].PrivateIpAddress)', so this LB is Internal"
161165
$scenario.ExternalOrInternal = 'Internal'
162166
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
targetScope = 'resourceGroup'
2+
param randomGuid string = newGuid()
3+
param location string
4+
param resourceGroupName string
5+
6+
// vnet
7+
module virtualNetworks '../modules/Microsoft.Network/virtualNetworks/deploy.bicep' = {
8+
name: '${uniqueString(deployment().name)}-virtualNetworks'
9+
scope: resourceGroup(resourceGroupName)
10+
params: {
11+
// Required parameters
12+
location: location
13+
addressPrefixes: [
14+
'10.0.0.0/16'
15+
]
16+
name: 'vnet-01'
17+
subnets: [
18+
{
19+
name: 'subnet-01'
20+
addressPrefix: '10.0.1.0/24'
21+
}
22+
]
23+
}
24+
dependsOn: [
25+
]
26+
}
27+
28+
// basic lb
29+
resource loadbalancer_emptyfe 'Microsoft.Network/loadBalancers@2024-05-01' = {
30+
name: 'lb-basic-01'
31+
location: location
32+
sku: {
33+
name: 'Basic'
34+
}
35+
properties: {
36+
frontendIPConfigurations: []
37+
backendAddressPools: []
38+
inboundNatRules: []
39+
loadBalancingRules: []
40+
probes: []
41+
42+
}
43+
}

AzureBasicLoadBalancerUpgrade/testEnvs/scripts/deploy.ps1

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,19 @@ $jobs = @()
136136
ForEach ($resourceGroupSuffixI in $resourceGroupSuffix) {
137137
foreach ($template in $filteredTemplates) {
138138
$rgTemplateName = "rg-{0}{1}-{2}" -f $template.BaseName.split('-')[0], $resourceGroupSuffixI, $template.BaseName.split('-', 2)[1]
139-
if ($template.FullName -like "*.bicep") {
139+
if ($template.Name -match "(019|044)-") {
140+
141+
$params = @{
142+
Name = "vmss-lb-deployment-$((get-date).tofiletime())"
143+
TemplateFile = $template.FullName
144+
Location = $Location
145+
resourceGroupNameFromTemplate = $rgTemplateName
146+
}
147+
$null = New-AzResourceGroup -Name $rgTemplateName -Location $Location -Force -ErrorAction SilentlyContinue
148+
$jobs += New-AzResourceGroupDeployment -ResourceGroupName $rgTemplateName @params -AsJob
149+
}
150+
151+
elseif ($template.FullName -like "*.bicep") {
140152
$params = @{
141153
Name = "vmss-lb-deployment-$((get-date).tofiletime())"
142154
TemplateFile = $template.FullName
@@ -151,16 +163,6 @@ ForEach ($resourceGroupSuffixI in $resourceGroupSuffix) {
151163
$jobs += $job
152164
}
153165

154-
elseif ($template.Name -like "019*.json") {
155-
156-
$params = @{
157-
Name = "vmss-lb-deployment-$((get-date).tofiletime())"
158-
TemplateFile = $template.FullName
159-
}
160-
$null = New-AzResourceGroup -Name $rgTemplateName -Location $Location -Force -ErrorAction SilentlyContinue
161-
$jobs += New-AzResourceGroupDeployment -ResourceGroupName $rgTemplateName @params -AsJob
162-
}
163-
164166
elseif ($template.Name -like "*.json") {
165167
$params = @{
166168
Name = "vmss-lb-deployment-$((get-date).tofiletime())"

0 commit comments

Comments
 (0)