I have Configured Azure virtual machine scale set with NIC and what I am trying to do is to apply the backendpool config of basic Load Balancer to new standard Load Balancer. After implementing the advice from my team
I want to remove NIC from my virtual machine scale set but it display an error
Error image
Remove-AzVmssNetworkInterfaceConfiguration: Sequence contains no matching element
I am using this powershell script
Remove-AzVmssNetworkInterfaceConfiguration -VirtualMachineScaleSet $myVmss -Name $myVmss.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations.NetworkInterfaceConfigurations
I tried to reproduce the same in my environment and got the same error like below:
To resolve this make use of below powershell command like below:
Check whether in vmss two nic are assoicate like below:
$myvmss = Get-azvmss -ResourceGroupName <RGName> -vmscalesetName <VmssName>
$myvmss.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations.Name
Update your virtual machine scale set using below command:
$myvmss | update-AzVmss
ResourceGroupName : v-imran
Sku :
Name : Standard_B1s
Tier : Standard
Capacity : 2
ProvisioningState : Succeeded
UniqueId : XXXXXXX539f-4462-bd5f-513cdf4416a9
SinglePlacementGroup : False
PlatformFaultDomainCount : 1
Identity :
Type : UserAssigned
UserAssignedIdentities :
{"/subscriptions/b83c1ed3-c5b6-XXXXX/resourceGroups/AzSecPackAutoConfigRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/AzSecPackAutoConfigUA-eastus":{"principalId":null,"clientId":null}}
Id : /subscriptions/b83c1ed3XXXXXX-2b83a0XXXXXXf/resourceGroups/v-imrankhan-mindtree/providers/Microsoft.Compute/virtualMachineScaleSets/infra
Name :
Type : Microsoft.Compute/virtualMachineScaleSets
Location : eastus
Tags : {"azsecpack":"nonprod","platformsettings.host_environment.service.platform_optedin_for_rootcerts":"true","Reason":"Repro","CreatedDate":
AM","CreatedBy":"NA","OwningTeam":"NA"}
When I try to execute the same command it execute successfully like below:
Remove-AzVmssNetworkInterfaceConfiguration -VirtualMachineScaleSet $myVmss -Name $myVmss.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations.NetworkInterfaceConfigurations me[1]
ResourceGroupName : v-imrankhan
Sku :
Name : Standard_B1s
Tier : Standard
Capacity : 2
ProvisioningState : Succeeded
UniqueId : 552c5e81-539f-4462-bd5f-513cdf4416a9
SinglePlacementGroup : False
PlatformFaultDomainCount : 1
Identity :
Type : UserAssigned
UserAssignedIdentities :
{"/subscriptions/b83c1ed3-c5b6-44fb-b5ba-XXXXX/resourceGroups/AzSecPackAutoConfigRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/AzSecPackAutoConfigUA-eastus":{"principalId":null,"clientId":null}}
Id : /subscriptions/b83c1ed3-c5b6-44fb-b5ba-XXXXXX/resourceGroups/v-imrankhan-mindtree/providers/Microsoft.Compute/virtualMachineScaleSets/infra
Name : infra
Type : Microsoft.Compute/virtualMachineScaleSets
Location : eastus
Tags : {"azsecpack":"nonprod","platformsettings.host_environment.service.platform_optedin_for_rootcerts":"true","Reason":"Repro","CreatedDate":"
AM","CreatedBy":"NA","OwningTeam":"NA"}
VirtualMachineProfile :
OsProfile :
ComputerNamePrefix : infr
AdminUsername : Imra WindowsConfiguration :
ProvisionVMAgent : True
Now, When I Check again NIC removed successfully like below: