azure automactically changes subnet for vmss

Muhammed Noor 16 Reputation points
2022-05-21T13:47:54.053+00:00

I have an image, I need to created a vm scaleset from it.

I have a vnet "vnet1" and different subnets ("LB-subnet","VMSS-subnet","Mangement-Subnet"). I created a load balancer in LB-subnet and it has frontend ip of 10.2.0.4. After that I created a VMSS(uniform) from my image and put it in vmss-subnet and attached the LB to it. But after the VMSS deployment, when i check its subnet, it is randomly selected. or may be the first subnet is selected. There is no option in vmss or its instances to change/add the nic just like we can in normal machines. is there any way to avoid it.

Azure Virtual Network
Azure Virtual Network
An Azure networking service that is used to provision private networks and optionally to connect to on-premises datacenters.
2,139 questions
Azure Virtual Machine Scale Sets
Azure Virtual Machine Scale Sets
Azure compute resources that are used to create and manage groups of heterogeneous load-balanced virtual machines.
347 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Sergio Monedero 10 Reputation points
    2023-10-23T08:52:05.1333333+00:00

    October 2023 and the bug is not solved. Azure Portal still assigns a random subnet to new VMSS.

    I found a simpler way of changing subnet without creating a new NIC.

    First, get the Resource ID of the subnet in the properties section of Azure Portal or in Azure Resource Explorer https://resources.azure.com/

    After, replace the variable values of this Azure Powershell script and run it:

    $ResourceGroupName = "<ResourceGroupName>"
    $ScaleSetName = "<ScaleSetName>"
    $NewSubnetResourceId = "<NewSubnetResourceId>"
    
    $vmss = Get-AzVmss -ResourceGroupName $ResourceGroupName -VMScaleSetName $ScaleSetName
    $vmss.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations[0].IpConfigurations[0].Subnet.Id = $NewSubnetResourceId
    Update-AzVmss -ResourceGroupName $ResourceGroupName -VMScaleSetName $ScaleSetName -VirtualMachineScaleSet $vmss
    
    2 people found this answer helpful.

  2. olavrb 131 Reputation points
    2023-03-02T18:50:46.37+00:00

    This bug is still present in the Azure portal when creating a VMSS into an existing VNet with multiple subnets: Whatever subnet the VMSS NIC defaulted to when selecting an existing VNet will be the one it deploys to, even though you changed it in the NIC settings.

    1 person found this answer helpful.
    0 comments No comments

  3. srbhatta-MSFT 8,546 Reputation points Microsoft Employee
    2022-05-25T09:23:53.063+00:00

    Hello @Muhammed Noor ,
    Thank you for reaching out to Microsoft QnA.
    I have done a repro of the same, and I see that every time the subnet of the VMSS gets changed to the subnet of the load balancer. This makes me think that it is the default behavior when we attach the vmss to a load balancer.
    You can however add a secondary nic to your VMSS using this Powershell command and then update the VMSS. Once you update the VMSS, the secondary nic will be reflected at each of the VMSS instance level.

    Hope this helps. If you have any queries, feel free to reach back.

    --------------------------------

    Please accept as answer and upvote if the information provided was useful.

    0 comments No comments