Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure 删除VMS网络接口配置时出错_Azure_Powershell_Azure Virtual Machine_Azure Powershell_Azure Load Balancer - Fatal编程技术网

Azure 删除VMS网络接口配置时出错

Azure 删除VMS网络接口配置时出错,azure,powershell,azure-virtual-machine,azure-powershell,azure-load-balancer,Azure,Powershell,Azure Virtual Machine,Azure Powershell,Azure Load Balancer,删除VMS网络接口配置时出错。代码如下: $myVmss = Get-AzVmss -ResourceGroupName 'MyApp-test-rg' -VMScaleSetName 'Myapp-vmss' Remove-AzVmssNetworkInterfaceConfiguration -VirtualMachineScaleSet $myVmss -Name $myVmss.VirtualMachineProfile.NetworkProfile.NetworkInterfac

删除VMS网络接口配置时出错。代码如下:

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

Remove-AzVmssNetworkInterfaceConfiguration -VirtualMachineScaleSet $myVmss -Name $myVmss.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations.IPConfigurations.Name
将错误获取为-

Remove-AzVmssNetworkInterfaceConfiguration: Sequence contains no matching element
有人能推荐一下吗

编辑:

我所要做的就是将基本LB的后端池配置应用于新的标准LB。在遵循Joy的建议后,remove命令起作用,但现在在更新AZVMS命令时面临问题

$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
这里是错误-

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.

您需要传递的名称是
NetworkInterfaceConfiguration
,而不是
IPConfiguration
,并且应该注意
myvms.virtualmachineeprofile.NetworkProfile.NetworkInterfaceConfigurations.name
是一个数组,因此您需要给出具体的数组

运行
删除AZVMSNetworkInterfaceConfiguration
之前,您可能需要检查
$myvms.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations.Name
以确认要删除的
网络接口配置

例如,如果要删除
测试
,则命令应为:

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

只是一个提示:

要使其生效,您需要停止虚拟机,然后在
删除AZVMSNetworkInterfaceConfiguration
之后使用
更新AZVMS

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

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

$myvmss | Update-AzVmss

谢谢你,乔伊。进行更改有助于命令的执行。我的主要动机是将基本LB的后端池迁移到标准LB,从而尝试将新std LB的后端池配置附加到VM。在更新AZVMS时,我遇到了这个错误-更新AZVMS:VM规模集的主网络接口配置/subscriptions/xxxxx/resourceGroups/xxxxx/providers/Microsoft.Compute/virtualMachine/。。无法更改。原始主网络接口配置:xxxxxx-vnet-v2-nic01,请求:MyNewConfig。更新了问题的详细信息@joy Wang。谢谢。@medinibster好吧,如果你原来的问题解决了,你能接受它并在不同的帖子中询问新问题吗?Stackoverflow避免在一篇文章中提出不同的问题,其他人也会明白这一点。