This article shows you how to configure routing preference via ISP network (Internet option) for a public IP address using the Azure portal, Azure PowerShell, or Azure CLI. After creating the public IP address, you can associate it with the following Azure resources for inbound and outbound traffic to the internet:
- Virtual machine
- Virtual machine scale set
- Azure Kubernetes Service (AKS)
- Internet-facing load balancer
- Application Gateway
- Azure Firewall
By default, the routing preference for public IP address is set to the Microsoft global network for all Azure services and can be associated with any Azure service.
Prerequisites
If you don't have an Azure trail subscription, create a trial subscription before you begin.
If you don't have an Azure trail subscription, create a trial subscription before you begin.
If you prefer to run CLI reference commands locally, install the Azure CLI. If you're running on Windows or macOS, consider running Azure CLI in a Docker container. For more information, see How to run the Azure CLI in a Docker container.
If you're using a local installation, sign in to the Azure CLI by using the az login command. To finish the authentication process, follow the steps displayed in your terminal. For other sign-in options, see Sign in with the Azure CLI.
When you're prompted, install the Azure CLI extension on first use. For more information about extensions, see Use extensions with the Azure CLI.
Run az version to find the version and dependent libraries that are installed. To upgrade to the latest version, run az upgrade.
- This article requires version 2.0.49 or later of the Azure CLI.
If you don't have an Azure trail subscription, create a trial subscription before you begin.
If you choose to install and use PowerShell locally, this article requires the Azure PowerShell module version 6.9.0 or later. Run Get-Module -ListAvailable Az to find the installed version. If you need to upgrade, see Install Azure PowerShell module. If you are running PowerShell locally, you also need to run Connect-AzAccount to create a connection with Azure.
Create a public IP address with a routing preference
Sign in to the Azure portal.
Select Create a resource.
In the search box, type Public IP address.
In the search results, select Public IP address. Next, in the Public IP address page, select Create.
In the Create public IP address page, enter or select this information:
| Setting |
Value |
| Project details |
|
| Subscription |
Select your subscription. |
| Resource group |
Select Create new, enter RoutingPreferenceResourceGroup, then select OK. |
| Instance details |
|
| Region |
Select China North 3. |
| Configuration details |
|
| Name |
Enter a name for the public IP address. |
| IP version |
Select IPv4. |
| SKU |
Select Standard. |
| Tier |
Select Regional. |
| Availability zone |
Select Zone-redundant. |
| IP address assignment |
Select Static. |
| Routing preference |
Select Internet. |
| DNS name label |
Enter a DNS name label if desired. |
Select Create.
Note
Public IP addresses are created with an IPv4 or IPv6 address. However, routing preference only supports IPV4 currently.
You can associate the above created public IP address with a Windows or Linux virtual machine. Use the CLI section on the tutorial page: Associate a public IP address to a virtual machine to associate the public IP to your VM. You can also associate the public IP address created above with an Azure Load Balancer, by assigning it to the load balancer frontend configuration. The public IP address serves as a load-balanced virtual IP address (VIP).
Create a resource group with the az group create command. The following example creates a resource group in the China North 3 Azure region:
az group create --name myResourceGroup --location chinanorth3
Create a public IP address
Create a Public IP Address with routing preference of Internet type using command az network public-ip create, with the format as shown below.
The following command creates a new public IP with Internet routing preference in the China North 3 Azure region.
az network public-ip create \
--name MyRoutingPrefIP \
--resource-group MyResourceGroup \
--location chinanorth3 \
--ip-tags 'RoutingPreference=Internet' \
--sku STANDARD \
--allocation-method static \
--version IPv4
Note
Currently, routing preference only supports IPV4 public IP addresses.
You can associate the above created public IP address with a Windows or Linux virtual machine. Use the CLI section on the tutorial page: Associate a public IP address to a virtual machine to associate the Public IP to your VM. You can also associate the public IP address created above with an Azure Load Balancer, by assigning it to the load balancer frontend configuration. The public IP address serves as a load-balanced virtual IP address (VIP).
The following command creates a new public IP with a routing preference type as Internet in the China North 3 Azure region:
$iptagtype="RoutingPreference"
$tagName = "Internet"
$ipTag = New-AzPublicIpTag -IpTagType $iptagtype -Tag $tagName
# attach the tag
$publicIp = New-AzPublicIpAddress `
-Name "MyPublicIP" `
-ResourceGroupName $rg.ResourceGroupName `
-Location $rg.Location `
-IpTag $ipTag `
-AllocationMethod Static `
-Sku Standard `
-IpAddressVersion IPv4
You can associate the above created public IP address with a Windows or Linux virtual machine. Use the CLI section on the tutorial page: Associate a public IP address to a virtual machine to associate the Public IP to your VM. You can also associate the public IP address created above with an Azure Load Balancer, by assigning it to the load balancer frontend configuration. The public IP address serves as a load-balanced virtual IP address (VIP).
Next steps