Attaching a network interface to an Azure VM is a crucial task for the developers to manage the cloud infrastructure. This article discusses two simple approaches to attaching a network interface to your existing Azure Virtual Machine.
Table of Contents
Attach Network Interface To Azure VM
Let us dive deep into the approaches individually.
- Approach-1: Using Azure Portal
- Approach-2: Using PowerShell
Approach-1: Using Azure Portal
Follow the below steps
1. Log in to the Azure Portal.
2. Search for the virtual machine and click on the search result from Virtual Machines.

3. Select the specific virtual machine from the list of VMs to which you wish to attach the network interface.

4. On the Virtual machine page, expand the Networking, click the Networking settings link, and click the Attach network interface button as shown in the screenshot below.

Check out How To Detach Network Interface Azure
5. On the attach network interface window, select an existing Azure network interface. Alternatively, click on the Create and attach network interface link to create a new network interface and attach it to the existing VM.

If you click on the Create and Attach network interface link, you must fill in the details below.
- Resource Group: You can select an existing Resource group or click the Create new link to create a new one.
- Name: Enter a name for your network interface.
- Subnet: Select a subnet.
- Public inbound ports: Select none or allow selected ports based on your requirement. If you choose to allow selected ports, you need to select those ports you wish to allow in the Select inbound ports option, as shown in the screenshot below.

Based on your requirements, select all other optional options and then click the Create button to create the network interface.


The new network interface is successfully created and attached to the existing Azure VM.

Now, on the Azure Virtual Machine page, click on the Network settings link. You will see the new network interface attached to the VM successfully. Check out the screenshot below for your reference.

Check out Get-AzVirtualNetworkSubnetConfig
Approach-2: Using PowerShell
You can also use the below PowerShell command to add a network interface to Azure VM.
$myVM = Get-AzVM -ResourceGroupName "newresgroup" -Name "AzureLessonsVM"
Add-AzVMNetworkInterface -VM $myVM -Id "subscriptions/1cdf4300-dee5-4518-9c9c-feaa72a5cbd1/resourceGroups/newresgroup/providers/Microsoft.Network/networkInterfaces/azurelessonsvm908"
Update-AzVM -ResourceGroupName "newresgroup" -VM $myVMAfter executing the Azure PowerShell command, you can see that the command was executed successfully and that the new network interface was successfully attached to the Azure VM.

To cross-check, I just logged in to the Azure portal and verified that the provided Azure network interface has been successfully attached to the existing VM.

Conclusion
Attaching network interfaces to Azure VMs is essential to maintaining a robust cloud infrastructure. Using the information mentioned in this article, you can easily achieve this task using Azure Portal and PowerShell.
You may also like following the articles below
- How to delete Virtual Network in Azure
- Azure VM accelerated networking
- Azure Network Watcher
- Get-AzVirtualNetwork

I am Rajkishore, and I am a Microsoft Certified IT Consultant. I have over 14 years of experience in Microsoft Azure and AWS, with good experience in Azure Functions, Storage, Virtual Machines, Logic Apps, PowerShell Commands, CLI Commands, Machine Learning, AI, Azure Cognitive Services, DevOps, etc. Not only that, I do have good real-time experience in designing and developing cloud-native data integrations on Azure or AWS, etc. I hope you will learn from these practical Azure tutorials. Read more.
