@@ -381,13 +381,13 @@ public String osDiskName() {
381
381
382
382
@ Override
383
383
public UpgradeMode upgradeModel () {
384
- // upgradePolicy is a required property so no null check
385
- return this .innerModel ().upgradePolicy ().mode ();
384
+ // flexible vmss won't have an upgrade mode
385
+ return this .innerModel ().upgradePolicy () == null ? null : this . innerModel (). upgradePolicy () .mode ();
386
386
}
387
387
388
388
@ Override
389
389
public boolean overProvisionEnabled () {
390
- return this .innerModel ().overprovision ();
390
+ return ResourceManagerUtils . toPrimitiveBoolean ( this .innerModel ().overprovision () );
391
391
}
392
392
393
393
@ Override
@@ -397,6 +397,9 @@ public VirtualMachineScaleSetSkuTypes sku() {
397
397
398
398
@ Override
399
399
public int capacity () {
400
+ if (this .innerModel ().sku () == null ) {
401
+ return 0 ;
402
+ }
400
403
return ResourceManagerUtils .toPrimitiveInt (this .innerModel ().sku ().capacity ());
401
404
}
402
405
@@ -2283,7 +2286,11 @@ private VirtualMachineScaleSetNetworkConfiguration primaryNicConfiguration() {
2283
2286
2284
2287
private static void associateBackEndsToIpConfiguration (
2285
2288
String loadBalancerId , VirtualMachineScaleSetIpConfiguration ipConfig , String ... backendNames ) {
2289
+ if (ipConfig == null || ipConfig .loadBalancerBackendAddressPools () == null ) {
2290
+ return ;
2291
+ }
2286
2292
List <SubResource > backendSubResourcesToAssociate = new ArrayList <>();
2293
+
2287
2294
for (String backendName : backendNames ) {
2288
2295
String backendPoolId = mergePath (loadBalancerId , "backendAddressPools" , backendName );
2289
2296
boolean found = false ;
@@ -2327,6 +2334,9 @@ private static void associateInboundNATPoolsToIpConfiguration(
2327
2334
2328
2335
private static Map <String , LoadBalancerBackend > getBackendsAssociatedWithIpConfiguration (
2329
2336
LoadBalancer loadBalancer , VirtualMachineScaleSetIpConfiguration ipConfig ) {
2337
+ if (ipConfig == null || ipConfig .loadBalancerBackendAddressPools () == null ) {
2338
+ return Collections .emptyMap ();
2339
+ }
2330
2340
String loadBalancerId = loadBalancer .id ();
2331
2341
Map <String , LoadBalancerBackend > attachedBackends = new HashMap <>();
2332
2342
Map <String , LoadBalancerBackend > lbBackends = loadBalancer .backends ();
@@ -2343,6 +2353,9 @@ private static Map<String, LoadBalancerBackend> getBackendsAssociatedWithIpConfi
2343
2353
2344
2354
private static Map <String , LoadBalancerInboundNatPool > getInboundNatPoolsAssociatedWithIpConfiguration (
2345
2355
LoadBalancer loadBalancer , VirtualMachineScaleSetIpConfiguration ipConfig ) {
2356
+ if (ipConfig == null || ipConfig .loadBalancerInboundNatPools () == null ) {
2357
+ return Collections .emptyMap ();
2358
+ }
2346
2359
String loadBalancerId = loadBalancer .id ();
2347
2360
Map <String , LoadBalancerInboundNatPool > attachedInboundNatPools = new HashMap <>();
2348
2361
Map <String , LoadBalancerInboundNatPool > lbInboundNatPools = loadBalancer .inboundNatPools ();
@@ -2388,6 +2401,9 @@ private static void removeLoadBalancerAssociationFromIpConfiguration(
2388
2401
2389
2402
private static void removeAllBackendAssociationFromIpConfiguration (
2390
2403
LoadBalancer loadBalancer , VirtualMachineScaleSetIpConfiguration ipConfig ) {
2404
+ if (ipConfig == null || ipConfig .loadBalancerBackendAddressPools () == null ) {
2405
+ return ;
2406
+ }
2391
2407
List <SubResource > toRemove = new ArrayList <>();
2392
2408
for (SubResource subResource : ipConfig .loadBalancerBackendAddressPools ()) {
2393
2409
if (subResource
@@ -2405,6 +2421,9 @@ private static void removeAllBackendAssociationFromIpConfiguration(
2405
2421
2406
2422
private static void removeAllInboundNatPoolAssociationFromIpConfiguration (
2407
2423
LoadBalancer loadBalancer , VirtualMachineScaleSetIpConfiguration ipConfig ) {
2424
+ if (ipConfig == null || ipConfig .loadBalancerInboundNatPools () == null ) {
2425
+ return ;
2426
+ }
2408
2427
List <SubResource > toRemove = new ArrayList <>();
2409
2428
for (SubResource subResource : ipConfig .loadBalancerInboundNatPools ()) {
2410
2429
if (subResource
@@ -2422,6 +2441,9 @@ private static void removeAllInboundNatPoolAssociationFromIpConfiguration(
2422
2441
2423
2442
private static void removeBackendsFromIpConfiguration (
2424
2443
String loadBalancerId , VirtualMachineScaleSetIpConfiguration ipConfig , String ... backendNames ) {
2444
+ if (ipConfig == null || ipConfig .loadBalancerBackendAddressPools () == null ) {
2445
+ return ;
2446
+ }
2425
2447
List <SubResource > toRemove = new ArrayList <>();
2426
2448
for (String backendName : backendNames ) {
2427
2449
String backendPoolId = mergePath (loadBalancerId , "backendAddressPools" , backendName );
@@ -2440,6 +2462,9 @@ private static void removeBackendsFromIpConfiguration(
2440
2462
2441
2463
private static void removeInboundNatPoolsFromIpConfiguration (
2442
2464
String loadBalancerId , VirtualMachineScaleSetIpConfiguration ipConfig , String ... inboundNatPoolNames ) {
2465
+ if (ipConfig == null || ipConfig .loadBalancerInboundNatPools () == null ) {
2466
+ return ;
2467
+ }
2443
2468
List <SubResource > toRemove = new ArrayList <>();
2444
2469
for (String natPoolName : inboundNatPoolNames ) {
2445
2470
String inboundNatPoolId = mergePath (loadBalancerId , "inboundNatPools" , natPoolName );
0 commit comments