About Me

My photo
I am an MCSE in Data Management and Analytics, specializing in MS SQL Server, and an MCP in Azure. With over 19+ years of experience in the IT industry, I bring expertise in data management, Azure Cloud, Data Center Migration, Infrastructure Architecture planning, as well as Virtualization and automation. I have a deep passion for driving innovation through infrastructure automation, particularly using Terraform for efficient provisioning. If you're looking for guidance on automating your infrastructure or have questions about Azure, SQL Server, or cloud migration, feel free to reach out. I often write to capture my own experiences and insights for future reference, but I hope that sharing these experiences through my blog will help others on their journey as well. Thank you for reading!

How to add a Secondary NIC on a VM in Azure


How to add a Secondary NIC on a VM in Azure
===================================

I have a Virtual Machine named sqlnode1 and it is on ResourceGroupName  rakctlrg
The Virtual Machine has a NIC interface whose IP address is 10.0.0.4
The customer comes and say that they want to add a Extra NIC on the server.
How we will add a Extra NIC on the server.

Below is the Step by Step process to ADD a Secondary NIC on the server.
======================================================
1. Go to shell.azure.com
2. login to shell.azure.com


#First store the Azure VM in the a $VM variable

$vm = Get-AzureRmVm -Name "sqlnode1" -ResourceGroupName "rakctlrg"

#Make existing NIC as a Priamry NIC.
================================

$VM.NetworkProfile.NetworkInterfaces.Item(0).primary = $true
Update-AzureRmVM -ResourceGroupName "rakctlrg" -VM $VM

# Get info for the back end subnet

$myVnet = Get-AzureRmVirtualNetwork -Name "rakctlrg-vnet" -ResourceGroupName "rakctlrg"
$backEnd = $myVnet.Subnets|?{$_.Name -eq 'default'}

# Create a virtual NIC
====================

$myNic3 = New-AzureRmNetworkInterface -ResourceGroupName "rakctlrg" `
    -Name "myNic3" `
    -Location "centralus" `
    -SubnetId $backEnd.Id

# Get the ID of the new virtual NIC and add to VM
$nicId = (Get-AzureRmNetworkInterface -ResourceGroupName "rakctlrg" -Name "MyNic3").Id


Before executing below command, you need to stop the VM.
Then execute the below command

#Add a AzureRMVMNetworkInterface
=============================
Add-AzureRmVMNetworkInterface -VM $vm -Id $nicId | Update-AzureRmVm -ResourceGroupName "rakctlrg"


Then start the VM, you will find one more NIC in the server.


you will observe one extra NIC has been added in Azure VM.






Important point to remember:-
=======================

1. VM should be in deallocated state.
2. we can add multiple NIC in a VM, but it depends on the size of VM, example D2s v3  can support maximum of 2 NIC.
3. when adding 2nd NIC, first NIC should be on primary NIC.



Thanks for Reading..