Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
At this point, there is no way of adding \ associating additional Network Interfaces via the portal to an existing Virtual machine. We can add additional Network Interfaces during the time we create \ provision a new virtual machine or by deleting the existing virtual machine (keeping the disk) and re-provisioning the Virtual machine using the same OS VHD with associating multiple Network interfaces.
Before we begin, I suggest that you go through following article which to refer the requirements and constraints only.
You can also refer following article which helps describes in details on how to deploy a new virtual machine with multiple network interface in Azure Resource manager
https://azure.microsoft.com/en-in/documentation/articles/virtual-network-deploy-multinic-arm-ps/
As our goal is to add multiple Network Interface to an existing Virtual Machine we will have to delete the existing virtual machine and then re-create \ re-provision the Virtual Machine using following script
Note: The below script creates a Virtual Machine in an Availability Set and adds 2 network interfaces with one Public and Private IP on the Primary NIC and a Private IP on the secondary NIC.
As this virtual machine is going to be a part of Availability Set, at later stage we can even create an Azure Load balancer and add another Public IP.
Login-AzureRmAccountSelect-AzureRmSubscription -SubscriptionName ###Update the below Environment details ##### $VirtualMachineName = "sushrao1"$AvailabilitySet="sushraoavail"$vmSize="Standard_A6"$adminUsername="sushrao"$adminPassword="xxxxxxx"$PrivateIPforNIC1="192.168.1.23"$PrivateIPforNIC2="192.168.1.24" ## Existing OS VHD of the deleted Virtual Machine ## $sourceImageUri = "https://teststoragesushrao.blob.core.windows.net/vhds/testvm.vhd"$diskName= $VirtualMachineName + "OS-Disk" $ResourceGroupName="test”$LocationName="east us"$saName="teststoragesushrao"$vnetName="TestVNet"$subnetIndex=0$cred = New-Object PSCredential $adminUsername, ($adminPassword | ConvertTo-SecureString -AsPlainText -Force) ## Get the existing virtual network ## $vnet=Get-AzureRMvirtualNetwork -Name $vnetName -ResourceGroupName $ResourceGroupName ## Create the NIC1 ## $nicName="Primary"$pipName= $VirtualMachineName + "_pip"$domName= $VirtualMachineName$pip=New-AzureRmPublicIpAddress -Name $pipName -ResourceGroupName $ResourceGroupName -DomainNameLabel $domName -Location $LocationName -AllocationMethod Dynamic$nic=New-AzureRmNetworkInterface -Name $nicName -ResourceGroupName $ResourceGroupName -Location $LocationName -SubnetId $vnet.Subnets[$subnetIndex].Id -PublicIpAddressId $pip.Id -PrivateIpAddress $PrivateIPforNIC1 ## Create the NIC2 ## $nicName2="Secondary"$nic2=New-AzureRmNetworkInterface -Name $nicName2 -ResourceGroupName $ResourceGroupName -Location $LocationName -SubnetId $vnet.Subnets[$subnetIndex].Id -PrivateIpAddress $PrivateIPforNIC2 ## Create the availability group (if it does not exist) ## New-AzureRmAvailabilitySet –Name $AvailabilitySet –ResourceGroupName $ResourceGroupName -Location $LocationName ## Specify the name, size & associate the Network Interface to the virtual machine ## $vmName= $VirtualMachineName $avSet=Get-AzureRmAvailabilitySet –Name $AvailabilitySet –ResourceGroupName $ResourceGroupName$vm=New-AzureRMVMConfig -VMName $vmName -VMSize $vmSize -AvailabilitySetId $avset.Id$vm=Add-AzureRMVMNetworkInterface -VM $vm -Id $nic.Id -Primary$vm=Add-AzureRMVMNetworkInterface -VM $vm -Id $nic2.Id ## Specify the OS disk name $storageAcc=Get-AzureRMStorageAccount -ResourceGroupName $ResourceGroupName -Name $saName # Create VM from the existing OS disk $vm=Set-AzureRmVMOSDisk -VM $vm -Name $diskName -VhdUri $sourceImageUri -CreateOption attach -WindowsNew-AzureRmVM -ResourceGroupName $ResourceGroupName -Location $LocationName -VM $vm |
I strongly recommend that you perform the above actions on a test virtual machine and confirm if this suits your requirement before making any changes to the actual virtual machine.