Tutorial: Configure both routing preference options for a virtual machine using the Azure portal
This article shows you how to configure both routing preference options (Internet and Microsoft global network) for a virtual machine (VM). This configuration is achieved using two virtual network interfaces. One network interface is configured with a public IP routed via the Microsoft global network. The other network interface is configured with a public IP routed via an ISP network.
In this tutorial, you learn how to:
- Create a virtual machine with a public IP address with the Microsoft network routing preference.
- Create a public IP address with the Internet routing preference.
- Create a secondary network interface for the virtual machine.
- Associate the Internet routing preference public IP to the virtual machine secondary network interface.
- Attach secondary network interface to virtual machine.
Prerequisites
- An Azure account with an active subscription. Create an account for free.
Create the virtual machine
In this section, you'll create a virtual machine and public IP address. During the public IP address configuration, you'll select Microsoft network for routing preference.
Sign in to the Azure portal.
In the portal search box, enter Virtual machine. In the search results, select Virtual machines.
In Virtual machines, select + Create, then + Virtual machine.
In 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 Create new.
Enter TutorVMMixRoutePref-rg. Select OK.Instance details Virtual machine name Enter myVM. Region Select (US) West US 2. Availability options Select No infrastructure redundancy required. Image Select Windows Server 2019 Datacenter - Gen2. Azure Spot instance Leave the default of unchecked. Size Select a size. Administrator account Username Enter a username. Password Enter a password. Confirm password Reenter password. Inbound port rules Public inbound ports Select Allow selected ports. Select inbound ports Leave the default of RDP (3389).
Opening port 3389 from the internet is not recommended for production workloads.Select Next: Disks then Next: Networking, or select the Networking tab.
In the networking tab, enter or select the following information.
Setting Value Network interface Virtual network Leave the default of (new) TutorVMMixRoutePref-rg-vnet. Subnet Leave the default of (new) default (10.1.0.0/24). Public IP Select Create new.
In Name, enter myPublicIP.
Select Standard in SKU.
In Routing preference, select Microsoft network.
Select OK.Select Review + create.
Select Create.
Create the public IP address
In this section, you'll create a public IP address with the Internet routing preference.
In the portal search box, enter Public IP address. In the search results, select Public IP addresses.
Select + Create.
In Create public IP address, enter or select the following information:
Setting Value IP Version Leave the default of IPv4. SKU Leave the default of Standard. Tier Leave the default of Regional. IPv4 IP Address Configuration Name Enter myPublicIP-IR. Routing preference Select Internet. Subscription Select your subscription. Resource group Select TutorVMMixRoutePref-rg. Location Select West US 2. Select Create.
Create the secondary NIC
In this section, you'll create a secondary network interface for the virtual machine you created previously.
In the portal search box, enter Network interface. In the search results, select Network interfaces.
Select + Create.
In Create network interface, enter or select the following information:
Setting Value Project details Subscription Select your subscription. Resource group Select TutorVMMixRoutePref-rg. Name Enter myVMNic2. Region Select West US 2. Virtual network Select TutorVMMixRoutePref-rg-vnet. Subnet Select TutorVMMixRoutePref-rg-vnet/default (10.1.0.0/24). Network security group Select myVM-nsg. Select the Review + create tab, or select the Review + create button at the bottom of the page.
Select Create.
Associate the public IP address with secondary NIC
In this section, you'll associate the Internet routing preference public IP address you created previously with the network interface you created in the previous section.
In the portal search box, enter Public IP address. In the search results, select Public IP addresses.
Select myPublicIP-IR.
In the Overview page of myPublic-IR, select Associate.
In Associate public IP address, select Network interface in the Resource type pull-down box.
Select myVMNic2 in the Network interface pull-down box.
Select OK.
Attach secondary network interface to virtual machine
In this section, you'll attach the secondary network interface you created previously to the virtual machine.
In the portal search box, enter Virtual machine. In the search results, select Virtual machines.
Select myVM.
Stop myVM if it's running, otherwise continue to next step.
In myVM, select Networking in Settings.
In Networking of myVM, select Attach network interface.
In Attach network interface, select myVMNic2 in the pull-down box.
Select OK.
Clean up resources
If you're not going to continue to use this application, delete the public IP addresses and virtual machine with the following steps:
In the search box at the top of the portal, enter Resource group.
In the search results, select Resource groups.
Select TutorVMMixRoutePref-rg
Select Delete resource group.
Enter myResourceGroup for TYPE THE RESOURCE GROUP NAME and select Delete.
Next steps
Advance to the next article to learn how to create a public IP prefix: