@@ -70,6 +70,40 @@ def _output(self, *args, **kwargs):
7070 return result
7171
7272
73+ _VMSS_IP_CONFIG_OPTIONAL_COLLECTIONS = (
74+ 'applicationGatewayBackendAddressPools' ,
75+ 'applicationSecurityGroups' ,
76+ 'loadBalancerBackendAddressPools' ,
77+ 'loadBalancerInboundNatPools' ,
78+ )
79+
80+
81+ def _normalize_vmss_generic_update_collections (vmss ):
82+ # AAZ omits unset optional properties, while generic `--add` needs them present as None.
83+ vm_profile = vmss .get ('virtualMachineProfile' )
84+ network_profile = vm_profile .get ('networkProfile' ) if isinstance (vm_profile , dict ) else None
85+ nic_configs = network_profile .get ('networkInterfaceConfigurations' ) if isinstance (network_profile , dict ) else None
86+ if not isinstance (nic_configs , list ):
87+ return vmss
88+ for nic_config in nic_configs :
89+ ip_configs = nic_config .get ('ipConfigurations' ) if isinstance (nic_config , dict ) else None
90+ if not isinstance (ip_configs , list ):
91+ continue
92+ for ip_config in ip_configs :
93+ if isinstance (ip_config , dict ):
94+ for collection in _VMSS_IP_CONFIG_OPTIONAL_COLLECTIONS :
95+ ip_config .setdefault (collection , None )
96+ return vmss
97+
98+
99+ class VMSSShowForUpdate (VMSSShow ):
100+ """Show a VMSS with optional IP-config collections initialized for generic update."""
101+
102+ def _output (self , * args , ** kwargs ):
103+ result = super ()._output (* args , ** kwargs )
104+ return _normalize_vmss_generic_update_collections (result )
105+
106+
73107class VMSSPatch (_VMSSPatch ):
74108
75109 def _output (self , * args , ** kwargs ):
0 commit comments