Create an Azure Virtual Machine with Accelerated Networking
This article describes how to create a Linux or Windows virtual machine (VM) with Accelerated Networking (AccelNet) enabled by using the Azure CLI command-line interface.
Prerequisites
- An Azure account with an active subscription. You can create an account for free.
Create a virtual network
Create a virtual network and an Azure Bastion host
The following procedure creates a virtual network with a resource subnet, an Azure Bastion subnet, and a Bastion host:
In the portal, search for and select Virtual networks.
On the Virtual networks page, select + Create.
On the Basics tab of Create virtual network, enter, or select the following information:
Setting Value Project details Subscription Select your subscription. Resource group Select Create new.
Enter test-rg for the name.
Select OK.Instance details Name Enter vnet-1. Region Select East US 2. Select Next to proceed to the Security tab.
In the Azure Bastion section, select Enable Azure Bastion.
Bastion uses your browser to connect to VMs in your virtual network over Secure Shell (SSH) or Remote Desktop Protocol (RDP) by using their private IP addresses. The VMs don't need public IP addresses, client software, or special configuration. For more information, see What is Azure Bastion?.
In Azure Bastion, enter or select the following information:
Setting Value Azure Bastion host name Enter bastion. Azure Bastion public IP address Select Create a public IP address.
Enter public-ip-bastion in Name.
Select OK.Select Next to proceed to the IP Addresses tab.
In the address space box in Subnets, select the default subnet.
In Edit subnet, enter or select the following information:
Setting Value Subnet purpose Leave the default of Default. Name Enter subnet-1. IPv4 IPv4 address range Leave the default of 10.0.0.0/16. Starting address Leave the default of 10.0.0.0. Size Leave the default of /24 (256 addresses). Select Save.
Select Review + create at the bottom of the window. When validation passes, select Create.
Create a network interface with Accelerated Networking
Accelerated networking is enabled in the portal during virtual machine creation. Create a virtual machine in the following section.
Create a VM and attach the NIC
Create test virtual machine
The following procedure creates a test virtual machine (VM) named vm-1 in the virtual network.
In the portal, search for and select Virtual machines.
In Virtual machines, select + Create, then Azure virtual machine.
On the Basics tab of Create a virtual machine, enter or select the following information:
Setting Value Project details Subscription Select your subscription. Resource group Select test-rg. Instance details Virtual machine name Enter vm-1. Region Select East US 2. Availability options Select No infrastructure redundancy required. Security type Leave the default of Standard. Image Select Ubuntu Server 22.04 LTS - x64 Gen2. VM architecture Leave the default of x64. Size Select a size. Administrator account Authentication type Select Password. Username Enter azureuser. Password Enter a password. Confirm password Reenter the password. Inbound port rules Public inbound ports Select None. Select the Networking tab at the top of the page.
Enter or select the following information in the Networking tab:
Setting Value Network interface Virtual network Select vnet-1. Subnet Select subnet-1 (10.0.0.0/24). Public IP Select None. NIC network security group Select Advanced. Configure network security group Select Create new.
Enter nsg-1 for the name.
Leave the rest at the defaults and select OK.Leave the rest of the settings at the defaults and select Review + create.
Review the settings and select Create.
Note
Virtual machines in a virtual network with a bastion host don't need public IP addresses. Bastion provides the public IP, and the VMs use private IPs to communicate within the network. You can remove the public IPs from any VMs in bastion hosted virtual networks. For more information, see Dissociate a public IP address from an Azure VM.
Note
Azure provides a default outbound access IP for VMs that either aren't assigned a public IP address or are in the backend pool of an internal basic Azure load balancer. The default outbound access IP mechanism provides an outbound IP address that isn't configurable.
The default outbound access IP is disabled when one of the following events happens:
- A public IP address is assigned to the VM.
- The VM is placed in the backend pool of a standard load balancer, with or without outbound rules.
- An Azure NAT Gateway resource is assigned to the subnet of the VM.
VMs that you create by using virtual machine scale sets in flexible orchestration mode don't have default outbound access.
For more information about outbound connections in Azure, see Default outbound access in Azure and Use Source Network Address Translation (SNAT) for outbound connections.
Confirm that accelerated networking is enabled
Linux
In the Azure portal, search for and select virtual machines.
On the Virtual machines page, select your new VM.
On the VM's Overview page, select Connect then Connect via Bastion.
Enter the username and password you used when you created the VM, and then select Connect.
A new browser window opens with the Bastion connection to your VM.
From a shell on the remote VM, enter
uname -r
and confirm that the kernel version is one of the following versions, or greater:- Ubuntu 16.04: 4.11.0-1013.
- SLES SP3: 4.4.92-6.18.
- RHEL: 3.10.0-693, 2.6.32-573. RHEL 6.7-6.10 are supported if the Mellanox VF version 4.5+ is installed before Linux Integration Services 4.3+.
Note
Other kernel versions might be supported. For an updated list, see the compatibility tables for each distribution at Supported Linux and FreeBSD virtual machines for Hyper-V, and confirm that SR-IOV is supported. You can find more details in the release notes for Linux Integration Services for Hyper-V and Azure. *
Use the
lspci
command to confirm that the Mellanox VF device is exposed to the VM. The returned output should be similar to the following example:0000:00:00.0 Host bridge: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX Host bridge (AGP disabled) (rev 03) 0000:00:07.0 ISA bridge: Intel Corporation 82371AB/EB/MB PIIX4 ISA (rev 01) 0000:00:07.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01) 0000:00:07.3 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 02) 0000:00:08.0 VGA compatible controller: Microsoft Corporation Hyper-V virtual VGA 0001:00:02.0 Ethernet controller: Mellanox Technologies MT27500/MT27520 Family [ConnectX-3/ConnectX-3 Pro Virtual Function]
Use the
ethtool -S eth0 | grep vf_
command to check for activity on the virtual function (VF). If accelerated networking is enabled and active, you receive output similar to the following example:vf_rx_packets: 992956 vf_rx_bytes: 2749784180 vf_tx_packets: 2656684 vf_tx_bytes: 1099443970 vf_tx_dropped: 0
Close the Bastion connection to the VM.
Windows
Once you create the VM in Azure, connect to the VM and confirm that the Ethernet controller is installed in Windows.
In the Azure portal, search for and select virtual machines.
On the Virtual machines page, select your new VM.
On the VM's Overview page, select Connect then Connect via Bastion.
Enter the credentials you used when you created the VM, and then select Connect.
A new browser window opens with the Bastion connection to your VM.
On the remote VM, right-click Start and select Device Manager.
In the Device Manager window, expand the Network adapters node.
Confirm that the Mellanox ConnectX-4 Lx Virtual Ethernet Adapter appears, as shown in the following image:
The presence of the adapter confirms that Accelerated Networking is enabled for your VM.
Verify the packets are flowing over the VF interface from the output of the following command:
PS C:\ > Get-NetAdapter | Where-Object InterfaceDescription –like "*Mellanox*Virtual*" | Get-NetAdapterStatistics Name ReceivedBytes ReceivedUnicastPackets SentBytes SentUnicastPackets ---- ------------- ---------------------- --------- ------------------ Ethernet 2 492447549 347643 7468446 34991
Note
If the Mellanox adapter fails to start, open an administrator command prompt on the remote VM and enter the following command:
netsh int tcp set global rss = enabled
Close the Bastion connection to the VM.