Reputation: 421
I'm trying to add a second network interface with Windows PowerShell to a Microsoft Azure Virtual Machine Scale Set (VMSS). The VMSS already exists.
I am using Powershell since the az cli does not yet support adding network interfaces.
But my code seems not to work, since the network interface does not come up in the virtual machine.
I am referencing to code from http://thebluenode.com/azure-virtual-machine-scale-set-instances-upgrade-with-zero-downtime-rolling-update .
Please see my Powershell code what I am doing wrong. I guess I have to add some private IP configuration, but I don't know where.
Can you help me how to add a second network interface to my VMSS?
Thanks in advance.
Best regards,
Ronny Forberger
Tried the Powershell code provided.
Add-AzureRmAccount
Select-AzureRmSubscription -SubscriptionId "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
$vnetname = "conf-virtual-network-interlink"
$loc = "West Europe"
$backendSubnetName = "default"
$backendSubnetConfig = New-AzureRmVirtualNetworkSubnetConfig -Name $backendSubnetName -AddressPrefix "10.1.0.0/24"
echo "backendSubnetConfig: "$backendSubnetConfig
$vnet = New-AzureRmVirtualNetwork -ResourceName $vnetname -Location $loc -ResourceGroupName "resourcegroup-confluence-jira-datacenter" -Subnet $backendSubnetConfig -AddressPrefix "10.1.0.0/24"
echo "vnet: "$vnet
$subnetId = (Get-AzureRmVirtualNetworkSubnetConfig -Name $backendSubnetName -VirtualNetwork $vnet).Id
echo "subnetId: "$subnetId
$ipCfg = New-AzureRmVmssIPConfig -Name 'eth1' -SubnetId $subnetId
echo "ipCfg: "$ipCfg
$backendSubnet = Get-AzureRmVirtualNetworkSubnetConfig -Name $backendSubnetName -VirtualNetwork $vnet
echo "backendSubnet: "$backendSubnet
$vmss = Get-AzureRmVmss -ResourceGroupName resourcegroup-confluence-jira-datacenter -VMScaleSetName confcluster
echo "vmss: "$vmss
Add-AzureRmVmssNetworkInterfaceConfiguration -Name $backendSubnet -Primary $false -IPConfiguration $ipCfg -VirtualMachineScaleSet $vmss
Expected result is, that the network adapter in the VM of the VMSS comes up (ideally with a configured private IP).
Upvotes: 1
Views: 3316
Reputation: 15
Had a similar ask.. tried your script, works well. You just have to run below commandlet once your vmss object is modified to have additional secondary NIC.
Update-AzureRmVmss -ResourceGroupName "resourcegroup-confluence-jira-datacenter" -Name "confcluster" -VirtualMachineScaleSet $vmss
Upvotes: 0
Reputation: 421
It's not possible to have different network adapters in different virtual networks. they have to be on the same virtual network, they can be on a different subnet in the same virtual network
Upvotes: 1
Reputation: 1153
@RonnyForberger According to the article -
You can have up to 8 NICs per virtual machine, depending on machine size. The maximum number of NICs per machine is available in the VM size article. All NICs connected to a VM instance must connect to the same virtual network. The NICs can connect to different subnets, but all subnets must be part of the same virtual network.
Please make sure you use the same virtual network to create a new NIC configuration for your VMSS. Also, if you don't mention any public IP configurations, the NIC will be assigned a private IP by default.
The script you are using should ideally work, provided the above conditions are met.
You can use the below command to list the NICs in the portal cloud shell:
az vmss nic list --resource-group amgar-resource-group --vmss-name nt1
Upvotes: 0