Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
275 views
in Technique[技术] by (71.8m points)

azure - Error on removing vmss Network Interface Configuration

Getting error on removing vmss Network InterfaceConfiguration. Here is the code:

$myVmss = Get-AzVmss -ResourceGroupName 'MyApp-test-rg' -VMScaleSetName 'Myapp-vmss'
 

Remove-AzVmssNetworkInterfaceConfiguration -VirtualMachineScaleSet $myVmss -Name $myVmss.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations.IPConfigurations.Name

Getting error as-

Remove-AzVmssNetworkInterfaceConfiguration: Sequence contains no matching element

can someone please suggest.

EDITED:

all I am trying to do is to apply the backendpool config of basic LB to new standard LB. After following the suggestion of Joy, remove command worked but now facing issue on update-azvmss command.

$myVmss = Get-AzVmss -ResourceGroupName $rgName -VMScaleSetName $vmssName
$newlb = (Get-AzLoadBalancer -ResourceGroupName $rgName -Name $newLbName)
$mySubnetId = $myVmss.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations.IpConfigurations[0].Subnet.Id
$backendPoolId = $newlb.BackendAddressPools.Id

$ipConfig = New-AzVmssIpConfig -Name MyNewConfig -SubnetId $mySubnetId -LoadBalancerBackendAddressPoolsId $backendPoolId

Remove-AzVmssNetworkInterfaceConfiguration -VirtualMachineScaleSet $myVmss -Name $myVmss.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations.Name[1]  

Add-AzVmssNetworkInterfaceConfiguration -Name MyNewConfig -Primary $true -VirtualMachineScaleSet $myVmss -IpConfiguration $ipConfig

$myVmss | Update-AzVmss

here is the error-

Update-AzVmss: Primary network interface configuration of VM scale set /subscriptions/xxxxxxxxxxxx/resourceGroups/xxxxxx-RG/providers/Microsoft.Compute/virtualMachineScaleSets/xxxxxxx cannot be changed. Original Primary network interface configuration: xxxxxx-vnet-v2-nic01, Requested: MyNewConfig.
question from:https://stackoverflow.com/questions/65598502/error-on-removing-vmss-network-interface-configuration

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You need to pass the name of NetworkInterfaceConfiguration, not IPConfiguration, and you should note myVmss.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations.Name is an array, so you need to give the specific one.

Before running Remove-AzVmssNetworkInterfaceConfiguration, you may need to check $myVmss.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations.Name to confirm the NetworkInterfaceConfiguration you want to remove.

enter image description here

For example, you want to remove Test, then the command should be:

Remove-AzVmssNetworkInterfaceConfiguration -VirtualMachineScaleSet $myVmss -Name $myVmss.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations.Name[1]

Just a tip:

To make it take effect, you need to stop the VMSS, then use Update-AzVmss after Remove-AzVmssNetworkInterfaceConfiguration.

$myVmss = Get-AzVmss -ResourceGroupName testvmss -VMScaleSetName myvmss 

Remove-AzVmssNetworkInterfaceConfiguration -VirtualMachineScaleSet $myVmss -Name $myVmss.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations.Name[1]

$myvmss | Update-AzVmss

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...