Networking Faq
Networking Faq
Networking Faq
Azure Virtual Network (VNet) is the fundamental building block for your private network in Azure. VNet enables
many types of Azure resources, such as Azure Virtual Machines (VM), to securely communicate with each other,
the internet, and on-premises networks. VNet is similar to a traditional network that you'd operate in your own
data center, but brings with it additional benefits of Azure's infrastructure such as scale, availability, and isolation.
VNet concepts
Address space: When creating a VNet, you must specify a custom private IP address space using public and
private (RFC 1918) addresses. Azure assigns resources in a virtual network a private IP address from the
address space that you assign. For example, if you deploy a VM in a VNet with address space, 10.0.0.0/16, the
VM will be assigned a private IP like 10.0.0.4.
Subnets: Subnets enable you to segment the virtual network into one or more sub-networks and allocate a
portion of the virtual network's address space to each subnet. You can then deploy Azure resources in a
specific subnet. Just like in a traditional network, subnets allow you to segment your VNet address space into
segments that are appropriate for the organization's internal network. This also improves address allocation
efficiency. You can secure resources within subnets using Network Security Groups. For more information, see
Network security groups.
Regions : VNet is scoped to a single region/location; however, multiple virtual networks from different regions
can be connected together using Virtual Network Peering.
Subscription: VNet is scoped to a subscription. You can implement multiple virtual networks within each
Azure subscription and Azure region.
Best practices
As you build your network in Azure, it is important to keep in mind the following universal design principles:
Ensure non-overlapping address spaces. Make sure your VNet address space (CIDR block) does not overlap
with your organization's other network ranges.
Your subnets should not cover the entire address space of the VNet. Plan ahead and reserve some address
space for the future.
It is recommended you have fewer large VNets rather than multiple small VNets. This will prevent
management overhead.
Secure your VNet's by assigning Network Security Groups (NSGs) to the subnets beneath them.
NOTE
When using only an internal Standard Load Balancer, outbound connectivity is not available until you define how you want
outbound connections to work with an instance-level public IP or a public Load Balancer.
Communicate between Azure resources
Azure resources communicate securely with each other in one of the following ways:
Through a vir tual network : You can deploy VMs, and several other types of Azure resources to a virtual
network, such as Azure App Service Environments, the Azure Kubernetes Service (AKS), and Azure Virtual
Machine Scale Sets. To view a complete list of Azure resources that you can deploy into a virtual network, see
Virtual network service integration.
Through a vir tual network ser vice endpoint : Extend your virtual network private address space and the
identity of your virtual network to Azure service resources, such as Azure Storage accounts and Azure SQL
Database, over a direct connection. Service endpoints allow you to secure your critical Azure service resources
to only a virtual network. To learn more, see Virtual network service endpoints overview.
Through VNet Peering : You can connect virtual networks to each other, enabling resources in either virtual
network to communicate with each other, using virtual network peering. The virtual networks you connect can
be in the same, or different, Azure regions. To learn more, see Virtual network peering.
Pricing
There is no charge for using Azure VNet, it is free of cost. Standard charges are applicable for resources, such as
Virtual Machines (VMs) and other products. To learn more, see VNet pricing and the Azure pricing calculator.
Next steps
To get started using a virtual network, create one, deploy a few VMs to it, and communicate between the VMs. To
learn how, see the Create a virtual network quickstart.
Quickstart: Create a virtual network using the Azure
portal
11/2/2020 • 5 minutes to read • Edit Online
In this quickstart, you learn how to create a virtual network using the Azure portal. You deploy two virtual
machines (VMs). Next, you securely communicate between VMs and connect to VMs from the internet. A virtual
network is the fundamental building block for your private network in Azure. It enables Azure resources, like VMs,
to securely communicate with each other and with the internet.
Prerequisites
An Azure account with an active subscription. Create one for free.
Sign in to Azure
Sign in to the Azure portal.
SET T IN G VA L UE
3. Select Next: IP Addresses , and for IPv4 address space , enter 10.1.0.0/16.
4. Select Add subnet , then enter myVirtualSubnet for Subnet name and 10.1.0.0/24 for Subnet address
range .
5. Select Add , then select Review + create . Leave the rest as default and select Create .
6. In Create vir tual network , select Create .
SET T IN G VA L UE
Project details
Instance details
Administrator account
Save money
SET T IN G VA L UE
SET T IN G VA L UE
10. Select OK , then select Review + create . You're taken to the Review + create page where Azure validates
your configuration.
11. When you see the Validation passed message, select Create .
Create the second VM
Repeat the procedure in the previous section to create another virtual machine.
IMPORTANT
For the Vir tual machine name , enter myVm2.
For Diagnosis storage account , make sure you select myvmstorageaccount , instead of creating one.
NOTE
You may need to select More choices > Use a different account , to specify the credentials you entered when
you created the VM.
6. Select OK .
7. You may receive a certificate warning when you sign in. If you receive a certificate warning, select Yes or
Continue .
8. Once the VM desktop appears, minimize it to go back to your local desktop.
Pinging myVm2.0v0zze1s0uiedpvtxz5z0r0cxg.bx.internal.clouda
Request timed out.
Request timed out.
Request timed out.
Request timed out.
The ping fails, because ping uses the Internet Control Message Protocol (ICMP). By default, ICMP isn't
allowed through the Windows firewall.
3. To allow myVm2 to ping myVm1 in a later step, enter this command:
New-NetFirewallRule –DisplayName "Allow ICMPv4-In" –Protocol ICMPv4
You receive replies from myVm1, because you allowed ICMP through the Windows firewall on the myVm1
VM in step 3.
7. Close the remote desktop connection to myVm2.
Clean up resources
In this quickstart, you created a default virtual network and two VMs. You connected to one VM from the internet
and securely communicated between the two VMs.
When you're done using the virtual network and the VMs, delete the resource group and all of the resources it
contains:
1. Search for and select myResourceGroup.
2. Select Delete resource group .
3. Enter myResourceGroup for TYPE THE RESOURCE GROUP NAME and select Delete .
Next steps
To learn more about virtual network settings, see Create, change, or delete a virtual network.
By default, Azure allows secure communication between VMs. Azure only allows inbound remote desktop
connections to Windows VMs from the internet. To learn more about types of VM network communications, see
Filter network traffic.
NOTE
Azure services cost money. Azure Cost Management helps you set budgets and configure alerts to keep spending under
control. Analyze, manage, and optimize your Azure costs with Cost Management. To learn more, see the quickstart on
analyzing your costs.
Quickstart: Create a virtual network using PowerShell
11/2/2020 • 5 minutes to read • Edit Online
A virtual network lets Azure resources, like virtual machines (VMs), communicate privately with each other, and
with the internet. In this quickstart, you learn how to create a virtual network. After creating a virtual network, you
deploy two VMs into the virtual network. You then connect to the VMs from the internet, and communicate
privately over the virtual network.
Prerequisites
If you don't have an Azure subscription, create a free account now.
O P T IO N EXA M P L E/ L IN K
Select the Cloud Shell button on the menu bar at the upper
right in the Azure portal.
$virtualNetwork = New-AzVirtualNetwork `
-ResourceGroupName myResourceGroup `
-Location EastUS `
-Name myVirtualNetwork `
-AddressPrefix 10.0.0.0/16
Add a subnet
Azure deploys resources to a subnet within a virtual network, so you need to create a subnet. Create a subnet
configuration named default with Add-AzVirtualNetworkSubnetConfig:
$subnetConfig = Add-AzVirtualNetworkSubnetConfig `
-Name default `
-AddressPrefix 10.0.0.0/24 `
-VirtualNetwork $virtualNetwork
$virtualNetwork | Set-AzVirtualNetwork
New-AzVm `
-ResourceGroupName "myResourceGroup" `
-Location "East US" `
-VirtualNetworkName "myVirtualNetwork" `
-SubnetName "default" `
-Name "myVm1" `
-AsJob
The -AsJob option creates the VM in the background. You can continue to the next step.
When Azure starts creating the VM in the background, you'll get something like this back:
Id Name PSJobTypeName State HasMoreData Location Command
-- ---- ------------- ----- ----------- -------- -------
1 Long Running... AzureLongRun... Running True localhost New-AzVM
New-AzVm `
-ResourceGroupName "myResourceGroup" `
-VirtualNetworkName "myVirtualNetwork" `
-SubnetName "default" `
-Name "myVm2"
You'll have to create another user and password. Azure takes a few minutes to create the VM.
IMPORTANT
Don't continue with the next step until Azure's finished. You'll know it's done when it returns output to PowerShell.
Get-AzPublicIpAddress `
-Name myVm1 `
-ResourceGroupName myResourceGroup `
| Select IpAddress
Open a command prompt on your local computer. Run the mstsc command. Replace <publicIpAddress> with the
public IP address returned from the last step:
NOTE
If you've been running these commands from a PowerShell prompt on your local computer, and you're using the Az
PowerShell module version 1.0 or later, you can continue in that interface.
mstsc /v:<publicIpAddress>
NOTE
You may need to select More choices > Use a different account , to specify the credentials you entered when
you created the VM.
3. Select OK .
4. You may receive a certificate warning. If you do, select Yes or Continue .
Communicate between VMs
1. In the Remote Desktop of myVm1, open PowerShell.
2. Enter ping myVm2 .
You'll get something like this back:
Pinging myVm2.ovvzzdcazhbu5iczfvonhg2zrb.bx.internal.cloudapp.net
Request timed out.
Request timed out.
Request timed out.
Request timed out.
The ping fails, because it uses the Internet Control Message Protocol (ICMP). By default, ICMP isn't allowed
through your Windows firewall.
3. To allow myVm2 to ping myVm1 in a later step, enter this command:
C:\windows\system32>ping myVm1
You receive replies from myVm1, because you allowed ICMP through the Windows firewall on the myVm1
VM in a previous step.
7. Close the remote desktop connection to myVm2.
Clean up resources
When you're done with the virtual network and the VMs, use Remove-AzResourceGroup to remove the resource
group and all the resources it has:
Remove-AzResourceGroup -Name myResourceGroup -Force
Next steps
In this quickstart, you created a default virtual network and two VMs. You connected to one VM from the internet
and communicated privately between the two VMs. Azure lets unrestricted private communication between VMs.
By default, Azure only lets inbound remote desktop connections to Windows VMs from the internet. Advance to the
next article to learn more about configuring different types of VM network communications:
Filter network traffic
Quickstart: Create a virtual network using the Azure
CLI
11/2/2020 • 3 minutes to read • Edit Online
A virtual network enables Azure resources, like virtual machines (VMs), to communicate privately with each other,
and with the internet. In this quickstart, you learn how to create a virtual network. After creating a virtual network,
you deploy two VMs into the virtual network. You then connect to the VMs from the internet, and communicate
privately over the new virtual network.
Prerequisites
If you don't have an Azure subscription, create a free account now.
O P T IO N EXA M P L E/ L IN K
Select the Cloud Shell button on the menu bar at the upper
right in the Azure portal.
Create a virtual network with az network vnet create. This example creates a default virtual network named
myVirtualNetwork with one subnet named default:
az vm create \
--resource-group myResourceGroup \
--name myVm1 \
--image UbuntuLTS \
--generate-ssh-keys \
--no-wait
az vm create \
--resource-group myResourceGroup \
--name myVm2 \
--image UbuntuLTS \
--generate-ssh-keys
{
"fqdns": "",
"id": "/subscriptions/00000000-0000-0000-0000-
000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVm2",
"location": "eastus",
"macAddress": "00-0D-3A-23-9A-49",
"powerState": "VM running",
"privateIpAddress": "10.0.0.5",
"publicIpAddress": "40.68.254.142",
"resourceGroup": "myResourceGroup"
"zones": ""
}
Take note of the publicIpAddress . You will use this address to connect to the VM from the internet in the next
step.
ssh <publicIpAddress>
ping myVm1 -c 4
Clean up resources
When no longer needed, you can use az group delete to remove the resource group and all the resources it has:
Next steps
In this quickstart, you created a default virtual network and two VMs. You connected to one VM from the internet
and communicated privately between the two VMs. Azure lets unrestricted private communication between VMs.
By default, Azure only lets inbound remote desktop connections to Windows VMs from the internet. Advance to the
next article to learn more about configuring different types of VM network communications:
Filter network traffic
Quickstart: Create a virtual network - Resource
Manager template
11/2/2020 • 2 minutes to read • Edit Online
In this quickstart, you learn how to create a virtual network with two subnets using the Azure Resource Manager
template. A virtual network is the fundamental building block for your private network in Azure. It enables Azure
resources, like VMs, to securely communicate with each other and with the internet.
An ARM template is a JavaScript Object Notation (JSON) file that defines the infrastructure and configuration for
your project. The template uses declarative syntax. In declarative syntax, you describe your intended deployment
without writing the sequence of programming commands to create the deployment.
You can also complete this quickstart using the Azure portal, Azure PowerShell, or Azure CLI.
Prerequisites
If you don't have an Azure subscription, create a free account before you begin.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vnetName": {
"type": "string",
"defaultValue": "VNet1",
"metadata": {
"description": "VNet name"
}
},
"vnetAddressPrefix": {
"type": "string",
"defaultValue": "10.0.0.0/16",
"metadata": {
"description": "Address prefix"
}
},
"subnet1Prefix": {
"type": "string",
"defaultValue": "10.0.0.0/24",
"metadata": {
"description": "Subnet 1 Prefix"
}
},
"subnet1Name": {
"type": "string",
"defaultValue": "Subnet1",
"metadata": {
"description": "Subnet 1 Name"
}
},
"subnet2Prefix": {
"type": "string",
"defaultValue": "10.0.1.0/24",
"metadata": {
"metadata": {
"description": "Subnet 2 Prefix"
}
},
"subnet2Name": {
"type": "string",
"defaultValue": "Subnet2",
"metadata": {
"description": "Subnet 2 Name"
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for all resources."
}
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2020-05-01",
"name": "[parameters('vnetName')]",
"location": "[parameters('location')]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"[parameters('vnetAddressPrefix')]"
]
}
},
"resources": [
{
"type": "subnets",
"apiVersion": "2020-05-01",
"location": "[parameters('location')]",
"name": "[parameters('subnet1Name')]",
"dependsOn": [
"[parameters('vnetName')]"
],
"properties": {
"addressPrefix": "[parameters('subnet1Prefix')]"
}
},
{
"type": "subnets",
"apiVersion": "2020-05-01",
"location": "[parameters('location')]",
"name": "[parameters('subnet2Name')]",
"dependsOn": [
"[parameters('vnetName')]",
"[parameters('subnet1Name')]"
],
"properties": {
"addressPrefix": "[parameters('subnet2Prefix')]"
}
}
]
}
2. In the portal, on the Create a Vir tual Network with two Subnets page, type or select the following
values:
Resource group : Select Create new , type a name for the resource group, and select OK .
Vir tual Network Name : Type a name for the new virtual network.
3. Select Review + create , and then select Create .
Clean up resources
When you no longer need the resources that you created with the virtual network, delete the resource group. This
removes the virtual network and all the related resources.
To delete the resource group, call the Remove-AzResourceGroup cmdlet:
Next steps
In this quickstart, you deployed an Azure virtual network with two subnets. To learn more about Azure virtual
networks, continue to the tutorial for virtual networks.
Filter network traffic
Tutorial: Filter network traffic with a network security
group using the Azure portal
12/20/2019 • 7 minutes to read • Edit Online
You can filter network traffic inbound to and outbound from a virtual network subnet with a network security
group. Network security groups contain security rules that filter network traffic by IP address, port, and protocol.
Security rules are applied to resources deployed in a subnet. In this tutorial, you learn how to:
Create a network security group and security rules
Create a virtual network and associate a network security group to a subnet
Deploy virtual machines (VM) into a subnet
Test traffic filters
If you prefer, you can complete this tutorial using the Azure CLI or PowerShell.
If you don't have an Azure subscription, create a free account before you begin.
Sign in to Azure
Sign in to the Azure portal at https://portal.azure.com.
SET T IN G VA L UE
Name myVirtualNetwork
SET T IN G VA L UE
Name myAsgWebServers
Location East US
SET T IN G VA L UE
Name myAsgMgmtServers
Location East US
SET T IN G VA L UE
Name myNsg
Location East US
2. Create a security rule that allows ports 80 and 443 to the myAsgWebSer vers application security group.
Under Add inbound security rule , enter, or select the following values, accept the remaining defaults, and
then select Add :
SET T IN G VA L UE
Name Allow-Web-All
SET T IN G VA L UE
Name Allow-RDP-All
In this tutorial, RDP (port 3389) is exposed to the internet for the VM that is assigned to the
myAsgMgmtServers application security group. For production environments, instead of exposing port 3389
to the internet, it's recommended that you connect to Azure resources that you want to manage using a VPN
or private network connection.
Once you've completed steps 1-3, review the rules you created. Your list should look like the list in the following
picture:
SET T IN G VA L UE
Name myVmWeb
SET T IN G VA L UE
6. Select Review + Create at the bottom, left corner, select Create to start VM deployment.
Create the second VM
Complete steps 1-6 again, but in step 3, name the VM myVmMgmt. The VM takes a few minutes to deploy. Do not
continue to the next step until the VM is deployed.
3. Complete steps 1 and 2 again, searching for the myVmMgmt VM and selecting the myAsgMgmtSer vers
ASG.
Test traffic filters
1. Connect to the myVmMgmt VM. Enter myVmMgmt in the search box at the top of the portal. When
myVmMgmt appears in the search results, select it. Select the Connect button.
2. Select Download RDP file .
3. Open the downloaded rdp file and select Connect . Enter the user name and password you specified when
creating the VM. You may need to select More choices , then Use a different account , to specify the
credentials you entered when you created the VM.
4. Select OK .
5. You may receive a certificate warning during the sign-in process. If you receive the warning, select Yes or
Continue , to proceed with the connection.
The connection succeeds, because port 3389 is allowed inbound from the internet to the
myAsgMgmtServers application security group that the network interface attached to the myVmMgmt VM is
in.
6. Connect to the myVmWeb VM from the myVmMgmt VM by entering the following command in a
PowerShell session:
mstsc /v:myVmWeb
You are able to connect to the myVmWeb VM from the myVmMgmt VM because VMs in the same virtual
network can communicate with each other over any port, by default. You can't however, create a remote
desktop connection to the myVmWeb VM from the internet, because the security rule for the
myAsgWebServers doesn't allow port 3389 inbound from the internet and inbound traffic from the Internet
is denied to all resources, by default.
7. To install Microsoft IIS on the myVmWeb VM, enter the following command from a PowerShell session on
the myVmWeb VM:
8. After the IIS installation is complete, disconnect from the myVmWeb VM, which leaves you in the
myVmMgmt VM remote desktop connection.
9. Disconnect from the myVmMgmt VM.
10. In the Search resources, services, and docs box at the top of the Azure portal, begin typing myVmWeb from
your computer. When myVmWeb appears in the search results, select it. Note the Public IP address for
your VM. The address shown in the following picture is 137.135.84.74, but your address is different:
11. To confirm that you can access the myVmWeb web server from the internet, open an internet browser on
your computer and browse to http://<public-ip-address-from-previous-step> . You see the IIS welcome
screen, because port 80 is allowed inbound from the internet to the myAsgWebServers application security
group that the network interface attached to the myVmWeb VM is in.
Clean up resources
When no longer needed, delete the resource group and all of the resources it contains:
1. Enter myResourceGroup in the Search box at the top of the portal. When you see myResourceGroup in the
search results, select it.
2. Select Delete resource group .
3. Enter myResourceGroup for TYPE THE RESOURCE GROUP NAME: and select Delete .
Next steps
In this tutorial, you created a network security group and associated it to a virtual network subnet. To learn more
about network security groups, see Network security group overview and Manage a network security group.
Azure routes traffic between subnets by default. You may instead, choose to route traffic between subnets through a
VM, serving as a firewall, for example. To learn how to create a route table, advance to the next tutorial.
Create a route table
Tutorial: Route network traffic with a route table using
the Azure portal
11/2/2020 • 9 minutes to read • Edit Online
Azure routes traffic between all subnets within a virtual network, by default. You can create your own routes to
override Azure's default routing. Custom routes are helpful when, for example, you want to route traffic between
subnets through a network virtual appliance (NVA). In this tutorial, you learn how to:
Create an NVA that routes traffic
Create a route table
Create a route
Associate a route table to a subnet
Deploy virtual machines (VM) into different subnets
Route traffic from one subnet to another through an NVA
This tutorial uses the Azure portal. You can also use Azure CLI or Azure PowerShell.
If you don't have an Azure subscription, create a free account before you begin.
Create an NVA
Network virtual appliances (NVAs) are virtual machines that help with network functions, such as routing and
firewall optimization. This tutorial assumes you're using Windows Ser ver 2016 Datacenter . You can select a
different operating system if you want.
1. On the Azure portal menu or from the Home page, select Create a resource .
2. Choose Security > Windows Ser ver 2016 Datacenter .
3. In the Create a vir tual machine page, under Basics , enter or select this information:
SEC T IO N SET T IN G A C T IO N
SUB N ET N A M E A DDRESS RA N GE
Public 10.0.0.0/24
Private 10.0.1.0/24
DMZ 10.0.2.0/24
SET T IN G VA L UE
Name mynvastorageaccount
Performance Standard
SET T IN G VA L UE
Name myRouteTablePublic
5. Select Create .
Create a route
1. Go to the Azure portal to manage your route table. Search for and select Route tables .
2. Pick the name of your route table (myRouteTablePublic ).
3. Choose Routes > Add .
4. In Add route , enter or select this information:
SET T IN G VA L UE
Next hop address 10.0.2.4 (an address within the address range of the DMZ
subnet)
5. Select OK .
Turn on IP forwarding
Next, turn on IP forwarding for your new NVA virtual machine, myVmNva. When Azure sends network traffic to
myVmNva, if the traffic is destined for a different IP address, IP forwarding sends the traffic to the correct location.
1. Go to the Azure portal to manage your VM. Search for and select Vir tual machines .
2. Pick the name of your VM (myVmNva ).
3. In your NVA virtual machine's menu bar, select Networking .
4. Select myvmnva123 . That's the network interface Azure created for your VM. Azure adds numbers to
ensure a unique name.
5. In the network interface menu bar, select IP configurations .
6. In the IP configurations page, set IP for warding to Enabled , and select Save .
Create public and private virtual machines
Create a public VM and a private VM in the virtual network. Later, you'll use them to see that Azure routes the Public
subnet traffic to the Private subnet through the NVA.
To create the public VM and the private VM, follow the steps of Create an NVA earlier. You don't need to wait for
deployment to finish or go to the VM resource. You'll use most of the same settings, except as described below.
Before you select Create to create the public or private VM, go to the following two subsections (Public VM and
Private VM), which show the values that have to be different. You may continue to the next section (Route traffic
through an NVA) after Azure finishes deploying both VMs.
Public VM
TA B SET T IN G VA L UE
Private VM
TA B SET T IN G VA L UE
You'll be using trace route to test routing in this tutorial. For production environments, we don't recommend
allowing ICMP through the Windows Firewall.
Turn on IP forwarding within myVmNva
You turned on IP forwarding for the VM's network interface using Azure. The VM's operating system also has to
forward network traffic. Turn on IP forwarding for myVmNva VM's operating system with these commands.
1. From a command prompt on the myVmPrivate VM, open a remote desktop to the myVmNva VM:
mstsc /v:myvmnva
2. From PowerShell on the myVmNva VM, enter this command to turn on IP forwarding:
3. Restart the myVmNva VM: From the taskbar, select Star t > Power , Other (Planned) > Continue .
This also disconnects the remote desktop session.
4. After the myVmNva VM restarts, create a remote desktop session to the myVmPublic VM. While still
connected to the myVmPrivate VM, open a command prompt and run this command:
mstsc /v:myVmPublic
tracert myVmPrivate
1 <1 ms * 1 ms 10.0.2.4
2 1 ms 1 ms 1 ms 10.0.1.4
Trace complete.
You can see the first hop is to 10.0.2.4, which is NVA's private IP address. The second hop is to the private IP
address of the myVmPrivate VM: 10.0.1.4. Earlier, you added the route to the myRouteTablePublic route table
and associated it to the Public subnet. As a result, Azure sent the traffic through the NVA and not directly to
the Private subnet.
2. Close the remote desktop session to the myVmPublic VM, which leaves you still connected to the
myVmPrivate VM.
3. From a command prompt on the myVmPrivate VM, enter this command:
tracert myVmPublic
This command tests the routing of network traffic from the myVmPrivate VM to the myVmPublic VM. The
response is similar to this example:
1 1 ms 1 ms 1 ms 10.0.0.4
Trace complete.
You can see that Azure routes traffic directly from the myVmPrivate VM to the myVmPublic VM. By default,
Azure routes traffic directly between subnets.
4. Close the remote desktop session to the myVmPrivate VM.
Clean up resources
When the resource group is no longer needed, delete myResourceGroup and all resources it has:
1. Go to the Azure portal to manage your resource group. Search for and select Resource groups .
2. Pick the name of your resource group (myResourceGroup ).
3. Select Delete resource group .
4. In the confirmation dialog box, enter myResourceGroup for TYPE THE RESOURCE GROUP NAME , and
then select Delete . Azure deletes the myResourceGroup and all resources tied to that resource group,
including your route tables, storage accounts, virtual networks, VMs, network interfaces, and public IP
addresses.
Next steps
In this tutorial, you created a route table and associated it to a subnet. You created a simple NVA that routed traffic
from a public subnet to a private subnet. Now you can deploy different preconfigured NVAs from the Azure
Marketplace, which provide many useful network functions. To learn more about routing, see Routing overview and
Manage a route table.
While you can deploy many Azure resources within a virtual network, Azure can't deploy resources for some PaaS
services into a virtual network. It's possible to restrict access to the resources of some Azure PaaS services, though
the restriction must only be traffic from a virtual network subnet. To learn how to restrict network access to Azure
PaaS resources, see the next tutorial.
Restrict network access to PaaS resources
NOTE
Azure services cost money. Azure Cost Management helps you set budgets and configure alerts to keep spending under
control. Analyze, manage, and optimize your Azure costs with Cost Management. To learn more, see the quickstart on
analyzing your costs.
Tutorial: Restrict network access to PaaS resources
with virtual network service endpoints using the
Azure portal
11/2/2020 • 9 minutes to read • Edit Online
Virtual network service endpoints enable you to limit network access to some Azure service resources to a virtual
network subnet. You can also remove internet access to the resources. Service endpoints provide direct connection
from your virtual network to supported Azure services, allowing you to use your virtual network's private address
space to access the Azure services. Traffic destined to Azure resources through service endpoints always stays on
the Microsoft Azure backbone network. In this tutorial, you learn how to:
Create a virtual network with one subnet
Add a subnet and enable a service endpoint
Create an Azure resource and allow network access to it from only a subnet
Deploy a virtual machine (VM) to each subnet
Confirm access to a resource from a subnet
Confirm access is denied to a resource from a subnet and the internet
If you prefer, you can complete this tutorial using the Azure CLI or Azure PowerShell.
If you don't have an Azure subscription, create a free account before you begin.
Log in to Azure
Log in to the Azure portal at https://portal.azure.com.
SET T IN G VA L UE
Name myVirtualNetwork
Firewall Disabled
SET T IN G VA L UE
Name Private
Cau t i on
Before enabling a service endpoint for an existing subnet that has resources in it, see Change subnet settings.
SET T IN G VA L UE
Name myNsgPrivate
SET T IN G VA L UE
Protocol Any
Action Allow
Priority 100
Name Allow-Storage-All
8. Create another outbound security rule that denies communication to the internet. This rule overrides a
default rule in all network security groups that allows outbound internet communication. Complete steps 5-7
again, using the following values:
SET T IN G VA L UE
Protocol Any
Action Deny
Priority 110
Name Deny-Internet-All
9. Under SETTINGS , select Inbound security rules .
10. Select + Add .
11. Create an inbound security rule that allows Remote Desktop Protocol (RDP) traffic to the subnet from
anywhere. The rule overrides a default security rule that denies all inbound traffic from the internet. Remote
desktop connections are allowed to the subnet so that connectivity can be tested in a later step. Under
SETTINGS , select Inbound security rules , select +Add , enter the following values, and then select Add :
SET T IN G VA L UE
Source Any
Protocol Any
Action Allow
Priority 120
Name Allow-RDP-All
SET T IN G VA L UE
SET T IN G VA L UE
5. Select Save .
6. Close the Firewalls and vir tual networks box.
7. Under SETTINGS for the storage account, select Access keys , as shown in the following picture:
8. Note the Key value, as you'll have to manually enter it in a later step when mapping the file share to a drive
letter in a VM.
SET T IN G VA L UE
Name myVmPublic
4. Select a size for the virtual machine and then select Select .
5. Under Settings , select Network and then select myVir tualNetwork . Then select Subnet , and select
Public , as shown in the following picture:
6. Under Network Security Group , select Advanced . The portal automatically creates a network security
group for you that allows port 3389, which you'll need open to connect to the virtual machine in a later step.
Select OK on the Settings page.
7. On the Summar y page, select Create to start the virtual machine deployment. The VM takes a few minutes
to deploy, but you can continue to the next step while the VM is creating.
Create the second virtual machine
Complete steps 1-7 again, but in step 3, name the virtual machine myVmPrivate and in step 5, select the Private
subnet.
The VM takes a few minutes to deploy. Do not continue to the next step until it finishes creating and its settings
open in the portal.
2. After selecting the Connect button, a Remote Desktop Protocol (.rdp) file is created and downloaded to your
computer.
3. Open the downloaded rdp file. If prompted, select Connect . Enter the user name and password you specified
when creating the VM. You may need to select More choices , then Use a different account , to specify the
credentials you entered when you created the VM.
4. Select OK .
5. You may receive a certificate warning during the sign-in process. If you receive the warning, select Yes or
Continue , to proceed with the connection.
6. On the myVmPrivate VM, map the Azure file share to drive Z using PowerShell. Before running the
commands that follow, replace <storage-account-key> and <storage-account-name> with values you supplied
and retrieved in Create a storage account.
ping bing.com
You receive no replies, because the network security group associated to the Private subnet does not allow
outbound access to the internet.
8. Close the remote desktop session to the myVmPrivate VM.
Access is denied, because your computer is not in the Private subnet of the MyVirtualNetwork virtual
network.
Clean up resources
When no longer needed, delete the resource group and all resources it contains:
1. Enter myResourceGroup in the Search box at the top of the portal. When you see myResourceGroup in the
search results, select it.
2. Select Delete resource group .
3. Enter myResourceGroup for TYPE THE RESOURCE GROUP NAME: and select Delete .
Next steps
In this tutorial, you enabled a service endpoint for a virtual network subnet. You learned that you can enable service
endpoints for resources deployed from multiple Azure services. You created an Azure Storage account and
restricted network access to the storage account to only resources within a virtual network subnet. To learn more
about service endpoints, see Service endpoints overview and Manage subnets.
If you have multiple virtual networks in your account, you may want to connect two virtual networks together so
the resources within each virtual network can communicate with each other. To learn how to connect virtual
networks, advance to the next tutorial.
Connect virtual networks
Tutorial: Connect virtual networks with virtual
network peering using the Azure portal
2/13/2020 • 5 minutes to read • Edit Online
You can connect virtual networks to each other with virtual network peering. These virtual networks can be in the
same region or different regions (also known as Global VNet peering). Once virtual networks are peered,
resources in both virtual networks are able to communicate with each other, with the same latency and bandwidth
as if the resources were in the same virtual network. In this tutorial, you learn how to:
Create two virtual networks
Connect two virtual networks with a virtual network peering
Deploy a virtual machine (VM) into each virtual network
Communicate between VMs
If you prefer, you can complete this tutorial using the Azure CLI or Azure PowerShell.
If you don't have an Azure subscription, create a free account before you begin.
Log in to Azure
Log in to the Azure portal at https://portal.azure.com.
SET T IN G VA L UE
Name myVirtualNetwork1
4. On the IP Addresses tab, enter 10.0.0.0/16 for the Address Space field. Click the Add subnet button
below and enter Subnet1 for Subnet Name and 10.0.0.0/24 for Subnet Address range .
5. Select Review + Create and then select Create .
6. Complete steps 1-5 again, with the following changes:
SET T IN G VA L UE
Name myVirtualNetwork2
SET T IN G VA L UE
3. Enter, or select, the following information, accept the defaults for the remaining settings, and then select
OK .
SET T IN G VA L UE
Name of the peering from myVirtualNetwork1 to remote myVirtualNetwork1-myVirtualNetwork2 - When the page
virtual network first loads, you'll see the phrase "remote virtual network"
here. After you choose the remote virtual network, the
phrase "remote virtual network" will be replaced with the
name of the remote virtual network.
SET T IN G VA L UE
Name myVm1
SET T IN G VA L UE
6. Select Networking . Choose Allow selected por ts for the Public inbound por ts option. Choose RDP
for the Select inbound por ts option below this.
7. Select the Review + Create button in the lower, left-hand corner to start the VM deployment.
Create the second VM
Complete steps 1-6 again, with the following changes:
SET T IN G VA L UE
Name myVm2
The VMs take a few minutes to create. Do not continue with the remaining steps until both VMs are created.
3. To connect to the VM, open the downloaded RDP file. If prompted, select Connect .
4. Enter the user name and password you specified when creating the VM (you may need to select More
choices , then Use a different account , to specify the credentials you entered when you created the VM),
then select OK .
5. You may receive a certificate warning during the sign-in process. Select Yes to proceed with the connection.
6. In a later step, ping is used to communicate with the myVm2 VM from the myVm1 VM. Ping uses the
Internet Control Message Protocol (ICMP), which is denied through the Windows Firewall, by default. On
the myVm1 VM, enable ICMP through the Windows firewall, so that you can ping this VM from myVm2 in a
later step, using PowerShell:
Though ping is used to communicate between VMs in this tutorial, allowing ICMP through the Windows
Firewall for production deployments is not recommended.
7. To connect to the myVm2 VM, enter the following command from a command prompt on the myVm1 VM:
mstsc /v:10.1.0.4
8. Since you enabled ping on myVm1, you can now ping it by IP address:
ping 10.0.0.4
Clean up resources
When no longer needed, delete the resource group and all resources it contains:
1. Enter myResourceGroup in the Search box at the top of the portal. When you see myResourceGroup in the
search results, select it.
2. Select Delete resource group .
3. Enter myResourceGroup for TYPE THE RESOURCE GROUP NAME: and select Delete .
Next steps
In this tutorial, you learned how to connect two networks in the same Azure region, with virtual network peering.
You can also peer virtual networks in different supported regions and in different Azure subscriptions, as well as
create hub and spoke network designs with peering. To learn more about virtual network peering, see Virtual
network peering overview and Manage virtual network peerings.
To connect your own computer to a virtual network through a VPN, and interact with resources in a virtual
network, or in peered virtual networks, see Connect your computer to a virtual network.
Tutorial: Create a NAT gateway using the Azure
portal
11/2/2020 • 5 minutes to read • Edit Online
This tutorial shows you how to use Azure Virtual Network NAT service. You'll create a NAT gateway to provide
outbound connectivity for a virtual machine in Azure.
If you prefer, you can do these steps using the Azure CLI, Azure PowerShell, or deploy a ARM Template instead of
the portal.
Sign in to Azure
Sign in to the Azure portal.
PA RA M ET ER VA L UE
<resource-group-name> myResourceGroupNAT
<region-name> East US 2
<IPv4-address-space> 192.168.0.0\16
<subnet-name> mySubnet
<subnet-address-range> 192.168.0.0\24
SET T IN G VA L UE
Project Details
Instance details
3. Select the IP Addresses tab or select the Next: IP Addresses button at the bottom of the page.
4. In the IP Addresses tab, enter this information:
SET T IN G VA L UE
SET T IN G VA L UE
7. Select Save .
8. Select the Review + create tab or select the Review + create button.
9. Select Create .
SET T IN G VA L UE
IMPORTANT
Copy the public IP address, and then paste it into a notepad so you can use it to access the VM.
Sign in to VM
Open an Azure Cloud Shell in your browser. Use the IP address retrieved in the previous step to SSH to the virtual
machine.
ssh <username>@<ip-address-destination>
Clean up resources
When no longer needed, delete the resource group, NAT gateway, and all related resources. Select the resource
group myResourceGroupNAT that contains the NAT gateway, and then select Delete .
Next steps
In this tutorial, you created a NAT gateway and a VM to use it.
Review metrics in Azure Monitor to see your NAT service operating. Diagnose issues such as resource exhaustion
of available SNAT ports. Resource exhaustion of SNAT ports is addressed by adding additional public IP address
resources or public IP prefix resources or both.
Learn about Azure Virtual Network NAT
Learn about NAT gateway resource.
Quickstart for deploying NAT gateway resource using Azure CLI.
Quickstart for deploying NAT gateway resource using Azure PowerShell.
Quickstart for deploying NAT gateway resource using Azure portal.
Tutorial: Create a NAT Gateway using the Azure
portal and test the NAT service
11/2/2020 • 11 minutes to read • Edit Online
In this tutorial, you'll create a NAT gateway to provide outbound connectivity for virtual machines in Azure. To test
the NAT gateway, you deploy a source and destination virtual machine. You'll test the NAT gateway by making
outbound connections to a public IP address from the source to the destination virtual machine. This tutorial
deploys source and destination in two different virtual networks in the same resource group for simplicity only.
If you prefer, you can do these steps using the Azure CLI or Azure PowerShell instead of the portal.
Sign in to Azure
Sign in to the Azure portal.
PA RA M ET ER VA L UE
<resource-group-name> myResourceGroupNAT
<region-name> East US 2
<IPv4-address-space> 192.168.0.0/16
<subnet-name> mySubnetsource
<subnet-address-range> 192.168.0.0/24
Project Details
Instance details
3. Select the IP Addresses tab or select the Next: IP Addresses button at the bottom of the page.
4. In the IP Addresses tab, enter this information:
SET T IN G VA L UE
SET T IN G VA L UE
7. Select Save .
8. Select the Review + create tab or select the Review + create button.
9. Select Create .
SET T IN G VA L UE
PA RA M ET ER VA L UE
<resource-group-name> myResourceGroupNAT
<region-name> East US 2
<IPv4-address-space> 10.1.0.0/16
<subnet-name> mySubnetdestination
<subnet-address-range> 10.1.0.0/24
SET T IN G VA L UE
Project Details
Instance details
3. Select the IP Addresses tab or select the Next: IP Addresses button at the bottom of the page.
4. In the IP Addresses tab, enter this information:
SET T IN G VA L UE
7. Select Save .
8. Select the Review + create tab or select the Review + create button.
9. Select Create .
Sign in to destination VM
Open an Azure Cloud Shell in your browser. Use the IP address retrieved in the previous step to SSH to the virtual
machine.
ssh <username>@<ip-address-destination>
Copy and paste the following commands once you've logged in.
These commands will update your virtual machine, install nginx, and create a 100-KBytes file. This file will be
retrieved from the source VM using the NAT service.
Close the SSH session with the destination VM.
IMPORTANT
Copy the public IP address, and then paste it into a notepad so you can use it in subsequent steps. Indicate this is the source
virtual machine.
ssh <username>@<ip-address-source>
Copy and paste the following commands to prepare for testing the NAT service.
sudo apt-get -y update && \
sudo apt-get -y upgrade && \
sudo apt-get -y dist-upgrade && \
sudo apt-get -y autoremove && \
sudo apt-get -y autoclean && \
sudo apt-get install -y nload golang && \
echo 'export GOPATH=${HOME}/go' >> .bashrc && \
echo 'export PATH=${PATH}:${GOPATH}/bin' >> .bashrc && \
. ~/.bashrc &&
go get -u github.com/rakyll/hey
This command will update your virtual machine, install go, install hey from GitHub, and update your shell
environment.
You're now ready to test the NAT service.
You can also generate a series of requests using hey . Again, replace <ip-address-destination> with the
destination IP address you have previously copied.
This command will generate 100 requests, 10 concurrently, with a timeout of 30 seconds, and without reusing the
TCP connection. Each request will retrieve 100 Kbytes. At the end of the run, hey will report some statistics about
how well the NAT service did.
Clean up resources
When no longer needed, delete the resource group, NAT gateway, and all related resources. Select the resource
group myResourceGroupNAT that contains the NAT gateway, and then select Delete .
Next steps
In this tutorial, you created a NAT gateway, created a source and destination VM, and then tested the NAT gateway.
Review metrics in Azure Monitor to see your NAT service operating. Diagnose issues such as resource exhaustion
of available SNAT ports. Resource exhaustion of SNAT ports is easily addressed by adding additional public IP
address resources or public IP prefix resources or both.
Learn about Virtual Network NAT
Learn about NAT gateway resource.
Quickstart for deploying NAT gateway resource using Azure CLI.
Quickstart for deploying NAT gateway resource using Azure PowerShell.
Quickstart for deploying NAT gateway resource using Azure portal.
Azure CLI samples for virtual network
11/2/2020 • 2 minutes to read • Edit Online
The following table includes links to bash scripts with Azure CLI commands:
Create a virtual network for multi-tier applications Creates a virtual network with front-end and back-end
subnets. Traffic to the front-end subnet is limited to HTTP and
SSH, while traffic to the back-end subnet is limited to MySQL,
port 3306.
Peer two virtual networks Creates and connects two virtual networks in the same
region.
Route traffic through a network virtual appliance Creates a virtual network with front-end and back-end
subnets and a VM that is able to route traffic between the
two subnets.
Filter inbound and outbound VM network traffic Creates a virtual network with front-end and back-end
subnets. Inbound network traffic to the front-end subnet is
limited to HTTP, HTTPS, and SSH. Outbound traffic to the
internet from the back-end subnet is not permitted.
Configure IPv4 + IPv6 dual stack virtual network with Basic Deploys dual-stack (IPv4+IPv6) virtual network with two VMs
Load Balancer and an Azure Basic Load Balancer with IPv4 and IPv6 public IP
addresses.
Configure IPv4 + IPv6 dual stack virtual network with Deploys dual-stack (IPv4+IPv6) virtual network with two VMs
Standard Load Balancer and an Azure Standard Load Balancer with IPv4 and IPv6
public IP addresses.
Tutorial: Create and test a NAT gateway - Azure CLI Create and validate a NAT gateway using a source and
destination virtual machine.
Azure PowerShell samples for virtual network
11/2/2020 • 2 minutes to read • Edit Online
Create a virtual network for multi-tier applications Creates a virtual network with front-end and back-end
subnets. Traffic to the front-end subnet is limited to HTTP,
while traffic to the back-end subnet is limited to SQL, port
1433.
Peer two virtual networks Creates and connects two virtual networks in the same
region.
Route traffic through a network virtual appliance Creates a virtual network with front-end and back-end
subnets and a VM that is able to route traffic between the
two subnets.
Filter inbound and outbound VM network traffic Creates a virtual network with front-end and back-end
subnets. Inbound network traffic to the front-end subnet is
limited to HTTP and HTTPS. Outbound traffic to the internet
from the back-end subnet is not permitted.
Configure IPv4 + IPv6 dual stack virtual network with Basic Deploys dual-stack (IPv4+IPv6) virtual network with two VMs
Load Balancer and an Azure Basic Load Balancer with IPv4 and IPv6 public IP
addresses.
Configure IPv4 + IPv6 dual stack virtual network with Deploys dual-stack (IPv4+IPv6) virtual network with two VMs
Standard Load Balancer and an Azure Standard Load Balancer with IPv4 and IPv6
public IP addresses.
Azure Resource Manager template samples for
virtual network
11/2/2020 • 2 minutes to read • Edit Online
The following table includes links to Azure Resource Manager template samples. You can deploy templates using
the Azure portal, Azure CLI, or Azure PowerShell. To learn how to author your own templates, see Create your first
template and Understand the structure and syntax of Azure Resource Manager templates.
For the JSON syntax and properties to use in templates, see Microsoft.Network resource types.
TA SK DESC RIP T IO N
Create a virtual network with two subnets Creates a virtual network with two subnets.
Route traffic through a network virtual appliance Creates a virtual network with three subnets. Deploys a
virtual machine into each of the subnets. Creates a route
table containing routes to direct traffic from one subnet to
another through the virtual machine in the third subnet.
Associates the route table to one of the subnets.
Create a virtual network service endpoint for Azure Storage Creates a new virtual network with two subnets, and a
network interface in each subnet. Enables a service endpoint
to Azure Storage for one of the subnets and secures a new
storage account to that subnet.
Connect two virtual networks Creates two virtual networks and a virtual network peering
between them.
Create a virtual machine with multiple IP addresses Creates a Windows or Linux VM with multiple IP addresses.
Configure IPv4 + IPv6 dual stack virtual network Deploys dual-stack (IPv4+IPv6) virtual network with two VMs
and an Azure Basic Load Balancer with IPv4 and IPv6 public
IP addresses.
Virtual Network – Business Continuity
7/14/2019 • 2 minutes to read • Edit Online
Overview
A Virtual Network (VNet) is a logical representation of your network in the cloud. It allows you to define your own
private IP address space and segment the network into subnets. VNets serves as a trust boundary to host your
compute resources such as Azure Virtual Machines and Cloud Services (web/worker roles). A VNet allows direct
private IP communication between the resources hosted in it. You can link a virtual network to an on-premises
network through a VPN Gateway, or ExpressRoute.
A VNet is created within the scope of a region. You can create VNets with same address space in two different
regions (For example, US East and US West), but because they have the same address space, you can't connect
them together.
Business Continuity
There could be several different ways that your application could be disrupted. A region could be completely cut off
due to a natural disaster, or a partial disaster, due to a failure of multiple devices or services. The impact on the
VNet service is different in each of these situations.
Q: If an outage occurs for an entire region, what do I do? For example, if a region is completely cut
off due to a natural disaster? What happens to the vir tual networks hosted in the region?
A: The virtual network and the resources in the affected region remains inaccessible during the time of the service
disruption.
Q: What can I to do re-create the same vir tual network in a different region?
A: Virtual networks are fairly lightweight resources. You can invoke Azure APIs to create a VNet with the same
address space in a different region. To recreate the same environment that was present in the affected region, you
make API calls to redeploy the Cloud Services web and worker roles, and the virtual machines that you had. If you
have on-premises connectivity, such as in a hybrid deployment, you have to deploy a new VPN Gateway, and
connect to your on-premises network.
To create a virtual network, see Create a virtual network.
Q: Can a replica of a VNet in a given region be re-created in another region ahead of time?
A: Yes, you can create two VNets using the same private IP address space and resources in two different regions
ahead of time. If you are hosting internet-facing services in the VNet, you could have set up Traffic Manager to geo-
route traffic to the region that is active. However, you cannot connect two VNets with the same address space to
your on-premises network, as it would cause routing issues. At the time of a disaster and loss of a VNet in one
region, you can connect the other VNet in the available region, with the matching address space to your on-
premises network.
To create a virtual network, see Create a virtual network.
What is Virtual Network NAT?
11/2/2020 • 4 minutes to read • Edit Online
Virtual Network NAT (network address translation) simplifies outbound-only Internet connectivity for virtual
networks. When configured on a subnet, all outbound connectivity uses your specified static public IP addresses.
Outbound connectivity is possible without load balancer or public IP addresses directly attached to virtual
machines. NAT is fully managed and highly resilient.
Pricing
For pricing details, see Virtual Network pricing.
Availability
Virtual Network NAT and the NAT gateway resource are available in all regions of all Azure clouds regions.
Suggestions
We want to know how we can improve the service. Propose and vote on what we should build next at UserVoice
for NAT.
Limitations
NAT is compatible with standard SKU public IP, public IP prefix, and load balancer resources. Basic resources,
such as basic load balancer, and any products derived from them aren't compatible with NAT. Basic resources
must be placed on a subnet not configured with NAT.
IPv4 address family is supported. NAT doesn't interact with IPv6 address family. NAT can't be deployed on a
subnet with an IPv6 prefix.
NAT can't span multiple virtual networks.
Next steps
Learn about NAT gateway resource.
Tell us what to build next for Virtual Network NAT in UserVoice.
Designing virtual networks with NAT gateway
resources
11/2/2020 • 16 minutes to read • Edit Online
NAT gateway resources are part of Virtual Network NAT and provide outbound Internet connectivity for one or
more subnets of a virtual network. The subnet of the virtual network states which NAT gateway will be used. NAT
provides source network address translation (SNAT) for a subnet. NAT gateway resources specify which static IP
addresses virtual machines use when creating outbound flows. Static IP addresses come from public IP address
resources (PIP), public IP prefix resources, or both. If a public IP prefix resource is used, all IP addresses of the
entire public IP prefix resource are consumed by a NAT gateway resource. A NAT gateway resource can use a total
of up to 16 static IP addresses from either.
Resource
The resource is designed to be simple as you can see from the following Azure Resource Manager example in a
template-like format. This template-like format is shown here to illustrate the concepts and structure. Modify the
example for your needs. This document isn't intended as a tutorial.
The following diagram shows the writeable references between the different Azure Resource Manager resources.
The arrow indicates the direction of the reference, originating from where it's writeable. Review
{
"type": "Microsoft.Network/natGateways",
"apiVersion": "2019-11-01",
"name": "[parameters('natgatewayname')]",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Network/publicIPAddresses', variables('publicipname'))]"
],
"sku": {
"name": "Standard"
},
"properties": {
"idleTimeoutInMinutes": 4,
"publicIpAddresses": "[if(not(empty(parameters('publicipdns'))), variables('publicIpAddresses'),
json('null'))]"
}
},
When the NAT gateway resource has been created, it can be used on one or more subnets of a virtual network.
Specify which subnets use this NAT gateway resource. A NAT gateway isn't able to span more than one virtual
network. It isn't required to assign the same NAT gateway to all subnets of a virtual network. Individual subnets
can be configured with different NAT gateway resources.
Scenarios that don't use availability zones will be regional (no zone specified). If you're using availability zones,
you can specify a zone to isolate NAT to a specific zone. Zone-redundancy isn't supported. Review NAT availability
zones.
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vnetname": {
"defaultValue": "myVnet",
"type": "String",
"metadata": {
"description": "Name of the virtual network"
}
},
"subnetname": {
"defaultValue": "mySubnet",
"type": "String",
"metadata": {
"description": "Name of the subnet for virtual network"
}
},
"vnetaddressspace": {
"defaultValue": "192.168.0.0/16",
"type": "String",
"type": "String",
"metadata": {
"description": "Address space for virtual network"
}
},
"vnetsubnetprefix": {
"defaultValue": "192.168.0.0/24",
"type": "String",
"metadata": {
"description": "Subnet prefix for virtual network"
}
},
"natgatewayname": {
"defaultValue": "myNATgateway",
"type": "String",
"metadata": {
"description": "Name of the NAT gateway resource"
}
},
"publicipdns": {
"defaultValue": "[concat('gw-', uniqueString(resourceGroup().id))]",
"type": "String",
"metadata": {
"description": "dns of the public ip address, leave blank for no dns"
}
},
"location": {
"defaultValue": "[resourceGroup().location]",
"type": "String",
"metadata": {
"description": "Location of resources"
}
}
},
"variables": {
"publicIpName": "[concat(parameters('natgatewayname'), 'ip')]",
"publicIpAddresses": [
{
"id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicipname'))]"
}
]
},
"resources": [
{
"type": "Microsoft.Network/publicIPAddresses",
"apiVersion": "2019-11-01",
"name": "[variables('publicIpName')]",
"location": "[parameters('location')]",
"sku": {
"name": "Standard"
},
"properties": {
"publicIPAddressVersion": "IPv4",
"publicIPAllocationMethod": "Static",
"idleTimeoutInMinutes": 4,
"dnsSettings": {
"domainNameLabel": "[parameters('publicipdns')]"
}
}
},
{
"type": "Microsoft.Network/natGateways",
"apiVersion": "2019-11-01",
"name": "[parameters('natgatewayname')]",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Network/publicIPAddresses', variables('publicipname'))]"
],
"sku": {
"name": "Standard"
"name": "Standard"
},
"properties": {
"idleTimeoutInMinutes": 4,
"publicIpAddresses": "[if(not(empty(parameters('publicipdns'))), variables('publicIpAddresses'),
json('null'))]"
}
},
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2019-11-01",
"name": "[parameters('vnetname')]",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Network/natGateways', parameters('natgatewayname'))]"
],
"properties": {
"addressSpace": {
"addressPrefixes": [
"[parameters('vnetaddressspace')]"
]
},
"subnets": [
{
"name": "[parameters('subnetname')]",
"properties": {
"addressPrefix": "[parameters('vnetsubnetprefix')]",
"natGateway": {
"id": "[resourceId('Microsoft.Network/natGateways', parameters('natgatewayname'))]"
},
"privateEndpointNetworkPolicies": "Enabled",
"privateLinkServiceNetworkPolicies": "Enabled"
}
}
],
"enableDdosProtection": false,
"enableVmProtection": false
}
},
{
"type": "Microsoft.Network/virtualNetworks/subnets",
"apiVersion": "2019-11-01",
"name": "[concat(parameters('vnetname'), '/mySubnet')]",
"dependsOn": [
"[resourceId('Microsoft.Network/virtualNetworks', parameters('vnetname'))]",
"[resourceId('Microsoft.Network/natGateways', parameters('natgatewayname'))]"
],
"properties": {
"addressPrefix": "[parameters('vnetsubnetprefix')]",
"natGateway": {
"id": "[resourceId('Microsoft.Network/natGateways', parameters('natgatewayname'))]"
},
"privateEndpointNetworkPolicies": "Enabled",
"privateLinkServiceNetworkPolicies": "Enabled"
}
}
]
}
NAT gateways are defined with a property on a subnet within a virtual network. Flows created by virtual
machines on subnet subnetname of virtual network vnetname will use the NAT gateway. All outbound
connectivity will use the IP addresses associated with natgatewayname as the source IP address.
For more information on the Azure Resource Manager template used in this example, see:
Quickstart: Create a NAT gateway - Resource Manager template
Virtual Network NAT
Design Guidance
Review this section to familiarize yourself with considerations for designing virtual networks with NAT.
1. Cost optimization
2. Coexistence of inbound and outbound
3. Managing Basic resources
4. Availability Zones
Cost optimization
Service endpoints and private link are options to consider for optimizing cost. NAT isn't needed for these services.
Traffic directed to service endpoints or private link is not processed by the virtual network's NAT.
Service endpoints tie Azure service resources to your virtual network and control access to your Azure service
resources. For example, when you access Azure storage, use a service endpoint for storage to avoid data
processed NAT charges. Service endpoints are free.
Private link exposes Azure PaaS service (or other services hosted with private link) as a private endpoint inside a
virtual network. Private link is billed based on duration and data processed.
Evaluate if either or both of these approaches are a good fit for your scenario and use as needed.
Coexistence of inbound and outbound
NAT gateway is compatible with:
Standard load balancer
Standard public IP
Standard public IP prefix
When developing a new deployment, start with standard SKUs.
VM will use NAT gateway for outbound. Inbound originated isn't affected.
NAT and VM with public Load Balancer
Any outbound configuration from a load-balancing rule or outbound rules is superseded by NAT gateway.
Inbound originated isn't affected.
NAT and VM with instance-level public IP and public Load Balancer
Figure: Virtual Network NAT and VM with instance-level public IP and public Load Balancer
Any outbound configuration from a load-balancing rule or outbound rules is superseded by NAT gateway. The
VM will also use NAT gateway for outbound. Inbound originated isn't affected.
Managing Basic resources
Standard load balancer, public IP, and public IP prefix are compatible with NAT gateway. NAT gateways operate in
the scope of a subnet. The basic SKU of these services must be deployed on a subnet without a NAT gateway. This
separation allows both SKU variants to coexist in the same virtual network.
NAT gateways take precedence over outbound scenarios of the subnet. Basic load balancer or public IP (and any
managed service built with them) is unable to be adjusted with the correct translations. NAT gateway takes
control over outbound to Internet traffic on a subnet. Inbound traffic to basic load balancer and public ip is
unavailable. Inbound traffic to a basic load balancer and, or a public ip configured on a VM won't be available.
Availability Zones
Zone isolation with zonal stacks
Figure: Virtual Network NAT with zone isolation, creating multiple "zonal stacks"
Even without availability zones, NAT is resilient and can survive multiple infrastructure component failures.
Availability zones build on this resiliency with zone isolation scenarios for NAT.
Virtual networks and their subnets are regional constructs. Subnets aren't restricted to a zone.
A zonal promise for zone isolation exists when a virtual machine instance using a NAT gateway resource is in the
same zone as the NAT gateway resource and its public IP addresses. The pattern you want to use for zone
isolation is creating a "zonal stack" per availability zone. This "zonal stack" consists of virtual machine instances,
NAT gateway resources, public IP address and/or prefix resources on a subnet that is assumed to be serving only
the same zone. The control plane operations and data plane are then aligned with and constrained to the
specified zone.
Failure in a zone other than where your scenario exists is expected to be without impact to NAT. Outbound traffic
from virtual machines in the same zone will fail because of zone isolation.
Integrating inbound endpoints
If your scenario requires inbound endpoints, you have two options:
O P T IO N PAT T ERN EXA M P L E P RO C ON
(1) Align the inbound Create a standard Same health model Individual IP
endpoints with the load balancer with and failure mode for addresses per zone
respective zonal zonal frontend. inbound and may need to be
stacks you're outbound. Simpler to masked by a
creating for operate. common DNS name.
outbound.
(2) Overlay the zonal Create a standard Single IP address for Varying health model
stacks with a cross- load balancer with inbound endpoint. and failure modes for
zone inbound zone-redundant inbound and
endpoint. frontend. outbound. More
complex to operate.
NOTE
A zone-isolated NAT gateway requires IP addresses to match the zone of the NAT gateway. NAT gateway resources with IP
addresses from a different zone or without a zone aren't allowed.
NOTE
The zones property of a NAT gateway resource isn't mutable. Redeploy NAT gateway resource with the intended regional or
zone preference.
NOTE
IP addresses by themselves aren't zone-redundant if no zone is specified. The frontend of a Standard Load Balancer is zone-
redundant if an IP address isn't created in a specific zone. This doesn't apply to NAT. Only regional or zone-isolation is
supported.
Performance
Each NAT gateway resource can provide up to 50 Gbps of throughput. You can split your deployments into
multiple subnets and assign each subnet or groups of subnets a NAT gateway to scale out.
Each NAT gateway can support 64,000 flows for TCP and UDP respectively per assigned outbound IP address.
Review the following section on Source Network Address Translation (SNAT) for details as well as the
troubleshooting article for specific problem resolution guidance.
Source Network Address Translation
Source network address translation (SNAT) rewrites the source of a flow to originate from a different IP address.
NAT gateway resources use a variant of SNAT commonly referred to port address translation (PAT). PAT rewrites
the source address and source port. With SNAT, there's no fixed relationship between the number of private
addresses and their translated public addresses.
Fundamentals
Let's look at an example of four flows to explain the basic concept. The NAT gateway is using public IP address
resource 65.52.1.1 and the VM is making connections to 65.52.0.1.
F LO W SO URC E T UP L E DEST IN AT IO N T UP L E
1 192.168.0.16:4283 65.52.0.1:80
2 192.168.0.16:4284 65.52.0.1:80
3 192.168.0.17.5768 65.52.0.1:80
These flows might look like this after PAT has taken place:
The destination will see the source of the flow as 65.52.0.1 (SNAT source tuple) with the assigned port shown. PAT
as shown in the preceding table is also called port masquerading SNAT. Multiple private sources are
masqueraded behind an IP and port.
source (SNAT) port reuse
NAT gateways opportunistically reuse source (SNAT) ports. The following illustrates this concept as an additional
flow for the preceeding set of flows. The VM in the example is a flow to 65.52.0.2.
F LO W SO URC E T UP L E DEST IN AT IO N T UP L E
4 192.168.0.16:4285 65.52.0.2:80
A NAT gateway will likely translate flow 4 to a port that may be used for other destinations as well. See Scaling
for additional discussion on correctly sizing your IP address provisioning.
Don't take a dependency on the specific way source ports are assigned in the above example. The preceding is an
illustration of the fundamental concept only.
SNAT provided by NAT is different from Load Balancer in several aspects.
On-demand
NAT provides on-demand SNAT ports for new outbound traffic flows. All available SNAT ports in inventory are
used by any virtual machine on subnets configured with NAT.
NOTE
If you are assigning a public IP prefix resource, the entire public IP prefix will be used. You can't assign a public IP prefix
resource and then break out individual IP addresses to assign to other resources. If you want to assign individual IP
addresses from a public IP prefix to multiple resources, you need to create individual public IP addresses from the public IP
prefix resource and assign them as needed instead of the public IP prefix resource itself.
SNAT maps private addresses to one or more public IP addresses, rewriting source address and source port in the
processes. A NAT gateway resource will use 64,000 ports (SNAT ports) per configured public IP address for this
translation. NAT gateway resources can scale up to 16 IP addresses and 1M SNAT ports. If a public IP prefix
resource is provided, each IP address within the prefix is providing SNAT port inventory. And adding more public
IP addresses increases the available inventory SNAT ports. TCP and UDP are separate SNAT port inventories and
unrelated.
NAT gateway resources opportunistically reuse source (SNAT) ports. As design guidance for scaling purposes,
you should assume each flow requires a new SNAT port and scale the total number of available IP addresses for
outbound traffic. You should carefully consider the scale you are designing for and provision IP addresses
quantities accordingly.
SNAT ports to different destinations are most likely to be reused when possible. And as SNAT port exhaustion
approaches, flows may not succeed.
See SNAT fundamentals for example.
Protocols
NAT gateway resources interact with IP and IP transport headers of UDP and TCP flows and are agnostic to
application layer payloads. Other IP protocols aren't supported.
Timers
IMPORTANT
Long idle timer can unnecessarily increase likelihood of SNAT exhaustion. The longer of a timer you specify, the longer NAT
will hold on to SNAT ports until they eventually idle timeout. If your flows are idle timed out, they will fail eventually anyway
and unnecessarily consume SNAT port inventory. Flows that fail at 2 hours would have failed at the default 4 minutes as
well. Increasing the idle timeout is a last resort option that should be used sparingly. If a flow never does go idle, it will not
be impacted by the idle timer.
TCP idle timeout can be adjusted from 4 minutes (default) to 120 minutes (2 hours) for all flows. Additionally, you
can reset the idle timer with traffic on the flow. A recommended pattern for refreshing long idle connections and
endpoint liveness detection is TCP keepalives. TCP keepalives appear as duplicate ACKs to the endpoints, are low
overhead, and invisible to the application layer.
The following timers are used for SNAT port release:
T IM ER VA L UE
A SNAT port is available for reuse to the same destination IP address and destination port after 5 seconds.
NOTE
These timer settings are subject to change. The values are provided to help troubleshooting and you shouldn't take a
dependency on specific timers at this time.
Limitations
NAT is compatible with standard SKU public IP, public IP prefix, and load balancer resources. Basic resources
(for example basic load balancer) and any products derived from them aren't compatible with NAT. Basic
resources must be placed on a subnet not configured with NAT.
IPv4 address family is supported. NAT doesn't interact with IPv6 address family. NAT can't be deployed on a
subnet with an IPv6 prefix.
NAT can't span multiple virtual networks.
Suggestions
We want to know how we can improve the service. Are missing a capability? Make your case for what we should
build next at UserVoice for NAT.
Next steps
Learn about virtual network NAT.
Learn about metrics and alerts for NAT gateway resources.
Learn about troubleshooting NAT gateway resources.
Tutorial for validating NAT Gateway
Azure CLI
PowerShell
Portal
Quickstart for deploying a NAT gateway resource
Azure CLI
PowerShell
Portal
Template
Learn about NAT gateway resource API
REST API
Azure CLI
PowerShell
Learn about availability zones.
Learn about standard load balancer.
Learn about availability zones and standard load balancer.
Tell us what to build next for Virtual Network NAT in UserVoice.
Azure Virtual Network NAT metrics
11/2/2020 • 2 minutes to read • Edit Online
Azure Virtual Network NAT gateway resources provide multi-dimensional metrics. You can use these metrics to
observe the operation and for troubleshooting. Alerts can be configured for critical issues such as SNAT
exhaustion.
Metrics
NAT gateway resources provide the following multi-dimensional metrics in Azure Monitor:
REC O M M EN DED
M ET RIC DESC RIP T IO N A GGREGAT IO N DIM EN SIO N S
SNAT Connection Count State transitions per interval Sum Connection State, Protocol
(6 TCP; 17 UDP)
Total SNAT connection count Current active SNAT Sum Protocol (6 TCP; 17 UDP)
connections (~ SNAT ports
in use)
Alerts
Alerts for metrics can be configured in Azure Monitor for each of the preceding metrics.
Limitations
Resource Health isn't supported.
Next steps
Learn about Virtual Network NAT
Learn about NAT gateway resource
Learn about Azure Monitor
Learn about troubleshooting NAT gateway resources.
Tell us what to build next for Virtual Network NAT in UserVoice.
Troubleshoot Azure Virtual Network NAT
connectivity
11/2/2020 • 10 minutes to read • Edit Online
This article helps administrators diagnose and resolve connectivity problems when using Virtual Network NAT.
Problems
SNAT exhaustion
ICMP ping is failing
Connectivity failures
IPv6 coexistence
Connection doesn't originate from NAT gateway IP(s)
To resolve these problems, follow the steps in the following section.
Resolution
SNAT exhaustion
A single NAT gateway resource supports from 64,000 up to 1 million concurrent flows. Each IP address provides
64,000 SNAT ports to the available inventory. You can use up to 16 IP addresses per NAT gateway resource. The
SNAT mechanism is described here in more detail.
Frequently the root cause of SNAT exhaustion is an anti-pattern for how outbound connectivity is established,
managed, or configurable timers changed from their default values. Review this section carefully.
Steps
1. Check if you have modified the default idle timeout to a value higher than 4 minutes.
2. Investigate how your application is creating outbound connectivity (for example, code review or packet
capture).
3. Determine if this activity is expected behavior or whether the application is misbehaving. Use metrics in Azure
Monitor to substantiate your findings. Use "Failed" category for SNAT Connections metric.
4. Evaluate if appropriate patterns are followed.
5. Evaluate if SNAT port exhaustion should be mitigated with additional IP addresses assigned to NAT gateway
resource.
Design patterns
Always take advantage of connection reuse and connection pooling whenever possible. These patterns will avoid
resource exhaustion problems and result in predictable behavior. Primitives for these patterns can be found in
many development libraries and frameworks.
Solution: Use appropriate patterns and best practices
NAT gateway resources have a default TCP idle timeout of 4 minutes. If this setting is changed to a higher value,
NAT will hold on to flows longer and can cause unnecessary pressure on SNAT port inventory.
Atomic requests (one request per connection) are a poor design choice. Such anti-pattern limits scale, reduces
performance, and decreases reliability. Instead, reuse HTTP/S connections to reduce the numbers of
connections and associated SNAT ports. The application scale will increase and performance improve due to
reduced handshakes, overhead, and cryptographic operation cost when using TLS.
DNS can introduce many individual flows at volume when the client is not caching the DNS resolvers result.
Use caching.
UDP flows (for example DNS lookups) allocate SNAT ports for the duration of the idle timeout. The longer the
idle timeout, the higher the pressure on SNAT ports. Use short idle timeout (for example 4 minutes).
Use connection pools to shape your connection volume.
Never silently abandon a TCP flow and rely on TCP timers to clean up flow. If you don't let TCP explicitly close
the connection, state remains allocated at intermediate systems and endpoints and makes SNAT ports
unavailable for other connections. This pattern can trigger application failures and SNAT exhaustion.
Don't change OS-level TCP close related timer values without expert knowledge of impact. While the TCP stack
will recover, your application performance can be negatively impacted when the endpoints of a connection
have mismatched expectations. The desire to change timers is usually a sign of an underlying design problem.
Review following recommendations.
SNAT exhaustion can also be amplified with other anti-patterns in the underlying application. Review these
additional patterns and best practices to improve the scale and reliability of your service.
Explore impact of reducing TCP idle timeout to lower values including default idle timeout of 4 minutes to free
up SNAT port inventory earlier.
Consider asynchronous polling patterns for long-running operations to free up connection resources for other
operations.
Long-lived flows (for example reused TCP connections) should use TCP keepalives or application layer
keepalives to avoid intermediate systems timing out. Increasing the idle timeout is a last resort and may not
resolve the root cause. A long timeout can cause low rate failures when timeout expires and introduce delay
and unnecessary failures.
Graceful retry patterns should be used to avoid aggressive retries/bursts during transient failure or failure
recovery. Creating a new TCP connection for every HTTP operation (also known as "atomic connections") is an
anti-pattern. Atomic connections will prevent your application from scaling well and waste resources. Always
pipeline multiple operations into the same connection. Your application will benefit in transaction speed and
resource costs. When your application uses transport layer encryption (for example TLS), there's a significant
cost associated with the processing of new connections. Review Azure Cloud Design Patterns for additional best
practice patterns.
Additional possible mitigations
Solution: Scale outbound connectivity as follows:
You're experiencing contention for SNAT "Failed" category for SNAT Connections Determine if you can add additional
ports and SNAT port exhaustion during metric in Azure Monitor shows public IP address resources or public IP
periods of high usage. transient or persistent failures over time prefix resources. This addition will allow
and high connection volume. for up to 16 IP addresses in total to
your NAT gateway. This addition will
provide more inventory for available
SNAT ports (64,000 per IP address) and
allow you to scale your scenario further.
You've already given 16 IP addresses Attempt to add additional IP address Distribute your application environment
and still are experiencing SNAT port fails. Total number of IP addresses from across multiple subnets and provide a
exhaustion. public IP address resources or public IP NAT gateway resource for each subnet.
prefix resources exceeds a total of 16. Reevaluate your design pattern(s) to
optimize based on preceding guidance.
NOTE
It is important to understand why SNAT exhaustion occurs. Make sure you are using the right patterns for scalable and
reliable scenarios. Adding more SNAT ports to a scenario without understanding the cause of the demand should be a last
resort. If you do not understand why your scenario is applying pressure on SNAT port inventory, adding more SNAT ports
to the inventory by adding more IP addresses will only delay the same exhaustion failure as your application scales. You may
be masking other inefficiencies and anti-patterns.
GEN ERIC TC P C O N N EC T IO N TC P A P P L IC AT IO N L AY ER
O P ERAT IN G SY ST EM T EST T EST UDP
Linux nc (generic connection test) curl (TCP application layer application specific
test)
Connectivity failures
Connectivity issues with Virtual Network NAT can be caused by several different issues:
permanent failures due to configuration mistakes.
transient or persistent SNAT exhaustion of the NAT gateway,
transient failures in the Azure infrastructure,
transient failures in the path between Azure and the public Internet destination,
transient or persistent failures at the public Internet destination.
Use tools like the following to validation connectivity. ICMP ping isn't supported.
GEN ERIC TC P C O N N EC T IO N TC P A P P L IC AT IO N L AY ER
O P ERAT IN G SY ST EM T EST T EST UDP
Linux nc (generic connection test) curl (TCP application layer application specific
test)
Configuration
Check your configuration:
1. Does the NAT gateway resource have at least one public IP resource or one public IP prefix resource? You must
at least have one IP address associated with the NAT gateway for it to be able to provide outbound connectivity.
2. Is the virtual network's subnet configured to use the NAT gateway?
3. Are you using UDR (user-defined route) and are you overriding the destination? NAT gateway resources
become the default route (0/0) on configured subnets.
SNAT exhaustion
Review section on SNAT exhaustion in this article.
Azure infrastructure
Azure monitors and operates its infrastructure with great care. Transient failures can occur, there's no guarantee
that transmissions are lossless. Use design patterns that allow for SYN retransmissions for TCP applications. Use
connection timeouts large enough to permit TCP SYN retransmission to reduce transient impacts caused by a lost
SYN packet.
Solution:
Check for SNAT exhaustion.
The configuration parameter in a TCP stack that controls the SYN retransmission behavior is called RTO
(Retransmission Time-Out). The RTO value is adjustable but typically 1 second or higher by default with
exponential back-off. If your application's connection time-out is too short (for example 1 second), you may see
sporadic connection timeouts. Increase the application connection time-out.
If you observe longer, unexpected timeouts with default application behaviors, open a support case for further
troubleshooting.
We don't recommend artificially reducing the TCP connection timeout or tuning the RTO parameter.
Public Internet transit
The chances of transient failures increases with a longer path to the destination and more intermediate systems.
It's expected that transient failures can increase in frequency over Azure infrastructure.
Follow the same guidance as preceding Azure infrastructure section.
Internet endpoint
The previous sections apply, along with the Internet endpoint that communication is established with. Other
factors that can impact connectivity success are:
traffic management on destination side, including
API rate limiting imposed by the destination side
Volumetric DDoS mitigations or transport layer traffic shaping
firewall or other components at the destination
Usually packet captures at the source and the destination (if available) are required to determine what is taking
place.
Solution:
Check for SNAT exhaustion.
Validate connectivity to an endpoint in the same region or elsewhere for comparison.
If you're creating high volume or transaction rate testing, explore if reducing the rate reduces the occurrence of
failures.
If changing rate impacts the rate of failures, check if API rate limits or other constraints on the destination side
might have been reached.
If your investigation is inconclusive, open a support case for further troubleshooting.
TCP Resets received
The NAT gateway generates TCP resets on the source VM for traffic that isn't recognized as in progress.
One possible reason is the TCP connection has idle timed out. You can adjust the idle timeout from 4 minutes to up
to 120 minutes.
TCP Resets aren't generated on the public side of NAT gateway resources. TCP resets on the destination side are
generated by the source VM, not the NAT gateway resource.
Solution:
Review design patterns recommendations.
Open a support case for further troubleshooting if necessary.
IPv6 coexistence
Virtual Network NAT supports IPv4 UDP and TCP protocols and deployment on a subnet with an IPv6 prefix isn't
supported.
Solution: Deploy NAT gateway on a subnet without IPv6 prefix.
You can indicate interest in additional capabilities through Virtual Network NAT UserVoice.
Connection doesn't originate from NAT gateway IP(s)
You configure NAT gateway, IP address(es) to use, and which subnet should use a NAT gateway resource. However,
connections from virtual machine instances that existed before the NAT gateway was deployed don't use the IP
address(es). They appear to be using IP address(es) not used with the NAT gateway resource.
Solution:
Virtual Network NAT replaces the outbound connectivity for the subnet it is configured on. When transitioning
from default SNAT or load balancer outbound SNAT to using NAT gateways, new connections will immediately
begin using the IP address(es) associated with the NAT gateway resource. However, if a virtual machine still has an
established connection during the switch to NAT gateway resource, the connection will continue using the old
SNAT IP address that was assigned when the connection was established. Make sure you are really establishing a
new connection rather than reusing a connection that already existed because the OS or the browser was caching
the connections in a connection pool. For example, when using curl in PowerShell, make sure to specify the -
DisableKeepalive parameter to force a new connection. If you're using a browser, connections may also be pooled.
It's not necessary to reboot a virtual machine configuring a subnet for a NAT gateway resource. However, if a
virtual machine is rebooted, the connection state is flushed. When the connection state has been flushed, all
connections will begin using the NAT gateway resource's IP address(es). However, this is a side effect of the virtual
machine being rebooted and not an indicator that a reboot is required.
If you are still having trouble, open a support case for further troubleshooting.
Next steps
Learn about Virtual Network NAT
Learn about NAT gateway resource
Learn about metrics and alerts for NAT gateway resources.
Tell us what to build next for Virtual Network NAT in UserVoice.
Virtual network traffic routing
5/21/2020 • 24 minutes to read • Edit Online
Learn about how Azure routes traffic between Azure, on-premises, and Internet resources. Azure automatically
creates a route table for each subnet within an Azure virtual network and adds system default routes to the
table. To learn more about virtual networks and subnets, see Virtual network overview. You can override some
of Azure's system routes with custom routes, and add additional custom routes to route tables. Azure routes
outbound traffic from a subnet based on the routes in a subnet's route table.
System routes
Azure automatically creates system routes and assigns the routes to each subnet in a virtual network. You can't
create system routes, nor can you remove system routes, but you can override some system routes with
custom routes. Azure creates default system routes for each subnet, and adds additional optional default routes
to specific subnets, or every subnet, when you use specific Azure capabilities.
Default
Each route contains an address prefix and next hop type. When traffic leaving a subnet is sent to an IP address
within the address prefix of a route, the route that contains the prefix is the route Azure uses. Learn more about
how Azure selects a route when multiple routes contain the same prefixes, or overlapping prefixes. Whenever a
virtual network is created, Azure automatically creates the following default system routes for each subnet
within the virtual network:
The next hop types listed in the previous table represent how Azure routes traffic destined for the address prefix
listed. Explanations for the next hop types follow:
Vir tual network : Routes traffic between address ranges within the address space of a virtual network.
Azure creates a route with an address prefix that corresponds to each address range defined within the
address space of a virtual network. If the virtual network address space has multiple address ranges
defined, Azure creates an individual route for each address range. Azure automatically routes traffic
between subnets using the routes created for each address range. You don't need to define gateways for
Azure to route traffic between subnets. Though a virtual network contains subnets, and each subnet has
a defined address range, Azure does not create default routes for subnet address ranges, because each
subnet address range is within an address range of the address space of a virtual network.
Internet : Routes traffic specified by the address prefix to the Internet. The system default route specifies
the 0.0.0.0/0 address prefix. If you don't override Azure's default routes, Azure routes traffic for any
address not specified by an address range within a virtual network, to the Internet, with one exception. If
the destination address is for one of Azure's services, Azure routes the traffic directly to the service over
Azure's backbone network, rather than routing the traffic to the Internet. Traffic between Azure services
does not traverse the Internet, regardless of which Azure region the virtual network exists in, or which
Azure region an instance of the Azure service is deployed in. You can override Azure's default system
route for the 0.0.0.0/0 address prefix with a custom route.
None : Traffic routed to the None next hop type is dropped, rather than routed outside the subnet. Azure
automatically creates default routes for the following address prefixes:
10.0.0.0/8 and 192.168.0.0/16 : Reserved for private use in RFC 1918.
100.64.0.0/10 : Reserved in RFC 6598.
If you assign any of the previous address ranges within the address space of a virtual network, Azure
automatically changes the next hop type for the route from None to Vir tual network . If you assign an
address range to the address space of a virtual network that includes, but isn't the same as, one of the
four reserved address prefixes, Azure removes the route for the prefix and adds a route for the address
prefix you added, with Vir tual network as the next hop type.
Optional default routes
Azure adds additional default system routes for different Azure capabilities, but only if you enable the
capabilities. Depending on the capability, Azure adds optional default routes to either specific subnets within the
virtual network, or to all subnets within a virtual network. The additional system routes and next hop types that
Azure may add when you enable different capabilities are:
SUB N ET W IT H IN VIRT UA L
N ET W O RK T H AT RO UT E IS
SO URC E A DDRESS P REF IXES N EXT H O P T Y P E A DDED TO
Virtual network gateway Prefixes advertised from Virtual network gateway All
on-premises via BGP, or
configured in the local
network gateway
Vir tual network (VNet) peering : When you create a virtual network peering between two virtual
networks, a route is added for each address range within the address space of each virtual network a
peering is created for. Learn more about virtual network peering.
Vir tual network gateway : One or more routes with Virtual network gateway listed as the next hop
type are added when a virtual network gateway is added to a virtual network. The source is also virtual
network gateway, because the gateway adds the routes to the subnet. If your on-premises network
gateway exchanges border gateway protocol (BGP) routes with an Azure virtual network gateway, a
route is added for each route propagated from the on-premises network gateway. It's recommended that
you summarize on-premises routes to the largest address ranges possible, so the fewest number of
routes are propagated to an Azure virtual network gateway. There are limits to the number of routes you
can propagate to an Azure virtual network gateway. For details, see Azure limits.
Vir tualNetworkSer viceEndpoint : The public IP addresses for certain services are added to the route
table by Azure when you enable a service endpoint to the service. Service endpoints are enabled for
individual subnets within a virtual network, so the route is only added to the route table of a subnet a
service endpoint is enabled for. The public IP addresses of Azure services change periodically. Azure
manages the addresses in the route table automatically when the addresses change. Learn more about
virtual network service endpoints, and the services you can create service endpoints for.
NOTE
The VNet peering and Vir tualNetworkSer viceEndpoint next hop types are only added to route tables of
subnets within virtual networks created through the Azure Resource Manager deployment model. The next hop
types are not added to route tables that are associated to virtual network subnets created through the classic
deployment model. Learn more about Azure deployment models.
Custom routes
You create custom routes by either creating user-defined routes, or by exchanging border gateway protocol
(BGP) routes between your on-premises network gateway and an Azure virtual network gateway.
User-defined
You can create custom, or user-defined(static), routes in Azure to override Azure's default system routes, or to
add additional routes to a subnet's route table. In Azure, you create a route table, then associate the route table
to zero or more virtual network subnets. Each subnet can have zero or one route table associated to it. To learn
about the maximum number of routes you can add to a route table and the maximum number of user-defined
route tables you can create per Azure subscription, see Azure limits. If you create a route table and associate it
to a subnet, the routes within it are combined with, or override, the default routes Azure adds to a subnet by
default.
You can specify the following next hop types when creating a user-defined route:
Vir tual appliance : A virtual appliance is a virtual machine that typically runs a network application,
such as a firewall. To learn about a variety of pre-configured network virtual appliances you can deploy
in a virtual network, see the Azure Marketplace. When you create a route with the vir tual appliance
hop type, you also specify a next hop IP address. The IP address can be:
The private IP address of a network interface attached to a virtual machine. Any network interface
attached to a virtual machine that forwards network traffic to an address other than its own must
have the Azure Enable IP forwarding option enabled for it. The setting disables Azure's check of
the source and destination for a network interface. Learn more about how to enable IP forwarding
for a network interface. Though Enable IP forwarding is an Azure setting, you may also need to
enable IP forwarding within the virtual machine's operating system for the appliance to forward
traffic between private IP addresses assigned to Azure network interfaces. If the appliance must
route traffic to a public IP address, it must either proxy the traffic, or network address translate the
private IP address of the source's private IP address to its own private IP address, which Azure
then network address translates to a public IP address, before sending the traffic to the Internet.
To determine required settings within the virtual machine, see the documentation for your
operating system or network application. To understand outbound connections in Azure, see
Understanding outbound connections.
NOTE
Deploy a virtual appliance into a different subnet than the resources that route through the virtual
appliance are deployed in. Deploying the virtual appliance to the same subnet, then applying a route
table to the subnet that routes traffic through the virtual appliance, can result in routing loops, where
traffic never leaves the subnet.
The private IP address of an Azure internal load balancer. A load balancer is often used as part of
a high availability strategy for network virtual appliances.
You can define a route with 0.0.0.0/0 as the address prefix and a next hop type of virtual appliance,
enabling the appliance to inspect the traffic and determine whether to forward or drop the traffic. If you
intend to create a user-defined route that contains the 0.0.0.0/0 address prefix, read 0.0.0.0/0 address
prefix first.
Vir tual network gateway : Specify when you want traffic destined for specific address prefixes routed
to a virtual network gateway. The virtual network gateway must be created with type VPN . You cannot
specify a virtual network gateway created as type ExpressRoute in a user-defined route because with
ExpressRoute, you must use BGP for custom routes. You can define a route that directs traffic destined
for the 0.0.0.0/0 address prefix to a route-based virtual network gateway. On your premises, you might
have a device that inspects the traffic and determines whether to forward or drop the traffic. If you
intend to create a user-defined route for the 0.0.0.0/0 address prefix, read 0.0.0.0/0 address prefix first.
Instead of configuring a user-defined route for the 0.0.0.0/0 address prefix, you can advertise a route
with the 0.0.0.0/0 prefix via BGP, if you've enabled BGP for a VPN virtual network gateway.
None : Specify when you want to drop traffic to an address prefix, rather than forwarding the traffic to a
destination. If you haven't fully configured a capability, Azure may list None for some of the optional
system routes. For example, if you see None listed as the Next hop IP address with a Next hop type
of Virtual network gateway or Virtual appliance, it may be because the device isn't running, or isn't fully
configured. Azure creates system default routes for reserved address prefixes with None as the next hop
type.
Vir tual network : Specify when you want to override the default routing within a virtual network. See
Routing example, for an example of why you might create a route with the Vir tual network hop type.
Internet : Specify when you want to explicitly route traffic destined to an address prefix to the Internet, or
if you want traffic destined for Azure services with public IP addresses kept within the Azure backbone
network.
You cannot specify VNet peering or Vir tualNetworkSer viceEndpoint as the next hop type in user-defined
routes. Routes with the VNet peering or Vir tualNetworkSer viceEndpoint next hop types are only created
by Azure, when you configure a virtual network peering, or a service endpoint.
NOTE
System routes for traffic related to virtual network, virtual network peerings, or virtual network service endpoints, are
preferred routes, even if BGP routes are more specific.
When traffic is destined for an IP address outside the address prefixes of any other routes in the route table,
Azure selects the route with the User source, because user-defined routes are higher priority than system
default routes.
See Routing example for a comprehensive routing table with explanations of the routes in the table.
Routing example
To illustrate the concepts in this article, the sections that follow describe:
A scenario, with requirements
The custom routes necessary to meet the requirements
The route table that exists for one subnet that includes the default and custom routes necessary to meet the
requirements
NOTE
This example is not intended to be a recommended or best practice implementation. Rather, it is provided only to
illustrate concepts in this article.
Requirements
1. Implement two virtual networks in the same Azure region and enable resources to communicate
between the virtual networks.
2. Enable an on-premises network to communicate securely with both virtual networks through a VPN
tunnel over the Internet. Alternatively, an ExpressRoute connection could be used, but in this example, a
VPN connection is used.
3. For one subnet in one virtual network:
Force all outbound traffic from the subnet, except to Azure Storage and within the subnet, to flow
through a network virtual appliance, for inspection and logging.
Do not inspect traffic between private IP addresses within the subnet; allow traffic to flow directly
between all resources.
Drop any outbound traffic destined for the other virtual network.
Enable outbound traffic to Azure storage to flow directly to storage, without forcing it through a
network virtual appliance.
4. Allow all traffic between all other subnets and virtual networks.
Implementation
The following picture shows an implementation through the Azure Resource Manager deployment model that
meets the previous requirements:
Arrows show the flow of traffic.
Route tables
Subnet1
The route table for Subnet1 in the picture contains the following routes:
USER-
A DDRESS N EXT H O P N EXT H O P IP DEF IN ED
ID SO URC E STAT E P REF IXES TYPE A DDRESS RO UT E N A M E
N EXT H O P IP
SO URC E STAT E A DDRESS P REF IXES N EXT H O P T Y P E A DDRESS
The route table for Subnet2 contains all Azure-created default routes and the optional VNet peering and Virtual
network gateway optional routes. Azure added the optional routes to all subnets in the virtual network when
the gateway and peering were added to the virtual network. Azure removed the routes for the 10.0.0.0/8,
192.168.0.0/16, and 100.64.0.0/10 address prefixes from the Subnet1 route table when the user-defined route
for the 0.0.0.0/0 address prefix was added to Subnet1.
Next steps
Create a user-defined route table with routes and a network virtual appliance
Configure BGP for an Azure VPN Gateway
Use BGP with ExpressRoute
View all routes for a subnet. A user-defined route table only shows you the user-defined routes, not the
default, and BGP routes for a subnet. Viewing all routes shows you the default, BGP, and user-defined routes
for the subnet a network interface is in.
Determine the next hop type between a virtual machine and a destination IP address. The Azure Network
Watcher next hop feature enables you to determine whether traffic is leaving a subnet and being routed to
where you think it should be.
Interoperability in Azure : Test setup
4/1/2020 • 4 minutes to read • Edit Online
This article describes a test setup you can use to analyze how Azure networking services interoperate at the control
plane level and data plane level. Let's look briefly at the Azure networking components:
Azure ExpressRoute : Use private peering in Azure ExpressRoute to directly connect private IP spaces in your
on-premises network to your Azure Virtual Network deployments. ExpressRoute can help you achieve higher
bandwidth and a private connection. Many ExpressRoute eco partners offer ExpressRoute connectivity with
SLAs. To learn more about ExpressRoute and to learn how to configure ExpressRoute, see Introduction to
ExpressRoute.
Site-to-site VPN : You can use Azure VPN Gateway as a site-to-site VPN to securely connect an on-premises
network to Azure over the internet or by using ExpressRoute. To learn how to configure a site-to-site VPN to
connect to Azure, see Configure VPN Gateway.
VNet peering : Use virtual network (VNet) peering to establish connectivity between VNets in Azure Virtual
Network. To learn more about VNet peering, see the tutorial on VNet peering.
Test setup
The following figure illustrates the test setup:
The centerpiece of the test setup is the hub VNet in Azure Region 1. The hub VNet is connected to different
networks in the following ways:
The hub VNet is connected to the spoke VNet by using VNet peering. The spoke VNet has remote access to both
gateways in the hub VNet.
The hub VNet is connected to the branch VNet by using site-to-site VPN. The connectivity uses eBGP to
exchange routes.
The hub VNet is connected to the on-premises Location 1 network by using ExpressRoute private peering as the
primary path. It uses site-to-site VPN connectivity as the backup path. In the rest of this article, we refer to this
ExpressRoute circuit as ExpressRoute 1. By default, ExpressRoute circuits provide redundant connectivity for high
availability. On ExpressRoute 1, the secondary customer edge (CE) router's subinterface that faces the secondary
Microsoft Enterprise Edge Router (MSEE) is disabled. A red line over the double-line arrow in the preceding
figure represents the disabled CE router subinterface.
The hub VNet is connected to the on-premises Location 2 network by using another ExpressRoute private
peering. In the rest of this article, we refer to this second ExpressRoute circuit as ExpressRoute 2.
ExpressRoute 1 also connects both the hub VNet and the on-premises Location 1 network to a remote VNet in
Azure Region 2.
Next steps
Learn about configuration details for the test topology.
Learn about control plane analysis of the test setup and the views of different VNets or VLANs in the topology.
Learn about the data plane analysis of the test setup and Azure network monitoring feature views.
See the ExpressRoute FAQ to:
Learn how many ExpressRoute circuits you can connect to an ExpressRoute gateway.
Learn how many ExpressRoute gateways you can connect to an ExpressRoute circuit.
Learn about other scale limits of ExpressRoute.
Interoperability in Azure back-end connectivity
features: Test configuration details
11/2/2020 • 6 minutes to read • Edit Online
This article describes the configuration details of the test setup. The test setup helps you analyze how Azure
networking services interoperate at the control plane level and data plane level.
The following figure shows the VNet peering details of the hub VNet. If you want the hub VNet to permit the spoke
VNet to use the hub's gateways, select Allow gateway transit .
Branch VNet connectivity by using a site-to-site VPN
Set up site-to-site VPN connectivity between the hub and branch VNets by using VPN gateways in Azure VPN
Gateway. By default, VPN gateways and Azure ExpressRoute gateways use a private autonomous system number
(ASN) value of 65515 . You can change the ASN value in VPN Gateway. In the test setup, the ASN value of the
branch VNet VPN gateway is changed to 65516 to support eBGP routing between the hub and branch VNets.
On-premises Location 1 connectivity by using ExpressRoute and a site-
to-site VPN
ExpressRoute 1 configuration details
The following figure shows the Azure Region 1 ExpressRoute circuit configuration toward on-premises Location 1
customer edge (CE) routers:
The following figure shows the connection configuration between the ExpressRoute 1 circuit and the hub VNet:
The following list shows the primary CE router configuration for ExpressRoute private peering connectivity. (Cisco
ASR1000 routers are used as CE routers in the test setup.) When site-to-site VPN and ExpressRoute circuits are
configured in parallel to connect an on-premises network to Azure, Azure prioritizes the ExpressRoute circuit by
default. To avoid asymmetrical routing, the on-premises network also should prioritize ExpressRoute connectivity
over site-to-site VPN connectivity. The following configuration establishes prioritization by using the BGP local-
preference attribute:
interface TenGigabitEthernet0/0/0.300
description Customer 30 private peering to Azure
encapsulation dot1Q 30 second-dot1q 300
ip vrf forwarding 30
ip address 192.168.30.17 255.255.255.252
!
interface TenGigabitEthernet1/0/0.30
description Customer 30 to south bound LAN switch
encapsulation dot1Q 30
ip vrf forwarding 30
ip address 192.168.30.0 255.255.255.254
ip ospf network point-to-point
!
router ospf 30 vrf 30
router-id 10.2.30.253
redistribute bgp 65021 subnets route-map BGP2OSPF
network 192.168.30.0 0.0.0.1 area 0.0.0.0
default-information originate always
default-metric 10
!
router bgp 65021
!
address-family ipv4 vrf 30
network 10.2.30.0 mask 255.255.255.128
neighbor 192.168.30.18 remote-as 12076
neighbor 192.168.30.18 activate
neighbor 192.168.30.18 next-hop-self
neighbor 192.168.30.18 soft-reconfiguration inbound
neighbor 192.168.30.18 route-map prefer-ER-over-VPN in
neighbor 192.168.30.18 prefix-list Cust30_to_Private out
exit-address-family
!
route-map prefer-ER-over-VPN permit 10
set local-preference 200
!
ip prefix-list Cust30_to_Private seq 10 permit 10.2.30.0/25
!
ExpressRoute 1 connects both the hub VNet and on-premises Location 1 to a remote VNet in a different Azure
region:
Next steps
Learn about control plane analysis of the test setup and the views of different VNets or VLANs in the topology.
Learn about data plane analysis of the test setup and Azure network monitoring feature views.
See the ExpressRoute FAQ to:
Learn how many ExpressRoute circuits you can connect to an ExpressRoute gateway.
Learn how many ExpressRoute gateways you can connect to an ExpressRoute circuit.
Learn about other scale limits of ExpressRoute.
Interoperability in Azure : Control plane analysis
4/1/2020 • 4 minutes to read • Edit Online
This article describes the control plane analysis of the test setup. You can also review the test setup configuration
and the data plane analysis of the test setup.
Control plane analysis essentially examines routes that are exchanged between networks within a topology. Control
plane analysis can help you understand how different networks view the topology.
The ASN of the VNet's Azure ExpressRoute gateway is different from the ASN of Microsoft Enterprise Edge Routers
(MSEEs). An ExpressRoute gateway uses a private ASN (a value of 65515 ) and MSEEs use public ASN (a value of
12076 ) globally. When you configure ExpressRoute peering, because MSEE is the peer, you use 12076 as the peer
ASN. On the Azure side, MSEE establishes eBGP peering with the ExpressRoute gateway. The dual eBGP peering
that the MSEE establishes for each ExpressRoute peering is transparent at the control plane level. Therefore, when
you view an ExpressRoute route table, you see the VNet's ExpressRoute gateway ASN for the VNet's prefixes.
The following figure shows a sample ExpressRoute route table:
Within Azure, the ASN is significant only from a peering perspective. By default, the ASN of both the ExpressRoute
gateway and the VPN gateway in Azure VPN Gateway is 65515 .
Next steps
Learn about data plane analysis of the test setup and Azure network monitoring feature views.
See the ExpressRoute FAQ to:
Learn how many ExpressRoute circuits you can connect to an ExpressRoute gateway.
Learn how many ExpressRoute gateways you can connect to an ExpressRoute circuit.
Learn about other scale limits of ExpressRoute.
Interoperability in Azure : Data plane analysis
11/2/2020 • 16 minutes to read • Edit Online
This article describes the data plane analysis of the test setup. You can also review the test setup configuration and
the control plane analysis of the test setup.
Data plane analysis examines the path taken by packets that traverse from one local network (LAN or virtual
network) to another within a topology. The data path between two local networks isn't necessarily symmetrical.
Therefore, in this article, we analyze a forwarding path from a local network to another network that's separate
from the reverse path.
C:\Users\rb>tracert 10.11.30.4
1 2 ms 1 ms 1 ms 10.11.30.4
Trace complete.
The following figure shows the graphical connection view of the hub VNet and the spoke VNet from the
perspective of Azure Network Watcher:
C:\Users\rb>tracert 10.11.30.68
1 1 ms 1 ms 1 ms 10.10.30.142
2 * * * Request timed out.
3 2 ms 2 ms 2 ms 10.11.30.68
Trace complete.
In this traceroute, the first hop is the VPN gateway in Azure VPN Gateway of the hub VNet. The second hop is the
VPN gateway of the branch VNet. The IP address of the VPN gateway of the branch VNet isn't advertised in the hub
VNet. The third hop is the VM on the branch VNet.
The following figure shows the graphical connection view of the hub VNet and the branch VNet from the
perspective of Network Watcher:
For the same connection, the following figure shows the grid view in Network Watcher:
C:\Users\rb>tracert 10.2.30.10
1 2 ms 2 ms 2 ms 10.10.30.132
2 * * * Request timed out.
3 * * * Request timed out.
4 2 ms 2 ms 2 ms 10.2.30.10
Trace complete.
In this traceroute, the first hop is the Azure ExpressRoute gateway tunnel endpoint to a Microsoft Enterprise Edge
Router (MSEE). The second and third hops are the customer edge (CE) router and the on-premises Location 1 LAN
IPs. These IP addresses aren't advertised in the hub VNet. The fourth hop is the VM in the on-premises Location 1.
Path to on-premises Location 2
Traceroute output from a hub VNet to a VM in on-premises Location 2 is shown here:
C:\Users\rb>tracert 10.1.31.10
1 76 ms 75 ms 75 ms 10.10.30.134
2 * * * Request timed out.
3 * * * Request timed out.
4 75 ms 75 ms 75 ms 10.1.31.10
Trace complete.
In this traceroute, the first hop is the ExpressRoute gateway tunnel endpoint to an MSEE. The second and third hops
are the CE router and the on-premises Location 2 LAN IPs. These IP addresses aren't advertised in the hub VNet.
The fourth hop is the VM on the on-premises Location 2.
Path to the remote VNet
Traceroute output from a hub VNet to a VM in the remote VNet is shown here:
C:\Users\rb>tracert 10.17.30.4
1 2 ms 2 ms 2 ms 10.10.30.132
2 * * * Request timed out.
3 69 ms 68 ms 69 ms 10.17.30.4
Trace complete.
In this traceroute, the first hop is the ExpressRoute gateway tunnel endpoint to an MSEE. The second hop is the
remote VNet's gateway IP. The second hop IP range isn't advertised in the hub VNet. The third hop is the VM on the
remote VNet.
C:\Users\rb>tracert 10.10.30.4
Trace complete.
Trace complete.
In this traceroute, the first hop is the VPN gateway of the hub VNet. The second hop is the VPN gateway of the
branch VNet. The IP address of the VPN gateway of the branch VNet isn't advertised within the hub/spoke VNet.
The third hop is the VM on the branch VNet.
Path to on-premises Location 1
Traceroute output from the spoke VNet to a VM in on-premises Location 1 is shown here:
C:\Users\rb>tracert 10.2.30.10
1 24 ms 2 ms 3 ms 10.10.30.132
2 * * * Request timed out.
3 * * * Request timed out.
4 3 ms 2 ms 2 ms 10.2.30.10
Trace complete.
In this traceroute, the first hop is the hub VNet's ExpressRoute gateway tunnel endpoint to an MSEE. The second
and third hops are the CE router and the on-premises Location 1 LAN IPs. These IP addresses aren't advertised in
the hub/spoke VNet. The fourth hop is the VM in the on-premises Location 1.
Path to on-premises Location 2
Traceroute output from the spoke VNet to a VM in on-premises Location 2 is shown here:
C:\Users\rb>tracert 10.1.31.10
1 76 ms 75 ms 76 ms 10.10.30.134
2 * * * Request timed out.
3 * * * Request timed out.
4 75 ms 75 ms 75 ms 10.1.31.10
Trace complete.
In this traceroute, the first hop is the hub VNet's ExpressRoute gateway tunnel endpoint to an MSEE. The second
and third hops are the CE router and the on-premises Location 2 LAN IPs. These IP addresses aren't advertised in
the hub/spoke VNets. The fourth hop is the VM in the on-premises Location 2.
Path to the remote VNet
Traceroute output from the spoke VNet to a VM in the remote VNet is shown here:
C:\Users\rb>tracert 10.17.30.4
1 2 ms 1 ms 1 ms 10.10.30.133
2 * * * Request timed out.
3 71 ms 70 ms 70 ms 10.17.30.4
Trace complete.
In this traceroute, the first hop is the hub VNet's ExpressRoute gateway tunnel endpoint to an MSEE. The second
hop is the remote VNet's gateway IP. The second hop IP range isn't advertised in the hub/spoke VNet. The third hop
is the VM on the remote VNet.
C:\Windows\system32>tracert 10.10.30.4
Trace complete.
In this traceroute, the first hop is the VPN gateway of the branch VNet. The second hop is the VPN gateway of the
hub VNet. The IP address of the VPN gateway of the hub VNet isn't advertised in the remote VNet. The third hop is
the VM on the hub VNet.
Path to the spoke VNet
Traceroute output from the branch VNet to a VM in the spoke VNet is shown here:
C:\Users\rb>tracert 10.11.30.4
1 1 ms <1 ms 1 ms 10.11.30.100
2 * * * Request timed out.
3 4 ms 3 ms 2 ms 10.11.30.4
Trace complete.
In this traceroute, the first hop is the VPN gateway of the branch VNet. The second hop is the VPN gateway of the
hub VNet. The IP address of the VPN gateway of the hub VNet isn't advertised in the remote VNet. The third hop is
the VM on the spoke VNet.
Path to on-premises Location 1
Traceroute output from the branch VNet to a VM in on-premises Location 1 is shown here:
C:\Users\rb>tracert 10.2.30.10
Trace complete.
In this traceroute, the first hop is the VPN gateway of the branch VNet. The second hop is the VPN gateway of the
hub VNet. The IP address of the VPN gateway of the hub VNet isn't advertised in the remote VNet. The third hop is
the VPN tunnel termination point on the primary CE router. The fourth hop is an internal IP address of on-premises
Location 1. This LAN IP address isn't advertised outside the CE router. The fifth hop is the destination VM in the on-
premises Location 1.
Path to on-premises Location 2 and the remote VNet
As we discussed in the control plane analysis, the branch VNet has no visibility either to on-premises Location 2 or
to the remote VNet per the network configuration. The following ping results confirm:
C:\Users\rb>ping 10.1.31.10
C:\Users\rb>ping 10.17.30.4
Trace complete.
In this traceroute, the first two hops are part of the on-premises network. The third hop is the primary MSEE
interface that faces the CE router. The fourth hop is the ExpressRoute gateway of the hub VNet. The IP range of the
ExpressRoute gateway of the hub VNet isn't advertised to the on-premises network. The fifth hop is the destination
VM.
Network Watcher provides only an Azure-centric view. For an on-premises perspective, we use Azure Network
Performance Monitor. Network Performance Monitor provides agents that you can install on servers in networks
outside Azure for data path analysis.
The following figure shows the topology view of the on-premises Location 1 VM connectivity to the VM on the hub
VNet via ExpressRoute:
As discussed earlier, the test setup uses a site-to-site VPN as backup connectivity for ExpressRoute between the on-
premises Location 1 and the hub VNet. To test the backup data path, let's induce an ExpressRoute link failure
between the on-premises Location 1 primary CE router and the corresponding MSEE. To induce an ExpressRoute
link failure, shut down the CE interface that faces the MSEE:
C:\Users\rb>tracert 10.10.30.4
Trace complete.
The following figure shows the topology view of the on-premises Location 1 VM connectivity to the VM on the hub
VNet via site-to-site VPN connectivity when ExpressRoute connectivity is down:
Path to the spoke VNet
Traceroute output from on-premises Location 1 to a VM in the spoke VNet is shown here:
Let's bring back the ExpressRoute primary connectivity to do the data path analysis toward the spoke VNet:
C:\Users\rb>tracert 10.11.30.4
Trace complete.
Bring up the primary ExpressRoute 1 connectivity for the remainder of the data path analysis.
Path to the branch VNet
Traceroute output from on-premises Location 1 to a VM in the branch VNet is shown here:
C:\Users\rb>tracert 10.11.30.68
Trace complete.
C:\Users\rb>ping 10.1.31.10
Trace complete.
C:\Windows\system32>tracert 10.10.30.4
Trace complete.
C:\Windows\system32>tracert 10.11.30.4
Trace complete.
Path to the branch VNet, on-premises Location 1, and the remote VNet
As we discuss in the control plane analysis, the on-premises Location 1 has no visibility to the branch VNet, to on-
premises Location 1, or to the remote VNet per the network configuration.
1 65 ms 65 ms 65 ms 10.17.30.36
2 * * * Request timed out.
3 69 ms 68 ms 68 ms 10.10.30.4
Trace complete.
C:\Users\rb>tracert 10.11.30.4
1 67 ms 67 ms 67 ms 10.17.30.36
2 * * * Request timed out.
3 71 ms 69 ms 69 ms 10.11.30.4
Trace complete.
C:\Users\rb>tracert 10.2.30.10
1 67 ms 67 ms 67 ms 10.17.30.36
2 * * * Request timed out.
3 * * * Request timed out.
4 69 ms 69 ms 69 ms 10.2.30.10
Trace complete.
Next steps
See the ExpressRoute FAQ to:
Learn how many ExpressRoute circuits you can connect to an ExpressRoute gateway.
Learn how many ExpressRoute gateways you can connect to an ExpressRoute circuit.
Learn about other scale limits of ExpressRoute.
Enable containers to use Azure Virtual Network
capabilities
11/2/2020 • 3 minutes to read • Edit Online
Bring the rich set of Azure network capabilities to containers, by utilizing the same software defined networking
stack that powers virtual machines. The Azure Virtual Network container network interface (CNI) plug-in installs in
an Azure Virtual Machine. The plug-in assigns IP addresses from a virtual network to containers brought up in the
virtual machine, attaching them to the virtual network, and connecting them directly to other containers and
virtual network resources. The plug-in doesn’t rely on overlay networks, or routes, for connectivity, and provides
the same performance as virtual machines. At a high level, the plug-in provides the following capabilities:
A virtual network IP address is assigned to every Pod, which could consist of one or more containers.
Pods can connect to peered virtual networks and to on-premises over ExpressRoute or a site-to-site VPN. Pods
are also reachable from peered and on-premises networks.
Pods can access services such as Azure Storage and Azure SQL Database, that are protected by virtual network
service endpoints.
Network security groups and routes can be applied directly to Pods.
Pods can be placed directly behind an Azure internal or public Load Balancer, just like virtual machines
Pods can be assigned a public IP address, which makes them directly accessible from the internet. Pods can also
access the internet themselves.
Works seamlessly with Kubernetes resources such as Services, Ingress controllers, and Kube DNS. A Kubernetes
Service can also be exposed internally or externally through the Azure Load Balancer.
The following picture shows how the plug-in provides Azure Virtual Network capabilities to Pods:
The plug-in supports both Linux and Windows platforms.
Internet access
To enable Pods to access the internet, the plug-in configures iptables rules to network address translate (NAT) the
internet bound traffic from Pods. The source IP address of the packet is translated to the primary IP address on the
virtual machine's network interface. Windows virtual machines automatically source NAT (SNAT) traffic destined to
IP addresses outside the subnet the virtual machine is in. Typically, all traffic destined to an IP address outside of
the IP range of the virtual network is translated.
Limits
The plug-in supports up to 250 Pods per virtual machine and up to 16,000 Pods in a virtual network. These limits
are different for the Azure Kubernetes Service.
Next steps
Deploy the plug-in for Kubernetes clusters or Docker containers
Cross-network connectivity
11/2/2020 • 4 minutes to read • Edit Online
Fabrikam Inc. has a large physical presence and Azure deployment in East US. Fabrikam has back-end connectivity
between its on-premises and Azure deployments via ExpressRoute. Similarly, Contoso Ltd. has a presence and
Azure deployment in West US. Contoso has back-end connectivity between its on-premises and Azure deployments
via ExpressRoute.
Fabrikam Inc. acquires Contoso Ltd. Following the merger, Fabrikam wants to interconnect the networks. The
following figure illustrates the scenario:
The dashed arrows in the middle of the above figure indicate the desired network interconnections. Specifically,
there are three types cross connections desired: 1) Fabrikam and Contoso VNets cross connect, 2) Cross regional
on-premises and VNets cross connects (that is, connecting Fabrikam on-premises network to Contoso VNet and
connecting Contoso on-premises network to Fabrikam VNet), and 3) Fabrikam and Contoso on-premises network
cross connect.
The following table shows the route table of the private peering of the ExpressRoute of Contoso Ltd., before the
merger.
The following table shows the effective routes of a VM in the Contoso subscription, before the merger. Per the table,
the VM on the VNet is aware of the VNet address space and the Contoso on-premises network, apart from the
default ones.
The following table shows the route table of the private peering of the ExpressRoute of Fabrikam Inc., before the
merger.
The following table shows the effective routes of a VM in the Fabrikam subscription, before the merger. Per the
table, the VM on the VNet is aware of the VNet address space and the Fabrikam on-premises network, apart from
the default ones.
In this article, let's go through step by step and discuss how to achieve the desired cross connections using the
following Azure network features:
Virtual network peering
Virtual network ExpressRoute connection
Global Reach
The following table shows the routes known to the Fabrikam subscription VM. Pay attention to the last entry of the
table. This entry is the result of cross connecting the virtual networks.
VNet peering directly links two virtual networks (see there are no next hop for VNetGlobalPeering entry in the
above two tables)
The following table shows the route table of the private peering of the ExpressRoute of Fabrikam Inc., after cross
connecting virtual networks to the on-premises networks via ExpressRoute. See that the route table has routes
belonging to both the virtual networks.
The following table shows the routes known to the Contoso subscription VM. Pay attention to Virtual network
gateway entries of the table. The VM sees routes for both the on-premises networks.
The following table shows the routes known to the Fabrikam subscription VM. Pay attention to Virtual network
gateway entries of the table. The VM sees routes for both the on-premises networks.
NOTE
In either the Fabrikam and/or Contoso subscriptions you can also have spoke VNets to the respective hub VNet (a hub and
spoke design is not illustrated in the architecture diagrams in this article). The cross connections between the hub VNet
gateways to ExpressRoute will also allow communication between East and West hubs and spokes.
The following table shows the route table of the private peering of the ExpressRoute of Fabrikam Inc., after
configuring Global Reach. See that the route table has routes belonging to both the on-premises networks.
Next steps
See virtual network FAQ, for any further questions on VNet and VNet-peering. See ExpressRoute FAQ for any
further questions on ExpressRoute and virtual network connectivity.
Global Reach is rolled out on a country/region by country/region basis. To see if Global Reach is available in the
countries/regions that you want, see ExpressRoute Global Reach.
Virtual network peering
11/2/2020 • 6 minutes to read • Edit Online
Virtual network peering enables you to seamlessly connect two or more Virtual Networks in Azure. The virtual
networks appear as one for connectivity purposes. The traffic between virtual machines in peered virtual
networks uses the Microsoft backbone infrastructure. Like traffic between virtual machines in the same
network, traffic is routed through Microsoft's private network only.
Azure supports the following types of peering:
Virtual network peering: Connect virtual networks within the same Azure region.
Global virtual network peering: Connecting virtual networks across Azure regions.
The benefits of using virtual network peering, whether local or global, include:
A low-latency, high-bandwidth connection between resources in different virtual networks.
The ability for resources in one virtual network to communicate with resources in a different virtual
network.
The ability to transfer data between virtual networks across Azure subscriptions, Azure Active Directory
tenants, deployment models, and Azure regions.
The ability to peer virtual networks created through the Azure Resource Manager.
The ability to peer a virtual network created through Resource Manager to one created through the classic
deployment model. To learn more about Azure deployment models, see Understand Azure deployment
models.
No downtime to resources in either virtual network when creating the peering, or after the peering is
created.
Network traffic between peered virtual networks is private. Traffic between the virtual networks is kept on the
Microsoft backbone network. No public Internet, gateways, or encryption is required in the communication
between the virtual networks.
Connectivity
For peered virtual networks, resources in either virtual network can directly connect with resources in the
peered virtual network.
The network latency between virtual machines in peered virtual networks in the same region is the same as the
latency within a single virtual network. The network throughput is based on the bandwidth that's allowed for
the virtual machine, proportionate to its size. There isn't any additional restriction on bandwidth within the
peering.
The traffic between virtual machines in peered virtual networks is routed directly through the Microsoft
backbone infrastructure, not through a gateway or over the public Internet.
You can apply network security groups in either virtual network to block access to other virtual networks or
subnets. When configuring virtual network peering, either open or close the network security group rules
between the virtual networks. If you open full connectivity between peered virtual networks, you can apply
network security groups to block or deny specific access. Full connectivity is the default option. To learn more
about network security groups, see Security groups.
Service chaining
Service chaining enables you to direct traffic from one virtual network to a virtual appliance or gateway in a
peered network through user-defined routes.
To enable service chaining, configure user-defined routes that point to virtual machines in peered virtual
networks as the next hop IP address. User-defined routes could also point to virtual network gateways to
enable service chaining.
You can deploy hub-and-spoke networks, where the hub virtual network hosts infrastructure components such
as a network virtual appliance or VPN gateway. All the spoke virtual networks can then peer with the hub
virtual network. Traffic flows through network virtual appliances or VPN gateways in the hub virtual network.
Virtual network peering enables the next hop in a user-defined route to be the IP address of a virtual machine
in the peered virtual network, or a VPN gateway. You can't route between virtual networks with a user-defined
route that specifies an Azure ExpressRoute gateway as the next hop type. To learn more about user-defined
routes, see User-defined routes overview. To learn how to create a hub and spoke network topology, see Hub-
spoke network topology in Azure.
Both virtual network peering and global virtual network peering support gateway transit.
Gateway transit between virtual networks created through different deployment models is supported. The
gateway must be in the virtual network in the Resource Manager model. To learn more about using a gateway
for transit, see Configure a VPN gateway for transit in a virtual network peering.
When you peer virtual networks that share a single Azure ExpressRoute connection, the traffic between them
goes through the peering relationship. That traffic uses the Azure backbone network. You can still use local
gateways in each virtual network to connect to the on-premises circuit. Otherwise, you can use a shared
gateway and configure transit for on-premises connectivity.
Troubleshoot
To confirm that virtual networks are peered, you can check effective routes. Check routes for a network
interface in any subnet in a virtual network. If a virtual network peering exists, all subnets within the virtual
network have routes with next hop type VNet peering, for each address space in each peered virtual network.
For more information, see Diagnose a virtual machine routing problem.
You can also troubleshoot connectivity to a virtual machine in a peered virtual network using Azure Network
Watcher. A connectivity check lets you see how traffic is routed from a source virtual machine's network
interface to a destination virtual machine's network interface. For more information, see Troubleshoot
connections with Azure Network Watcher using the Azure portal.
You can also try the Troubleshoot virtual network peering issues.
Permissions
To learn about permissions required to create a virtual network peering, see Permissions.
Pricing
There's a nominal charge for ingress and egress traffic that uses a virtual network peering connection. For
more information, see Virtual Network pricing.
Gateway Transit is a peering property that enables a virtual network to utilize a VPN/ExpressRoute gateway in a
peered virtual network. Gateway transit works for both cross premises and network-to-network connectivity.
Traffic to the gateway (ingress or egress) in the peered virtual network incurs virtual network peering charges
on the spoke VNet (or non-gateway VNet). For more information, see VPN Gateway pricing for VPN gateway
charges and ExpressRoute Gateway pricing for ExpressRoute gateway charges.
NOTE
A previous version of this document stated that virtual network peering charges would not apply on the spoke VNet (or
non-gateway VNet) with Gateway Transit. It now reflects accurate pricing per the pricing page.
Next steps
You can create a peering between two virtual networks. The networks can belong to the same
subscription, different deployment models in the same subscription, or different subscriptions. Complete
a tutorial for one of the following scenarios:
A Z URE DEP LO Y M EN T M O DEL SUB SC RIP T IO N
Different
Different
To learn how to create a hub and spoke network topology, see Hub-spoke network topology in Azure.
To learn about all virtual network peering settings, see Create, change, or delete a virtual network
peering.
For answers to common virtual network peering and global virtual network peering questions, see VNet
Peering.
Virtual Network service endpoints
11/2/2020 • 11 minutes to read • Edit Online
Virtual Network (VNet) service endpoint provides secure and direct connectivity to Azure services over an
optimized route over the Azure backbone network. Endpoints allow you to secure your critical Azure service
resources to only your virtual networks. Service Endpoints enables private IP addresses in the VNet to reach the
endpoint of an Azure service without needing a public IP address on the VNet.
This feature is available for the following Azure services and regions. The Microsoft.* resource is in parenthesis.
Enable this resource from the subnet side while configuring service endpoints for your service:
Generally available
Azure Storage (Microsoft.Storage): Generally available in all Azure regions.
Azure SQL Database (Microsoft.Sql): Generally available in all Azure regions.
Azure Synapse Analytics (Microsoft.Sql): Generally available in all Azure regions.
Azure Database for PostgreSQL ser ver (Microsoft.Sql): Generally available in Azure regions where
database service is available.
Azure Database for MySQL ser ver (Microsoft.Sql): Generally available in Azure regions where database
service is available.
Azure Database for MariaDB (Microsoft.Sql): Generally available in Azure regions where database service
is available.
Azure Cosmos DB (Microsoft.AzureCosmosDB): Generally available in all Azure regions.
Azure Key Vault (Microsoft.KeyVault): Generally available in all Azure regions.
Azure Ser vice Bus (Microsoft.ServiceBus): Generally available in all Azure regions.
Azure Event Hubs (Microsoft.EventHub): Generally available in all Azure regions.
Azure Data Lake Store Gen 1 (Microsoft.AzureActiveDirectory): Generally available in all Azure regions
where ADLS Gen1 is available.
Azure App Ser vice (Microsoft.Web): Generally available in all Azure regions where App service is available.
Azure Cognitive Ser vices (Microsoft.CognitiveServices): Generally available in all Azure regions where
Cognitive services are available.
Public Preview
Azure Container Registr y (Microsoft.ContainerRegistry): Preview available in limited Azure regions where
Azure Container Registry is available.
For the most up-to-date notifications, check the Azure Virtual Network updates page.
Key benefits
Service endpoints provide the following benefits:
Improved security for your Azure ser vice resources : VNet private address spaces can overlap. You
can't use overlapping spaces to uniquely identify traffic that originates from your VNet. Service endpoints
provide the ability to secure Azure service resources to your virtual network by extending VNet identity to
the service. Once you enable service endpoints in your virtual network, you can add a virtual network rule
to secure the Azure service resources to your virtual network. The rule addition provides improved
security by fully removing public internet access to resources and allowing traffic only from your virtual
network.
Optimal routing for Azure ser vice traffic from your vir tual network : Today, any routes in your
virtual network that force internet traffic to your on-premises and/or virtual appliances also force Azure
service traffic to take the same route as the internet traffic. Service endpoints provide optimal routing for
Azure traffic.
Endpoints always take service traffic directly from your virtual network to the service on the Microsoft
Azure backbone network. Keeping traffic on the Azure backbone network allows you to continue auditing
and monitoring outbound Internet traffic from your virtual networks, through forced-tunneling, without
impacting service traffic. For more information about user-defined routes and forced-tunneling, see Azure
virtual network traffic routing.
Simple to set up with less management overhead : You no longer need reserved, public IP addresses
in your virtual networks to secure Azure resources through IP firewall. There are no Network Address
Translation (NAT) or gateway devices required to set up the service endpoints. You can configure service
endpoints through a simple click on a subnet. There's no additional overhead to maintaining the
endpoints.
Limitations
The feature is available only to virtual networks deployed through the Azure Resource Manager deployment
model.
Endpoints are enabled on subnets configured in Azure virtual networks. Endpoints can't be used for traffic
from your premises to Azure services. For more information, see Secure Azure service access from on-
premises
For Azure SQL, a service endpoint applies only to Azure service traffic within a virtual network's region. For
Azure Storage, endpoints also extend to include paired regions where you deploy the virtual network to
support Read-Access Geo-Redundant Storage (RA-GRS) and Geo-Redundant Storage (GRS) traffic. For more
information, see Azure paired regions.
For Azure Data Lake Storage (ADLS) Gen 1, the VNet Integration capability is only available for virtual
networks within the same region. Also note that virtual network integration for ADLS Gen1 uses the virtual
network service endpoint security between your virtual network and Azure Active Directory (Azure AD) to
generate additional security claims in the access token. These claims are then used to authenticate your
virtual network to your Data Lake Storage Gen1 account and allow access. The
Microsoft.AzureActiveDirectory tag listed under services supporting service endpoints is used only for
supporting service endpoints to ADLS Gen 1. Azure AD doesn't support service endpoints natively. For more
information about Azure Data Lake Store Gen 1 VNet integration, see Network security in Azure Data Lake
Storage Gen1.
NOTE
Service endpoint routes override any BGP or UDR routes for the address prefix match of an Azure service. For more
information, see troubleshooting with effective routes.
Provisioning
Service endpoints can be configured on virtual networks independently by a user with write access to a virtual
network. To secure Azure service resources to a VNet, the user must have permission to
Microsoft.Network/virtualNetworks/subnets/joinViaServiceEndpoint/action for the added subnets. The built-in
service administrator roles include this permission by default. You can modify the permission by creating custom
roles.
For more information about built-in roles, see Azure built-in roles. For more information about assigning specific
permissions to custom roles, see Azure custom roles.
Virtual networks and Azure service resources can be in the same or different subscriptions. If the virtual network
and Azure service resources are in different subscriptions, the resources must be under the same Active
Directory (AD) tenant.
FAQs
For FAQs, see Virtual Network Service Endpoint FAQs.
Next steps
Configure virtual network service endpoints
Secure an Azure Storage account to a virtual network
Secure an Azure SQL Database to a virtual network
Secure an Azure Synapse Analytics to a virtual network
Azure service integration in virtual networks
Virtual Network Service Endpoint Policies
Azure Resource Manager template
Deploy dedicated Azure services into virtual
networks
11/2/2020 • 2 minutes to read • Edit Online
When you deploy dedicated Azure services in a virtual network, you can communicate with the service resources
privately, through private IP addresses.
1 'Dedicated' implies that only service specific resources can be deployed in this subnet and cannot be combined
Public IP addresses allow Internet resources to communicate inbound to Azure resources. Public IP addresses
enable Azure resources to communicate to Internet and public-facing Azure services. The address is dedicated to
the resource, until it's unassigned by you. A resource without a public IP assigned can communicate outbound.
Azure dynamically assigns an available IP address that isn't dedicated to the resource. For more information about
outbound connections in Azure, see Understand outbound connections.
In Azure Resource Manager, a public IP address is a resource that has its own properties. Some of the resources you
can associate a public IP address resource with:
Virtual machine network interfaces
Internet-facing load balancers
VPN gateways
Application gateways
Azure Firewall
IP address version
Public IP addresses are created with an IPv4 or IPv6 address.
SKU
To learn about SKU upgrade, refer to Public IP upgrade.
Public IP addresses are created with one of the following SKUs:
IMPORTANT
Matching SKUs are required for load balancer and public IP resources. You can't have a mixture of basic SKU resources and
standard SKU resources. You can't attach standalone virtual machines, virtual machines in an availability set resource, or a
virtual machine scale set resources to both SKUs simultaneously. New designs should consider using Standard SKU resources.
Please review Standard Load Balancer for details.
Standard
Standard SKU public IP addresses:
Always use static allocation method.
Have an adjustable inbound originated flow idle timeout of 4-30 minutes, with a default of 4 minutes, and fixed
outbound originated flow idle timeout of 4 minutes.
Secure by default and closed to inbound traffic. Allow list inbound traffic with a network security group.
Assigned to network interfaces, standard public load balancers, or Application Gateways. For more information
about Standard load balancer, see Azure Standard Load Balancer.
Can be zone-redundant or zonal (can be created zonal and guaranteed in a specific availability zone). To learn
more about availability zones, see Availability zones overview and Standard Load Balancer and Availability
Zones.
NOTE
Inbound communication with a Standard SKU resource fails until you create and associate a network security group and
explicitly allow the desired inbound traffic.
NOTE
Only Public IP addresses with basic SKU are available when using instance metadata service IMDS. Standard SKU is not
supported.
Basic
All public IP addresses created before the introduction of SKUs are Basic SKU public IP addresses.
With the introduction of SKUs, specify which SKU you would like the public IP address to be.
Basic SKU addresses:
Assigned with the static or dynamic allocation method.
Have an adjustable inbound originated flow idle timeout of 4-30 minutes, with a default of 4 minutes, and fixed
outbound originated flow idle timeout of 4 minutes.
Are open by default. Network security groups are recommended but optional for restricting inbound or
outbound traffic.
Assigned to any Azure resource that can be assigned a public IP address, such as:
Network interfaces
VPN Gateways
Application Gateways
Public load balancers
Don't support Availability Zone scenarios. Use Standard SKU public IP for Availability Zone scenarios. To learn
more about availability zones, see Availability zones overview and Standard Load Balancer and Availability
Zones.
Allocation method
Basic and standard public IPs support static assignment. The resource is assigned an IP address at the time it's
created. The IP address is released when the resource is deleted.
Basic SKU public IP addresses support a dynamic assignment. Dynamic is the default assignment method. The IP
address isn't given to the resource at the time of creation when selecting dynamic.
The IP is assigned when you associate the public IP address resource with a:
Virtual machine
The first virtual machine is associated with the backend pool of a load balancer.
The IP address is released when you stop (or delete) the resource.
For example, a public IP resource is released from a resource named Resource A . Resource A receives a different
IP on start-up if the public IP resource is reassigned.
The IP address is released when the allocation method is changed from static to dynamic . To ensure the IP
address for the associated resource remains the same, set the allocation method explicitly to static . A static IP
address is assigned immediately.
NOTE
Even when you set the allocation method to static, you cannot specify the actual IP address assigned to the public IP
address resource. Azure assigns the IP address from a pool of available IP addresses in the Azure location the resource is
created in.
NOTE
Azure allocates public IP addresses from a range unique to each region in each Azure cloud. You can download the list of
ranges (prefixes) for the Azure Public, US government, China, and Germany clouds.
IMPORTANT
Each domain name label created must be unique within its Azure location.
DNS Recommendations
If a region move is needed, you can't migrate the FQDN of your public IP. Use the FQDN to create a custom CNAME
record pointing to the public IP address.
If a move to a different public IP is required, update the CNAME record instead of updating the FQDN.
You can use Azure DNS or an external DNS provider for your DNS Record.
Virtual machines
You can associate a public IP address with a Windows or Linux virtual machine by assigning it to its network
interface .
Choose dynamic or static for the public IP address. Learn more about assigning IP addresses to network
interfaces.
Internet-facing load balancers
You can associate a public IP address of either SKU with an Azure Load Balancer, by assigning it to the load balancer
frontend configuration. The public IP serves as a load-balanced IP.
You can assign either a dynamic or a static public IP address to a load balancer front end. You can assign multiple
public IP addresses to a load balancer front end. This configuration enables multi-VIP scenarios like a multi-tenant
environment with TLS-based websites.
For more information about Azure load balancer SKUs, see Azure load balancer standard SKU.
VPN gateways
Azure VPN Gateway connects an Azure virtual network to:
Azure virtual networks
On-premises network(s).
A public IP address is assigned to the VPN Gateway to enable communication with the remote network. You can
only assign a dynamic basic public IP address to a VPN gateway.
Application gateways
You can associate a public IP address with an Azure Application Gateway, by assigning it to the gateway's frontend
configuration.
Assign a dynamic basic public IP to an application gateway V1 front-end configuration.
Assign a static standard SKU address to a V2 front-end configuration.
Azure Firewall
Azure Firewall allows you to create, enforce, and log application and network connectivity policies across
subscriptions and virtual networks.
You can only associate static standard public IP addresses with a firewall. This allows outside firewalls to identify
traffic originating from your virtual network.
At-a-glance
The following table shows the property through which a public IP can be associated to a top-level resource and the
possible allocation methods.
Application gateway Front-end configuration Yes (V1 only) Yes (V2 only)
Pricing
Public IP addresses may have a nominal charge. To learn more about IP address pricing in Azure, review the IP
address pricing page.
Next steps
Learn about Private IP Addresses in Azure
Deploy a VM with a static public IP using the Azure portal
Private IP addresses
11/2/2020 • 3 minutes to read • Edit Online
Allocation method
Azure assigns private IP addresses to resources from the address range of the virtual network subnet where the
resource is.
Azure reserves the first four addresses in each subnet address range. The addresses can't be assigned to resources.
For example, if the subnet's address range is 10.0.0.0/16, addresses 10.0.0.0-10.0.0.3 and 10.0.255.255 are
unavailable. IP addresses within the subnet's address range can only be assigned to one resource at a time.
There are two methods in which a private IP address is given:
Dynamic : Azure assigns the next available unassigned or unreserved IP address in the subnet's address
range. For example, Azure assigns 10.0.0.10 to a new resource, if addresses 10.0.0.4-10.0.0.9 are already
assigned to other resources.
Dynamic is the default allocation method. Once assigned, dynamic IP addresses are released if a network
interface is:
Deleted
Reassigned to a different subnet within the same virtual network.
The allocation method is changed to static, and a different IP address is specified.
By default, Azure assigns the previous dynamically assigned address as the static address when you change
the allocation method from dynamic to static.
Static : You select and assign any unassigned or unreserved IP address in the subnet's address range.
For example, a subnet's address range is 10.0.0.0/16 and addresses 10.0.0.4-10.0.0.9 are assigned to other
resources. You can assign any address between 10.0.0.10 - 10.0.255.254. Static addresses are only released if
a network interface is deleted.
Azure assigns the static IP as the dynamic IP when the allocation method is changed. The reassignment
occurs even if the address isn't the next available in the subnet. The address changes when the network
interface is assigned to a different subnet.
To assign the network interface to a different subnet, you change the allocation method from static to
dynamic. Assign the network interface to a different subnet, then change the allocation method back to
static. Assign an IP address from the new subnet's address range.
Virtual machines
One or more private IP addresses are assigned to one or more network interfaces . The network interfaces are
assigned to a Windows or Linux virtual machine. You can specify the allocation method as either dynamic or static
for each private IP address.
Internal DNS hostname resolution (for virtual machines)
Azure virtual machines are configured with Azure-managed DNS servers by default. You can explicitly configure
custom DNS servers. These DNS servers provide internal name resolution for virtual machines that are within the
same virtual network.
A mapping for the hostname to a virtual machine's private IP address is added to the Azure-managed DNS servers.
A hostname is mapped to the primary IP of the main network interface when a VM has:
Multiple network interfaces
Multiple IP addresses
Both
VMs configured with Azure-managed DNS resolve the hostnames within the same virtual network. Use a custom
DNS server to resolve host names of VMs in connected virtual networks.
At-a-glance
The following table shows the property through which a private IP can be associated to a resource.
The possible allocation methods that can be used are also displayed:
Dynamic
Static
Limits
The limits on IP addressing are found in the full set of limits for networking in Azure. The limits are per region and
per subscription. Contact support to increase the default limits up to the maximum limits based on your business
needs.
Next steps
Learn about Public IP Addresses in Azure
Deploy a VM with a static private IP address using the Azure portal
Public IP address prefix
11/2/2020 • 4 minutes to read • Edit Online
A public IP address prefix is a reserved range of IP addresses in Azure. Azure gives a contiguous range of
addresses to your subscription based on how many you specify.
If you're not familiar with public addresses, see Public IP addresses.
Public IP addresses are assigned from a pool of addresses in each Azure region. You can download the list of
ranges Azure uses for each region. For example, 40.121.0.0/16 is one of over 100 ranges Azure uses in the East US
region. The range includes the usable addresses of 40.121.0.1 - 40.121.255.254.
You create a public IP address prefix in an Azure region and subscription by specifying a name, and how many
addresses you want the prefix to include.
Public IP address ranges are assigned with a prefix of your choosing. If you create a prefix of /28, Azure gives 16 ip
addresses from one of its ranges.
You don't know which range Azure will assign until you create the range, but the addresses are contiguous.
Public IP address prefixes have a fee, for more information, see public IP address pricing.
Benefits
Creation of public IP address resources from a known range.
Firewall rule configuration with ranges that include public IP addresses you've currently assigned, and
addresses you haven't assigned yet. This configuration eliminates the need to change firewall rules as you
assign IP addresses to new resources.
The default size of a range you can create is /28 or 16 IP addresses.
There aren't limits as to how many ranges you can create. There are limits on the maximum number of static
public IP addresses you can have in an Azure subscription. The number of ranges you create can't encompass
more static public IP addresses than you can have in your subscription. For more information, see Azure limits.
The addresses that you create using addresses from the prefix can be assigned to any Azure resource that you
can assign a public IP address to.
You can easily see which IP addresses that are given and not given within the range.
Scenarios
You can associate the following resources to a static public IP address from a prefix:
RESO URC E SC EN A RIO ST EP S
Virtual machines Associating public IPs from a prefix to To associate IPs from a prefix to your
your virtual machines in Azure reduces virtual machine:
management overhead when adding IP 1. Create a prefix.
addresses to an allow list in the firewall. 2. Create an IP from the prefix.
You can add an entire prefix with a 3. Associate the IP to your virtual
single firewall rule. As you scale with machine's network interface.
virtual machines in Azure, you can You can also associate the IPs to a
associate IPs from the same prefix Virtual Machine Scale Set.
saving cost, time, and management
overhead.
Standard load balancers Associating public IPs from a prefix to To associate IPs from a prefix to your
your frontend IP configuration or load balancer:
outbound rule of a load balancer 1. Create a prefix.
ensures simplification of your Azure 2. Create an IP from the prefix.
public IP address space. Simplify your 3. When creating the load balancer,
scenario by grooming outbound select or update the IP created in step 2
connections from a range of contiguous above as the frontend IP of your load
IP addresses. balancer.
Azure Firewall You can use a public IP from a prefix for To associate an IP from a prefix to your
outbound SNAT. All outbound virtual firewall:
network traffic is translated to the 1. Create a prefix.
Azure Firewall public IP. 2. Create an IP from the prefix.
3. When you deploy the Azure firewall,
be sure to select the IP you previously
gave from the prefix.
Application Gateway v2 You can use a public IP from a prefix for To associate an IP from a prefix to your
your autoscaling and zone-redundant gateway:
Application gateway v2. 1. Create a prefix.
2. Create an IP from the prefix.
3. When you deploy the Application
Gateway, be sure to select the IP you
previously gave from the prefix.
Constraints
You can't specify the IP addresses for the prefix. Azure gives the IP addresses for the prefix, based on the size
that you specify.
You can create a prefix of up to 16 IP addresses or a /28 by default. Review Network limits increase requests
and Azure limits for more information.
You can't change the range, once you've created the prefix.
Only static public IP addresses created with the Standard SKU can be assigned from the prefix's range. To learn
more about public IP address SKUs, see public IP address.
Addresses from the range can only be assigned to Azure Resource Manager resources. Addresses can't be
assigned to resources in the classic deployment model.
All public IP addresses created from the prefix must exist in the same Azure region and subscription as the
prefix. Addresses must be assigned to resources in the same region and subscription.
You can't delete a prefix if any addresses within it are assigned to public IP address resources associated to a
resource. Dissociate all public IP address resources that are assigned IP addresses from the prefix first.
Next steps
Create a public IP address prefix
What is IPv6 for Azure Virtual Network?
11/2/2020 • 5 minutes to read • Edit Online
IPv6 for Azure Virtual Network (VNet) enables you to host applications in Azure with IPv6 and IPv4 connectivity
both within a virtual network and to and from the Internet. Due to the exhaustion of public IPv4 addresses, new
networks for mobility and Internet of Things (IoT) are often built on IPv6. Even long established ISP and mobile
networks are being transformed to IPv6. IPv4-only services can find themselves at a real disadvantage in both
existing and emerging markets. Dual stack IPv4/IPv6 connectivity enables Azure-hosted services to traverse this
technology gap with globally available, dual-stacked services that readily connect with both the existing IPv4 and
these new IPv6 devices and networks.
Azure's original IPv6 connectivity makes it easy to provide dual stack (IPv4/IPv6) Internet connectivity for
applications hosted in Azure. It allows for simple deployment of VMs with load balanced IPv6 connectivity for
both inbound and outbound initiated connections. This feature is still available and more information is available
here. IPv6 for Azure virtual network is much more full featured- enabling full IPv6 solution architectures to be
deployed in Azure.
The following diagram depicts a simple dual stack (IPv4/IPv6) deployment in Azure:
Benefits
IPv6 for Azure VNET benefits:
Helps expand the reach of your Azure-hosted applications into the growing mobile and Internet of Things
markets.
Dual stacked IPv4/IPv6 VMs provide maximum service deployment flexibility. A single service instance can
connect with both IPv4 and IPv6-capable Internet clients.
Builds on long-established, stable Azure VM-to-Internet IPv6 connectivity.
Secure by default since IPv6 connectivity to the Internet is only established when you explicitly request it in
your deployment.
Capabilities
IPv6 for Azure VNet includes the following capabilities:
Azure customers can define their own IPv6 virtual network address space to meet the needs of their
applications, customers, or seamlessly integrate into their on-premises IP space.
Dual stack (IPv4 and IPv6) virtual networks with dual stack subnets enable applications to connect with both
IPv4 and IPv6 resources in their virtual network or - the Internet.
IMPORTANT
The subnets for IPv6 must be exactly /64 in size. This ensures future compatibility should you decide to enable
routing of the subnet to an on-premises network since some routers can only accept /64 IPv6 routes.
Protect your resources with IPv6 rules for Network Security Groups.
And the Azure platform's Distributed Denial of Service (DDoS) protections are extended to Internet-
facing Public IP's
Customize the routing of IPv6 traffic in your virtual network with User-Defined Routes- especially when
leveraging Network Virtual Appliances to augment your application.
Linux and Windows Virtual Machines can all use IPv6 for Azure VNET
Standard IPv6 public Load Balancer support to create resilient, scalable applications, which include:
Optional IPv6 health probe to determine which backend pool instances are health and thus can receive
new flows.
Optional outbound rules which provide full declarative control over outbound connectivity to scale and
tune this ability to your specific needs.
Optional multiple front-end configurations which enable a single load balancer to use multiple IPv6
public IP addresses- the same frontend protocol and port can be reused across frontend addresses.
Optional IPv6 ports can be reused on backend instances using the Floating IP feature of load-balancing
rules
Note: Load balancing does not perform any protocol translation (no NAT64).
Note: IPv6 can be load balanced only to the primary network interface (NIC) on Azure VMs.
Standard IPv6 internal Load Balancer support to create resilient multi-tier applications within Azure VNETs.
Basic IPv6 public Load Balancer support for compatibility with legacy deployments
Reserved IPv6 Public IP addresses and address ranges provide stable, predictable IPv6 addresses which ease
filtering of your azure-hosted applications for your company and your customers.
Instance-level Public IP provides IPv6 Internet connectivity directly to individual VMs.
Add IPv6 to Existing IPv4-only deployments- this feature enables you to easily add IPv6 connectivity to existing
IPv4-only deployments without the need to recreate deployments. The IPv4 network traffic is unaffected
during this process so depending on your application and OS you may be able to add IPv6 even to live
services.
Let Internet clients seamlessly access your dual stack application using their protocol of choice with Azure DNS
support for IPv6 (AAAA) records.
Create dual stack applications that automatically scale to your load with virtual machine scale sets with IPv6.
Virtual Network (VNET) Peering - both within-regional and global peering - enables you to seemlessly connect
dual stack VNETs- both the IPv4 and IPv6 endpoints on VMs in the peered networks will be able to
communicate with each other. You can even peer dual stack with IPv4-only VNETs as you are transitioning your
deployments to dual stack.
IPv6 Troubleshooting and Diagnostics are available with load balancer metrics/alerting and Network Watcher
features such as packet capture, NSG flow logs, connection troubleshooting and connection monitoring.
Scope
IPv6 for Azure VNET is a foundational feature set which enables customers to host dual stack (IPv4+IPv6)
applications in Azure. We intend to add IPv6 support to more Azure networking features over time and eventually
to offer dual stack versions of Azure PaaS services but in the meantime all Azure PaaS services can be accessed
via the IPv4 endpoints on dual stack Virtual Machines.
Limitations
The current IPv6 for Azure virtual network release has the following limitations:
IPv6 for Azure virtual network is available in all global Azure Commercial and US Government regions using
all deployment methods.
ExpressRoute gateways CAN be used for IPv4-only traffic in a VNET with IPv6 enabled. Support for IPv6 traffic
is on our roadmap.
VPN gateways CANNOT be used in a VNET with IPv6 enabled, either directly or peered with
"UseRemoteGateway".
The Azure platform (AKS, etc.) does not support IPv6 communication for Containers.
IPv6 can be load balanced only to the primary network interface (NIC) on Azure VMs. Load balancing IPv6
traffic to secondary NICs is not supported.
IPv6-only Virtual Machines or Virtual Machines Scale Sets are not supported, each NIC must include at least
one IPv4 IP configuration.
When adding IPv6 to existing IPv4 deployments, IPv6 ranges can not be added to a VNET with existing
resource navigation links.
Forward DNS for IPv6 is supported for Azure public DNS today but Reverse DNS is not yet supported.
Pricing
IPv6 Azure resources and bandwidth are charged at the same rates as IPv4. There are no additional or different
charges for IPv6. You can find details about pricing for public IP addresses, network bandwidth, or Load Balancer.
Next steps
Learn how to deploy an IPv6 dual stack application using Azure PowerShell.
Learn how to deploy an IPv6 dual stack application using Azure CLI.
Learn how to deploy an IPv6 dual stack application using Resource Manager Templates (JSON)
Reserved public IPv6 address prefix
11/2/2020 • 2 minutes to read • Edit Online
In Azure, dual stack (IPv4+IPv6) virtual networks (VNet) and virtual machines (VMs) are secure by default since
they have no Internet connectivity. You can easily add an IPv6 Internet connectivity to your Azure Load Balancers
and VMs with public IPv6 addresses that you obtain from Azure.
Any public IPs that you reserve are associated with an Azure region of your choice and with your Azure
subscription. You may move a reserved (static) IPv6 public IP between any of the Azure Load Balancers or VMs in
your subscription. You may dissociate the IPv6 public IP entirely and it will be held for your use when you're ready.
WARNING
Use caution to not delete your public IP addresses accidentally. Deleting a public IP removes it from your subscription and
you will not be able to recover it (not even with the help of Azure support).
In addition to reserving individual IPv6 addresses, you can reserve contiguous ranges of Azure IPv6 addresses
(known as IP prefix) for your use. Similar to individual IP addresses, reserved prefixes are associated with an Azure
region of your choice and with your Azure subscription. Reserving a predictable, contiguous range of addresses
has many uses. For example, you can greatly simplify IP filtering of your Azure-hosted applications by your
company and your customers as your static IP ranges can be readily programmed into on-premises firewalls. You
can create individual public IPs from your IP prefix as needed and when you delete those individual Public IPs they
are returned to your reserved range so that you can reuse them later. All the IP addresses in your IP Prefix are
reserved for your exclusive use until such time as you delete your Prefix.
Pricing
For costs associated with using Azure Public IPs, both individual IP addresses and IP ranges, see Public IP Address
pricing.
Limitations
IPv6 is supported on Basic Public IPs only with "dynamic" allocation that means that the IPv6 address will change if
you delete and redeploy your application (VM's or load balancers) in Azure. Standard IPv6 Public IP's support solely
static (reserved) allocation though Standard INTERNAL load balancers can also support dynamic allocation from
within the subnet to which they are assigned.
As a best practice, we recommend that you use Standard Public IPs and Standard Load Balancers for your IPv6
applications.
Next steps
Reserve a public IPv6 address prefix.
Learn more about IPv6 addresses.
Learn about how to create and use public IPs (both IPv4 and IPv6) in Azure.
What is routing preference (preview)?
11/2/2020 • 4 minutes to read • Edit Online
Azure routing preference enables you to choose how your traffic routes between Azure and the Internet. You can
choose to route traffic either via the Microsoft network, or, via the ISP network (public internet). These options are
also referred to as cold potato routing and hot potato routing respectively. Egress data transfer price varies based
on the routing selection. You can choose the routing option while creating a public IP address. The public IP
address can be associated with resources such as virtual machine, virtual machine scale sets, internet-facing load
balancer, etc. You can also set the routing preference for Azure storage resources such as blobs, files, web, and
Azure DataLake. By default, traffic is routed via the Microsoft global network for all Azure services.
IMPORTANT
Routing preference is currently in public preview. This preview version is provided without a service level agreement, and it's
not recommended for production workloads. Certain features might not be supported or might have constrained
capabilities. For more information, see Supplemental Terms of Use for Microsoft Azure Previews.
Ingress traffic: The global BGP Anycast announcement ensures ingress traffic enters Microsoft network closest to
the user. For example, if a user from Singapore accesses Azure resources hosted in Chicago, USA then traffic is
entered into Microsoft global network in Singapore Edge POP and travels on Microsoft network to the service
hosted in Chicago.
Egress traffic: The egress traffic follows the same principle. Traffic travels majority of its journey on Microsoft
global network and exits closest to the user. For example, if traffic from Azure Chicago is destined to a user from
Singapore, then traffic travels on Microsoft network from Chicago to Singapore, and exits the Microsoft network in
Singapore Edge POP.
Both ingress and egress traffic stays bulk of the travel on the Microsoft global network. This is also known as cold
potato routing.
Supported services
Public IP with Routing preference choice “Microsoft Global Network” can be associated with any Azure services.
However, Public IP with Routing preference choice Internet can be associated with the following Azure resources:
Virtual machine
Virtual machine scale set
Azure Kubernetes Service (AKS)
Internet-facing load balancer
Application Gateway
Azure Firewall
For storage, primary endpoints always use the Microsoft global network . You can enable secondary endpoints
with Internet as your choice for traffic routing. Supported storage services are:
Blobs
Files
Web
Azure DataLake
Pricing
The price difference between both options is reflected in the internet egress data transfer pricing. Routing via
Microsoft global network data transfer price is same as current internet egress price. Visit Azure bandwidth
pricing page for the latest pricing information. Routing via Public Internet is priced lower as shown in the table
below:
Availability
Routing Preference support is available in the following regions for services such as virtual machine and internet-
facing load balancer that use a public IP for internet egress - North Europe, West Europe, France South, UK South,
East US, North Central US, South Central US, West US, West Central US, Southeast Asia, Germany West Central,
Switzerland West, Japan East, and Japan West.
Routing Preference support for storage account is available in the following Azure regions - North Central US,
West Central US, South Central US, East US, West US, North Europe, France South, Germany West Central,
Switzerland West, South East Asia, Japan East, and Japan West.
Limitations
Routing preference is only compatible with standard SKU of public IP address. Basic SKU of public IP address is
not supported.
Routing preference currently supports only IPv4 public IP addresses. IPv6 public IP addresses are not
supported.
Virtual machines with multiple NICs can have only one type of routing preference.
Next steps
Configure routing preference for a VM using the Azure PowerShell
Configure routing preference for a VM using the Azure CLI
Azure security baseline for Azure Public IP
11/2/2020 • 12 minutes to read • Edit Online
This security baseline applies guidance from the Azure Security Benchmark version 1.0 to Azure Public IP. The Azure
Security Benchmark provides recommendations on how you can secure your cloud solutions on Azure. The content
is grouped by the security controls defined by the Azure Security Benchmark and the related guidance applicable
to Azure Public IP. Controls not applicable to Azure Public IP have been excluded. Note Azure Public IPs do not
store customer data.
To see how Azure Public IP completely maps to the Azure Security Benchmark, see the full Azure Public IP security
baseline mapping file.
Network security
For more information, see the Azure Security Benchmark: Network security.
1.10: Document traffic configuration rules
Guidance : Azure Public IPs can be assigned tags. Use resource tags for network security groups and other
resources related to network security. Use any of the built-in Azure Policy definitions related to tagging, such as
"Require tag and its value" that ensure that all resources are created with tags and to notify you of existing
untagged resources.
Azure PowerShell or Azure CLI can be used to look up or perform actions on resources based on their tags.
How to create and use tags
How to create an Azure Virtual Network
How to filter network traffic with network security group rules
Azure Security Center monitoring : Not applicable
Responsibility : Customer
Secure configuration
For more information, see the Azure Security Benchmark: Secure configuration.
7.1: Establish secure configurations for all Azure resources
Guidance : Define and implement standard security configurations for Azure Public IP with Azure Policy. Use Azure
Policy aliases in the "Microsoft.Network" namespace to create custom policies to audit or enforce the network
configuration of your Azure Public IP instances. You may also make use of built-in policy definitions.
How to configure and manage Azure Policy
How to create a custom policy with policy aliases
Azure Security Center monitoring : Not applicable
Responsibility : Customer
7.3: Maintain secure Azure resource configurations
Guidance : Use Azure Policy [deny] and [deploy if not exist] to enforce secure settings across your Azure resources.
How to configure and manage Azure Policy
Understand Azure Policy Effects
Azure Security Center monitoring : Not applicable
Responsibility : Customer
7.5: Securely store configuration of Azure resources
Guidance : If using custom Azure Policy definitions, use Azure DevOps or Azure Repos to securely store and
manage your code.
How to store code in Azure DevOps
Azure Repos Documentation
Azure Security Center monitoring : Not applicable
Responsibility : Customer
7.7: Deploy configuration management tools for Azure resources
Guidance : Define and implement standard security configurations for Azure Public IP with Azure Policy. Use Azure
Policy aliases in the "Microsoft.Network" namespace to create custom policies to audit or enforce the network
configuration of your Azure Public IP instances.
How to configure and manage Azure Policy
How to create a custom policy with policy aliases
Azure Security Center monitoring : Not applicable
Responsibility : Customer
7.9: Implement automated configuration monitoring for Azure resources
Guidance : Use built-in Azure Policy definitions as well as Azure Policy aliases in the "Microsoft.Network"
namespace to create custom Azure Policy definitions to alert, audit, and enforce system configurations. Use Azure
Policy [audit], [deny], and [deploy if not exist] to automatically enforce configurations for your Azure resources.
How to configure and manage Azure Policy
Azure Security Center monitoring : Not applicable
Responsibility : Customer
Incident response
For more information, see the Azure Security Benchmark: Incident response.
10.1: Create an incident response guide
Guidance : Build out an incident response guide for your organization. Ensure that there are written incident
response plans that define all roles of personnel as well as phases of incident handling/management from
detection to post-incident review.
How to configure Workflow Automation within Azure Security Center
Guidance on building your own security incident response process
Microsoft Security Response Center's Anatomy of an Incident
Customers may also use NIST's Computer Security Incident Handling Guide to aid in the creation of their
own incident response plan
Azure Security Center monitoring : Not applicable
Responsibility : Customer
10.2: Create an incident scoring and prioritization procedure
Guidance : Security Center assigns a severity to each alert to help you prioritize which alerts should be investigated
first. The severity is based on how confident Security Center is in the finding or the analytic used to issue the alert
as well as the confidence level that there was malicious intent behind the activity that led to the alert.
Additionally, clearly mark subscriptions (for ex. production, non-prod) and create a naming system to clearly
identify and categorize Azure resources.
Security alerts in Azure Security Center
Use tags to organize your Azure resources
Azure Security Center monitoring : Yes
Responsibility : Customer
10.3: Test security response procedures
Guidance : Conduct exercises to test your systems’ incident response capabilities on a regular cadence. Identify
weak points and gaps and revise plan as needed.
Refer to NIST's publication: Guide to Test, Training, and Exercise Programs for IT Plans and Capabilities
Azure Security Center monitoring : Not applicable
Responsibility : Customer
10.4: Provide security incident contact details and configure alert notifications for security incidents
Guidance : Security incident contact information will be used by Microsoft to contact you if the Microsoft Security
Response Center (MSRC) discovers that the customer's data has been accessed by an unlawful or unauthorized
party. Review incidents after the fact to ensure that issues are resolved.
How to set the Azure Security Center Security Contact
Azure Security Center monitoring : Not applicable
Responsibility : Customer
10.5: Incorporate security alerts into your incident response system
Guidance : Export your Security Center alerts and recommendations using the Continuous Export feature.
Continuous Export allows you to export alerts and recommendations either manually or in an ongoing, continuous
fashion. You may use the Azure Security Center data connector to stream the alerts Sentinel.
How to configure continuous export
How to stream alerts into Azure Sentinel
Azure Security Center monitoring : Not applicable
Responsibility : Customer
10.6: Automate the response to security alerts
Guidance : Use the Workflow Automation feature in Azure Security Center to automatically trigger responses via
"Logic Apps" on security alerts and recommendations.
How to configure Workflow Automation and Logic Apps
Azure Security Center monitoring : Not applicable
Responsibility : Customer
Next steps
See the Azure security benchmark
Learn more about Azure security baselines
Azure security baseline for Virtual Network
11/2/2020 • 23 minutes to read • Edit Online
This security baseline applies guidance from the Azure Security Benchmark version 1.0 to Azure Virtual Network.
The Azure Security Benchmark provides recommendations on how you can secure your cloud solutions on Azure.
The content is grouped by the security controls defined by the Azure Security Benchmark and the related
guidance applicable to Azure Virtual Network. Controls not applicable to Azure Virtual Network have been
excluded.
To see how Azure Virtual Network completely maps to the Azure Security Benchmark, see the full Azure Virtual
Network security baseline mapping file.
Network security
For more information, see the Azure Security Benchmark: Network security.
1.2: Monitor and log the configuration and traffic of virtual networks, subnets, and network interfaces
Guidance : Use Security Center and follow network protection recommendations to help secure your network
resources in Azure.
Send network security group flow logs to a Log Analytics Workspace and use Traffic Analytics to provide insights
into traffic flow into your Azure cloud. Traffic Analytics offers the ability to visualize network activity and identify hot
spots, identify security threats, understand traffic flow patterns, and pinpoint network misconfigurations.
Use Azure Monitor logs to provide insights into your environment. A workspace should be used to collate and
analyze the data, and can integrate with other Azure services such as Application Insights and Security Center.
Choose resource logs to send to an Azure storage account or an event hub. A different platform can also be used to
analyze the logs.
How to Enable NSG Flow Logs
How to Enable and use Traffic Analytics
Understand Network Security provided by Security Center
Azure Security Center monitoring : Yes
Responsibility : Customer
1.4: Deny communications with known-malicious IP addresses
Guidance : Enable distributed denial of service (DDoS) Standard protection on your Azure Virtual Network to guard
against DDoS attacks.
Deploy Azure Firewall at each of the organization's network boundaries with threat intelligence-based filtering
enabled and configured to "Alert and deny" for malicious network traffic.
Use Security Center's threat protection features to detect communications with known malicious IP addresses.
Apply Security Center's Adaptive Network Hardening recommendations for network security group configurations
that limit ports and source IPs based on actual traffic and threat intelligence.
Manage Azure DDoS Protection Standard using the Azure portal
Azure Firewall threat intelligence-based filtering
Threat protection in Security Center
Adaptive Network Hardening in Azure Security Center
Azure Security Center monitoring : Yes
Responsibility : Customer
1.5: Record network packets
Guidance : Use VPN Gateway's packet capture in addition to commonly available packet capture tools to record
network packets.
You can also review agent based or NVA solutions that provide Terminal Access Point (TAP) or Network Visibility
functionality through Packet Broker partner solutions available in Azure Marketplace Offerings.
Configure packet captures for VPN gateways
Network Virtual Appliance Partner
Azure Security Center monitoring : Yes
Responsibility : Customer
1.6: Deploy network-based intrusion detection/intrusion prevention systems (IDS/IPS )
Guidance : Use an Azure Firewall deployed on your virtual network with Threat Intelligence enabled. Use Azure
Firewall Threat intelligence-based filtering to alert or to deny traffic to and from known malicious IP addresses and
domains. The IP addresses and domains are sourced from the Microsoft Threat Intelligence feed.
You can also select an appropriate offer from the Azure Marketplace that supports IDS/IPS functionality with
payload inspection capabilities.
Deploy the firewall solution of your choice at each of your organization's network boundaries to detect and/or deny
malicious traffic.
How to deploy Azure Firewall
How to configure alerts with Azure Firewall
Azure Marketplace
Azure Security Center monitoring : Currently not available
Responsibility : Customer
1.8: Minimize complexity and administrative overhead of network security rules
Guidance : Use Virtual Network service tags to define network access controls on network security groups or
Azure Firewall. Service tags can be used in place of specific IP addresses when creating security rules. Allow or deny
the traffic for the corresponding service by specifying the service tag name (for example, ApiManagement) in the
appropriate source or destination field of a rule. Microsoft manages the address prefixes encompassed by the
service tag and automatically updates the service tag as addresses change.
Use Application Security Groups to help simplify complex security configuration. Application security groups allow
you to configure network security as a natural extension of an application's structure. This enables you to group
virtual machines and define network security policies based on those groups.
Understand and use Service tags
Understand and use Application Security Groups
Azure Security Center monitoring : Currently not available
Responsibility : Customer
1.9: Maintain standard security configurations for network devices
Guidance : Define and implement standard security configurations for network resources with Azure Policy and
review the built-in network policy definitions for implementation.
Refer to the default policy for Security Center which contains available security recommendations related to your
virtual networks.
Use Azure Blueprints to simplify large-scale Azure deployments by packaging key environment artifacts, such as
Azure Resource Manager templates, Azure role-based access control (Azure RBAC) assignments, and policies, in a
single blueprint definition. Azure Blueprint can be applied to new subscriptions for fine-tuned control and
management through versioning.
How to configure and manage Azure Policy
Azure Policy samples for networking
How to create an Azure Blueprint
Enable monitoring in Azure Security Center
Azure Security Center monitoring : Not applicable
Responsibility : Customer
1.10: Document traffic configuration rules
Guidance : Use tags for network security groups and other resources related to network security and traffic flow.
Use the "Description" field to specify business need, duration, and other information for any rules that allow traffic
to/from a network for individual network security group rules. Use any of the built-in Azure Policy definitions
related to tagging, such as "Require tag and its value" to ensure that all resources are created with tags and to notify
you of existing untagged resources.
Choose Azure PowerShell or Azure CLI to look up or perform actions on resources based on their tags.
How to create and use Tags
How to create a Virtual Network
How to create an NSG with a Security Config
Azure Security Center monitoring : Not applicable
Responsibility : Customer
1.11: Use automated tools to monitor network resource configurations and detect changes
Guidance : Use Azure Activity Log to monitor resource configurations and detect changes to your virtual network.
Create alerts within Azure Monitor which will trigger when changes to critical resources take place.
How to view and retrieve Azure Activity Log events
How to create alerts in Azure Monitor
Azure Security Center monitoring : Currently not available
Responsibility : Customer
Data protection
For more information, see the Azure Security Benchmark: Data protection.
4.4: Encrypt all sensitive information in transit
Guidance : Encrypt all sensitive information in transit. Ensure that any clients connecting to your Azure resources in
your virtual networks are able to negotiate TLS 1.2 or greater. Follow Security Center recommendations for
encryption at rest and encryption in transit.
Microsoft provides several options which can be utilized by customers for securing data in transit internally within
the Azure network and externally across the Internet to the end user. These include communication through Virtual
Private Networks (utilizing IPsec/IKE encryption), Transport Layer Security (TLS) 1.2 or later (via Azure components
such as Application Gateway or Azure Front Door), protocols directly on the Azure virtual machines (such as
Windows IPsec or SMB), and more.
Additionally, "encryption by default" using MACsec (an IEEE standard at the data-link layer) is enabled for all Azure
traffic traveling between Azure datacenters to ensure confidentiality and integrity of customer data.
Understand encryption in transit with Azure
Azure Security Center monitoring : Yes
Responsibility : Shared
4.6: Use Azure RBAC to manage access to resources
Guidance : Use Azure role-based access control (Azure RBAC) to manage access to data and resources. Otherwise
use service-specific access-control methods.
Choose built-in roles like Owner, Contributor, or Network contributor and assign the role to the appropriate scope.
For example, you can assign a subset of virtual network capabilities with the specific permissions required for
virtual networks to any of these roles.
How to configure Azure RBAC
Plan virtual networks
Review the Azure built-in roles
Azure Security Center monitoring : Currently not available
Responsibility : Customer
4.9: Log and alert on changes to critical Azure resources
Guidance : Use Azure Monitor with the Azure Activity Logs to create alerts for when changes take place to critical
Azure resources like Virtual Networks and network security groups.
Diagnostic logging for a network security group
How to create alerts for Azure Activity Log events
Azure Security Center monitoring : Currently not available
Responsibility : Customer
Secure configuration
For more information, see the Azure Security Benchmark: Secure configuration.
7.1: Establish secure configurations for all Azure resources
Guidance : Use Azure Policy aliases to create custom policies to audit or enforce the configuration of your Azure
network resources and also use built-in Azure Policy definitions.
Export any of your build templates with Azure Resource Manager in JavaScript Object Notation (JSON) form and
review it to ensure that the configurations meet or exceed the security requirements for your organization.
Implement recommendations from Security Center as a secure configuration baseline for your Azure resources.
How to view available Azure Policy Aliases
Tutorial: Create and manage policies to enforce compliance
Azure policy sample built-ins for virtual network
Single and multi-resource export to a template in Azure portal
Security recommendations - a reference guide
Azure Security Center monitoring : Not applicable
Responsibility : Customer
7.3: Maintain secure Azure resource configurations
Guidance : Use Azure Resource Manager templates and Azure Policies to securely configure Azure resources
associated with the Virtual network and related resources. Azure Resource Manager templates are JSON (JavaScript
Object Notation) based files used to deploy virtual machines along with Azure resources. Microsoft performs the
maintenance on the base templates.
Use Azure Policy [deny] and [deploy if not exist] effects to enforce secure settings across your Azure resources.
Information on creating Azure Resource Manager templates
How to configure and manage Azure Policy
Understanding Azure Policy Effects
Azure Resource Manager template samples for virtual network
Azure policy sample built-ins for virtual network
Azure Security Center monitoring : Not applicable
Responsibility : Customer
7.5: Securely store configuration of Azure resources
Guidance : Use Azure DevOps to securely store and manage your code like custom Azure policies, Azure Resource
Manager templates, desired state configuration scripts. and so on.
You must have permissions to access the resources you wish to manage in Azure DevOps, such as your code,
builds, and work tracking. Most permissions are granted through built-in security groups. You can grant or deny
permissions to specific users, built-in security groups, or groups defined in Azure Active Directory (Azure AD) if
integrated with Azure DevOps, or Active Directory if integrated with Team Foundation Server.
How to store code in Azure DevOps
About permissions and groups in Azure DevOps
Azure Security Center monitoring : Not applicable
Responsibility : Customer
7.7: Deploy configuration management tools for Azure resources
Guidance : Define and implement standard security configurations for Azure resources using Azure Policy. Use
Azure Policy aliases to create custom policies to audit or enforce the network configuration of your Azure resources
and any built-in policy definitions related to specific resources.
How to configure and manage Azure Policy
How to use Aliases
Azure policy sample built-ins for virtual network
Azure Security Center monitoring : Not applicable
Responsibility : Customer
7.9: Implement automated configuration monitoring for Azure resources
Guidance : Use Security Center to perform baseline scans for your Azure Virtual Network and related resources.
Use Azure Policy to alert and audit Azure resource configurations.
How to remediate recommendations in Security Center
How to configure and manage Azure Policy
Azure policy sample built-ins for virtual network
Azure Security Center monitoring : Not applicable
Responsibility : Customer
7.11: Manage Azure secrets securely
Guidance : Use Managed Service Identity in conjunction with Azure Key Vault to simplify and secure secret
management for your Azure resources hosted in an Azure Virtual Network.
How to integrate with Azure Managed Identities
How to create a Key Vault
How to provide Key Vault authentication with a managed identity
Azure Security Center monitoring : Not applicable
Responsibility : Customer
7.13: Eliminate unintended credential exposure
Guidance : Implement Credential Scanner to identify credentials within code. Credential Scanner will also
encourage moving discovered credentials to more secure locations such as Azure Key Vault.
How to setup Credential Scanner
Azure Security Center monitoring : Currently not available
Responsibility : Customer
Data recovery
For more information, see the Azure Security Benchmark: Data recovery.
9.1: Ensure regular automated back-ups
Guidance : Use Azure Resource Manager to deploy a virtual network and related resources. Azure Resource
Manager provides ability to export templates which can be used as backups to restore Virtual network and related
resources. Use Azure Automation to call the Azure Resource Manager template export API on a regular basis.
Overview of Azure Resource Manager
Azure Resource Manager template samples for virtual network
Single and multi-resource export to a template in Azure portal
Resource Groups - Export Template
Introduction to Azure Automation
Azure Security Center monitoring : Currently not available
Responsibility : Customer
9.2: Perform complete system backups and backup any customer-managed keys
Guidance : Use Azure Resource Manager to deploy a virtual network and related resources. Azure Resource
Manager provides ability to export templates which can be used as backups to restore Virtual network and related
resources. Use Azure Automation to call the Azure Resource Manager template export API on a regular basis. Back
up customer-managed keys within Azure Key Vault.
Overview of Azure Resource Manager
Azure Resource Manager template samples for virtual network
Single and multi-resource export to a template in Azure portal
Resource Groups - Export Template
Introduction to Azure Automation
How to backup key vault keys in Azure
Azure Security Center monitoring : Yes
Responsibility : Customer
9.3: Validate all backups including customer-managed keys
Guidance : Periodically perform deployment of Azure Resource Manager templates to an isolated subscription and
test restoration of backed up customer-managed keys.
Deploy resources with ARM templates and Azure portal
Azure Security Center monitoring : Yes
Responsibility : Customer
9.4: Ensure protection of backups and customer-managed keys
Guidance : Use Azure DevOps to securely store and manage your code like custom Azure Policy definitions and
Azure Resource Manager templates.
Grant or deny permissions to specific users, built-in security groups, or groups defined in Azure Active Directory
(Azure AD) if integrated with Azure DevOps, or Active Directory if integrated with Team Foundation Server.
Use Azure role-based access control (Azure RBAC) to protect customer-managed keys.
Enable Soft-Delete and purge protection in Key Vault to protect keys against accidental or malicious deletion.
How to store code in Azure DevOps
About permissions and groups in Azure DevOps
How to enable Soft-Delete and Purge protection in Key Vault
Soft delete for Azure Storage blobs
Azure Security Center monitoring : Not applicable
Responsibility : Customer
Incident response
For more information, see the Azure Security Benchmark: Incident response.
10.1: Create an incident response guide
Guidance : Build out an incident response guide for your organization. Ensure that there are written incident
response plans that define all roles of personnel as well as phases of incident handling/management from
detection to post-incident review.
Guidance on building your own security incident response process
Microsoft Security Response Center's Anatomy of an Incident
Leverage NIST's Computer Security Incident Handling Guide to aid in the creation of your own incident
response plan
Azure Security Center monitoring : Yes
Responsibility : Customer
10.2: Create an incident scoring and prioritization procedure
Guidance : Security Center assigns a severity to each alert to help you prioritize which alerts should be investigated
first. The severity is based on how confident Security Center is in the finding or the analytic used to issue the alert
as well as the confidence level that there was malicious intent behind the activity that led to the alert.
Clearly mark subscriptions (for example, production or non-production) using tags and create a naming system to
clearly identify and categorize Azure resources, especially those processing sensitive data. It is your responsibility to
prioritize the remediation of alerts based on the criticality of the Azure resources and environment where the
incident occurred.
Security alerts in Security Center
Use tags to organize your Azure resources
Azure Security Center monitoring : Yes
Responsibility : Customer
10.3: Test security response procedures
Guidance : Conduct exercises to test your systems’ incident response capabilities on a regular cadence to help
protect your Azure resources. Identify weak points and gaps and revise plan as needed.
NIST's publication - Guide to Test, Training, and Exercise Programs for IT Plans and Capabilities
Azure Security Center monitoring : Not applicable
Responsibility : Customer
10.4: Provide security incident contact details and configure alert notifications for security incidents
Guidance : Security incident contact information will be used by Microsoft to contact you if the Microsoft Security
Response Center (MSRC) discovers that your data has been accessed by an unlawful or unauthorized party. Review
incidents after the fact to ensure that issues are resolved.
How to set the Security Center Security Contact
Azure Security Center monitoring : Yes
Responsibility : Customer
10.5: Incorporate security alerts into your incident response system
Guidance : Export your Security Center alerts and recommendations using the Continuous Export feature to help
identify risks to Azure resources. Continuous Export allows you to export alerts and recommendations either
manually or in an ongoing, continuous fashion.
You can also use the Security Center data connector to stream the alerts to Azure Sentinel.
How to configure continuous export
How to stream alerts into Azure Sentinel
Azure Security Center monitoring : Yes
Responsibility : Customer
10.6: Automate the response to security alerts
Guidance : Use the Workflow Automation feature in Security Center to automatically trigger responses via "Logic
Apps" on security alerts and recommendations to protect your Azure resources.
How to configure Workflow Automation and Logic Apps
Azure Security Center monitoring : Not applicable
Responsibility : Customer
Next steps
See the Azure security benchmark
Learn more about Azure security baselines
Network security groups
11/2/2020 • 9 minutes to read • Edit Online
You can use an Azure network security group to filter network traffic to and from Azure resources in an Azure
virtual network. A network security group contains security rules that allow or deny inbound network traffic to, or
outbound network traffic from, several types of Azure resources. For each rule, you can specify source and
destination, port, and protocol.
This article describes properties of a network security group rule, the default security rules that are applied, and the
rule properties that you can modify to create an augmented security rule.
Security rules
A network security group contains zero, or as many rules as desired, within Azure subscription limits. Each rule
specifies the following properties:
P RO P ERT Y EXP L A N AT IO N
Port range You can specify an individual or range of ports. For example,
you could specify 80 or 10000-10005. Specifying ranges
enables you to create fewer security rules. Augmented security
rules can only be created in network security groups created
through the Resource Manager deployment model. You
cannot specify multiple ports or port ranges in the same
security rule in network security groups created through the
classic deployment model.
Network security group security rules are evaluated by priority using the 5-tuple information (source, source port,
destination, destination port, and protocol) to allow or deny the traffic. You may not create two security rules with
the same priority and direction. A flow record is created for existing connections. Communication is allowed or
denied based on the connection state of the flow record. The flow record allows a network security group to be
stateful. If you specify an outbound security rule to any address over port 80, for example, it's not necessary to
specify an inbound security rule for the response to the outbound traffic. You only need to specify an inbound
security rule if communication is initiated externally. The opposite is also true. If inbound traffic is allowed over a
port, it's not necessary to specify an outbound security rule to respond to traffic over the port.
Existing connections may not be interrupted when you remove a security rule that enabled the flow. Traffic flows
are interrupted when connections are stopped and no traffic is flowing in either direction, for at least a few minutes.
There are limits to the number of security rules you can create in a network security group. For details, see Azure
limits.
Default security rules
Azure creates the following default rules in each network security group that you create:
Inbound
A l l o w VN et In Bo u n d
SO URC E DEST IN AT IO N
P RIO RIT Y SO URC E P O RT S DEST IN AT IO N P O RT S P ROTO C O L A C C ESS
A l l o w A z u r eLo ad Bal an c er In Bo u n d
SO URC E DEST IN AT IO N
P RIO RIT Y SO URC E P O RT S DEST IN AT IO N P O RT S P ROTO C O L A C C ESS
Den y A l l In b o u n d
SO URC E DEST IN AT IO N
P RIO RIT Y SO URC E P O RT S DEST IN AT IO N P O RT S P ROTO C O L A C C ESS
Outbound
A l l o w Vn e t O u t B o u n d
SO URC E DEST IN AT IO N
P RIO RIT Y SO URC E P O RT S DEST IN AT IO N P O RT S P ROTO C O L A C C ESS
A l l o w In t er n et O u t Bo u n d
SO URC E DEST IN AT IO N
P RIO RIT Y SO URC E P O RT S DEST IN AT IO N P O RT S P ROTO C O L A C C ESS
Den y A l l O u t Bo u n d
SO URC E DEST IN AT IO N
P RIO RIT Y SO URC E P O RT S DEST IN AT IO N P O RT S P ROTO C O L A C C ESS
In the Source and Destination columns, VirtualNetwork, AzureLoadBalancer, and Internet are service tags, rather
than IP addresses. In the protocol column, Any encompasses TCP, UDP, and ICMP. When creating a rule, you can
specify TCP, UDP, ICMP or Any. 0.0.0.0/0 in the Source and Destination columns represents all addresses. Clients
like Azure portal, Azure CLI, or PowerShell can use * or any for this expression.
You cannot remove the default rules, but you can override them by creating rules with higher priorities.
Augmented security rules
Augmented security rules simplify security definition for virtual networks, allowing you to define larger and
complex network security policies, with fewer rules. You can combine multiple ports and multiple explicit IP
addresses and ranges into a single, easily understood security rule. Use augmented rules in the source, destination,
and port fields of a rule. To simplify maintenance of your security rule definition, combine augmented security rules
with service tags or application security groups. There are limits to the number of addresses, ranges, and ports that
you can specify in a rule. For details, see Azure limits.
Service tags
A service tag represents a group of IP address prefixes from a given Azure service. It helps to minimize the
complexity of frequent updates on network security rules.
For more information, see Azure service tags. For an example on how to use the Storage service tag to restrict
network access, see Restrict network access to PaaS resources.
Application security groups
Application security groups enable you to configure network security as a natural extension of an application's
structure, allowing you to group virtual machines and define network security policies based on those groups. You
can reuse your security policy at scale without manual maintenance of explicit IP addresses. To learn more, see
Application security groups.
Next steps
To learn about which Azure resources can be deployed into a virtual network and have network security groups
associated to them, see Virtual network integration for Azure services
To learn how traffic is evaluated with network security groups, see How network security groups work.
If you've never created a network security group, you can complete a quick tutorial to get some experience
creating one.
If you're familiar with network security groups and need to manage them, see Manage a network security group.
If you're having communication problems and need to troubleshoot network security groups, see Diagnose a
virtual machine network traffic filter problem.
Learn how to enable network security group flow logs to analyze network traffic to and from resources that
have an associated network security group.
How network security groups filter network traffic
11/2/2020 • 5 minutes to read • Edit Online
You can use an Azure network security group to filter network traffic to and from Azure resources in an Azure
virtual network. A network security group contains security rules that allow or deny inbound network traffic to, or
outbound network traffic from, several types of Azure resources. For each rule, you can specify source and
destination, port, and protocol.
You can deploy resources from several Azure services into an Azure virtual network. For a complete list, see
Services that can be deployed into a virtual network. You can associate zero, or one, network security group to each
virtual network subnet and network interface in a virtual machine. The same network security group can be
associated to as many subnets and network interfaces as you choose.
The following picture illustrates different scenarios for how network security groups might be deployed to allow
network traffic to and from the internet over TCP port 80:
Reference the previous picture, along with the following text, to understand how Azure processes inbound and
outbound rules for network security groups:
Inbound traffic
For inbound traffic, Azure processes the rules in a network security group associated to a subnet first, if there is
one, and then the rules in a network security group associated to the network interface, if there is one.
VM1 : The security rules in NSG1 are processed, since it is associated to Subnet1 and VM1 is in Subnet1. Unless
you've created a rule that allows port 80 inbound, the traffic is denied by the DenyAllInbound default security
rule, and never evaluated by NSG2, since NSG2 is associated to the network interface. If NSG1 has a security
rule that allows port 80, the traffic is then processed by NSG2. To allow port 80 to the virtual machine, both
NSG1 and NSG2 must have a rule that allows port 80 from the internet.
VM2 : The rules in NSG1 are processed because VM2 is also in Subnet1. Since VM2 does not have a network
security group associated to its network interface, it receives all traffic allowed through NSG1 or is denied all
traffic denied by NSG1. Traffic is either allowed or denied to all resources in the same subnet when a network
security group is associated to a subnet.
VM3 : Since there is no network security group associated to Subnet2, traffic is allowed into the subnet and
processed by NSG2, because NSG2 is associated to the network interface attached to VM3.
VM4 : Traffic is allowed to VM4, because a network security group isn't associated to Subnet3, or the network
interface in the virtual machine. All network traffic is allowed through a subnet and network interface if they
don't have a network security group associated to them.
Outbound traffic
For outbound traffic, Azure processes the rules in a network security group associated to a network interface first, if
there is one, and then the rules in a network security group associated to the subnet, if there is one.
VM1 : The security rules in NSG2 are processed. Unless you create a security rule that denies port 80 outbound
to the internet, the traffic is allowed by the AllowInternetOutbound default security rule in both NSG1 and
NSG2. If NSG2 has a security rule that denies port 80, the traffic is denied, and never evaluated by NSG1. To
deny port 80 from the virtual machine, either, or both of the network security groups must have a rule that
denies port 80 to the internet.
VM2 : All traffic is sent through the network interface to the subnet, since the network interface attached to VM2
does not have a network security group associated to it. The rules in NSG1 are processed.
VM3 : If NSG2 has a security rule that denies port 80, the traffic is denied. If NSG2 has a security rule that allows
port 80, then port 80 is allowed outbound to the internet, since a network security group is not associated to
Subnet2.
VM4 : All network traffic is allowed from VM4, because a network security group isn't associated to the network
interface attached to the virtual machine, or to Subnet3.
Intra-Subnet traffic
It's important to note that security rules in an NSG associated to a subnet can affect connectivity between VM's
within it. For example, if a rule is added to NSG1 which denies all inbound and outbound traffic, VM1 and VM2 will
no longer be able to communicate with each other. Another rule would have to be added specifically to allow this.
You can easily view the aggregate rules applied to a network interface by viewing the effective security rules for a
network interface. You can also use the IP flow verify capability in Azure Network Watcher to determine whether
communication is allowed to or from a network interface. IP flow verify tells you whether a communication is
allowed or denied, and which network security rule allows or denies the traffic.
NOTE
Network security groups are associated to subnets or to virtual machines and cloud services deployed in the classic
deployment model, and to subnets or network interfaces in the Resource Manager deployment model. To learn more about
Azure deployment models, see Understand Azure deployment models.
TIP
Unless you have a specific reason to, we recommend that you associate a network security group to a subnet, or a network
interface, but not both. Since rules in a network security group associated to a subnet can conflict with rules in a network
security group associated to a network interface, you can have unexpected communication problems that require
troubleshooting.
Next steps
To learn about which Azure resources can be deployed into a virtual network and have network security groups
associated to them, see Virtual network integration for Azure services.
If you've never created a network security group, you can complete a quick tutorial to get some experience
creating one.
If you're familiar with network security groups and need to manage them, see Manage a network security
group.
If you're having communication problems and need to troubleshoot network security groups, see Diagnose a
virtual machine network traffic filter problem.
Learn how to enable network security group flow logs to analyze network traffic to and from resources that
have an associated network security group.
Application security groups
11/2/2020 • 3 minutes to read • Edit Online
Application security groups enable you to configure network security as a natural extension of an application's
structure, allowing you to group virtual machines and define network security policies based on those groups. You
can reuse your security policy at scale without manual maintenance of explicit IP addresses. The platform handles
the complexity of explicit IP addresses and multiple rule sets, allowing you to focus on your business logic. To better
understand application security groups, consider the following example:
In the previous picture, NIC1 and NIC2 are members of the AsgWeb application security group. NIC3 is a member
of the AsgLogic application security group. NIC4 is a member of the AsgDb application security group. Though
each network interface in this example is a member of only one network security group, a network interface can be
a member of multiple application security groups, up to the Azure limits. None of the network interfaces have an
associated network security group. NSG1 is associated to both subnets and contains the following rules:
Allow-HTTP-Inbound-Internet
This rule is needed to allow traffic from the internet to the web servers. Because inbound traffic from the internet is
denied by the DenyAllInbound default security rule, no additional rule is needed for the AsgLogic or AsgDb
application security groups.
SO URC E DEST IN AT IO N
P RIO RIT Y SO URC E P O RT S DEST IN AT IO N P O RT S P ROTO C O L A C C ESS
Deny-Database-All
Because the AllowVNetInBound default security rule allows all communication between resources in the same
virtual network, this rule is needed to deny traffic from all resources.
SO URC E DEST IN AT IO N
P RIO RIT Y SO URC E P O RT S DEST IN AT IO N P O RT S P ROTO C O L A C C ESS
Allow-Database-BusinessLogic
This rule allows traffic from the AsgLogic application security group to the AsgDb application security group. The
priority for this rule is higher than the priority for the Deny-Database-All rule. As a result, this rule is processed
before the Deny-Database-All rule, so traffic from the AsgLogic application security group is allowed, whereas all
other traffic is blocked.
SO URC E DEST IN AT IO N
P RIO RIT Y SO URC E P O RT S DEST IN AT IO N P O RT S P ROTO C O L A C C ESS
The rules that specify an application security group as the source or destination are only applied to the network
interfaces that are members of the application security group. If the network interface is not a member of an
application security group, the rule is not applied to the network interface, even though the network security group
is associated to the subnet.
Application security groups have the following constraints:
There are limits to the number of application security groups you can have in a subscription, as well as other
limits related to application security groups. For details, see Azure limits.
You can specify one application security group as the source and destination in a security rule. You cannot
specify multiple application security groups in the source or destination.
All network interfaces assigned to an application security group have to exist in the same virtual network that
the first network interface assigned to the application security group is in. For example, if the first network
interface assigned to an application security group named AsgWeb is in the virtual network named VNet1, then
all subsequent network interfaces assigned to ASGWeb must exist in VNet1. You cannot add network interfaces
from different virtual networks to the same application security group.
If you specify an application security group as the source and destination in a security rule, the network
interfaces in both application security groups must exist in the same virtual network. For example, if AsgLogic
contained network interfaces from VNet1, and AsgDb contained network interfaces from VNet2, you could not
assign AsgLogic as the source and AsgDb as the destination in a rule. All network interfaces for both the source
and destination application security groups need to exist in the same virtual network.
TIP
To minimize the number of security rules you need, and the need to change the rules, plan out the application security
groups you need and create rules using service tags or application security groups, rather than individual IP addresses, or
ranges of IP addresses, whenever possible.
Next steps
Learn how to Create a network security group.
Virtual network service tags
11/11/2020 • 9 minutes to read • Edit Online
A service tag represents a group of IP address prefixes from a given Azure service. Microsoft manages the address
prefixes encompassed by the service tag and automatically updates the service tag as addresses change,
minimizing the complexity of frequent updates to network security rules.
You can use service tags to define network access controls on network security groups or Azure Firewall. Use
service tags in place of specific IP addresses when you create security rules. By specifying the service tag name,
such as ApiManagement , in the appropriate
source or destination field of a rule, you can allow or deny the traffic for the corresponding service.
You can use service tags to achieve network isolation and protect your Azure resources from the general Internet
while accessing Azure services that have public endpoints. Create inbound/outbound network security group
rules to deny traffic to/from Internet and allow traffic to/from AzureCloud or other available service tags of
specific Azure services.
NOTE
In the classic deployment model (before Azure Resource Manager), a subset of the tags listed in the previous table are
supported. These tags are spelled differently:
CL ASSI C SP EL L I NG E Q U I VA L E N T R E S O U R C E M A N A G E R TA G
AZURE_LOADBALANCER AzureLoadBalancer
INTERNET Internet
VIRTUAL_NETWORK VirtualNetwork
NOTE
Service tags of Azure services denote the address prefixes from the specific cloud being used. For example, the underlying IP
ranges that correspond to the Sql tag value on the Azure Public cloud will be different from the underlying ranges on the
Azure China cloud.
NOTE
If you implement a virtual network service endpoint for a service, such as Azure Storage or Azure SQL Database, Azure adds
a route to a virtual network subnet for the service. The address prefixes in the route are the same address prefixes, or CIDR
ranges, as those of the corresponding service tag.
NOTE
While it's in public preview, the Discovery API might return information that's less current than information returned by the
JSON downloads. (See the next section.)
NOTE
A subset of this information has been published in XML files for Azure Public, Azure China, and Azure Germany. These XML
downloads will be deprecated by June 30, 2020 and will no longer be available after that date. You should migrate to using
the Discovery API or JSON file downloads as described in the previous sections.
Tips
You can detect updates from one publication to the next by noting increased changeNumber values in the
JSON file. Each subsection (for example, Storage.WestUS ) has its own changeNumber that's incremented as
changes occur. The top level of the file's changeNumber is incremented when any of the subsections is
changed.
For examples of how to parse the service tag information (for example, get all address ranges for Storage in
WestUS), see the Service Tag Discovery API PowerShell documentation.
Next steps
Learn how to create a network security group.
Virtual network service endpoint policies for Azure
Storage
11/2/2020 • 6 minutes to read • Edit Online
Virtual Network (VNet) service endpoint policies allow you to filter egress virtual network traffic to Azure Storage accounts
over service endpoint, and allow data exfiltration to only specific Azure Storage accounts. Endpoint policies provide granular
access control for virtual network traffic to Azure Storage when connecting over service endpoint.
This feature is generally available for Azure Storage in all global Azure regions .
Key benefits
Virtual network service endpoint policies provide following benefits:
Improved security for your Vir tual Network traffic to Azure Storage
Azure service tags for network security groups allow you to restrict virtual network outbound traffic to specific Azure
Storage regions. However, this allows traffic to any account within selected Azure Storage region.
Endpoint policies allow you to specify the Azure Storage accounts that are allowed virtual network outbound access
and restricts access to all the other storage accounts. This gives much more granular security control for protecting
data exfiltration from your virtual network.
Scalable, highly available policies to filter Azure ser vice traffic
Endpoint policies provide horizontally scalable, highly available solution to filter Azure service traffic from virtual
networks, over service endpoints. No additional overhead is required to maintain central network appliances for this
traffic in your virtual networks.
"/subscriptions/subscriptionID/resourceGroups/MySEPDeployment/providers/Microsoft.Storage/storageAccounts/mystgacc"
],
"type": "Microsoft.Network/serviceEndpointPolicies/serviceEndpointPolicyDefinitions"
}
]
Configuration
You can configure the endpoint policies to restrict virtual network traffic to specific Azure Storage accounts.
Endpoint policy is configured on a subnet in a virtual network. Service endpoints for Azure Storage should be enabled
on the subnet to apply the policy.
Endpoint policy allows you to add specific Azure Storage accounts to allow list, using the resourceID format. You can
restrict access to
all storage accounts in a subscription
E.g. /subscriptions/subscriptionId
an individual storage account by listing the corresponding Azure Resource Manager resourceId. This covers
traffic to blobs, tables, queues, files and Azure Data Lake Storage Gen2.
E.g.
/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.Storage/storageAccounts/storageAccountName
By default, if no policies are attached to a subnet with endpoints, you can access all storage accounts in the service.
Once a policy is configured on that subnet, only the resources specified in the policy can be accessed from compute
instances in that subnet. Access to all other storage accounts will be denied.
When applying Service Endpoint policies on a subnet, the Azure Storage Service Endpoint scope gets upgraded from
regional to global . This means that all the traffic to Azure Storage is secured over service endpoint thereafter. The
Service endpoint policies are also applicable globally, so any storage accounts, that are not explicitly allowed, will be
denied access.
You can apply multiple policies to a subnet. When multiple policies are associated to the subnet, virtual network traffic
to resources specified across any of these policies will be allowed. Access to all other service resources, not specified
in any of the policies, will be denied.
NOTE
Service endpoint policies are allow policies , so apart from the specified resources, all other resources are restricted. Please
ensure that all service resource dependencies for your applications are identified and listed in the policy.
Only storage accounts using the Azure Resource Model can be specified in the endpoint policy. Your classic Azure
Storage accounts will not support Azure Service Endpoint Policies.
RA-GRS secondary access will be automatically allowed if the primary account is listed.
Storage accounts can be in the same or a different subscription or Azure Active Directory tenant as the virtual
network.
Scenarios
Peered, connected or multiple vir tual networks : To filter traffic in peered virtual networks, endpoint policies should
be applied individually to these virtual networks.
Filtering Internet traffic with Network Appliances or Azure Firewall : Filter Azure service traffic with policies, over
service endpoints, and filter rest of the Internet or Azure traffic via appliances or Azure Firewall.
Filtering traffic on Azure ser vices deployed into Vir tual Networks : At this time, Azure Service Endpoint Policies
are not supported for any managed Azure services that are deployed into your virtual network.
Filtering traffic to Azure ser vices from on-premises : Service endpoint policies only apply to the traffic from
subnets associated to the policies. To allow access to specific Azure service resources from on-premises, traffic should be
filtered using network virtual appliances or firewalls.
Provisioning
Service endpoint policies can be configured on subnets by a user with write access to a virtual network. Learn more about
Azure built-in roles and assigning specific permissions to custom roles.
Virtual networks and Azure Storage accounts can be in the same or different subscriptions, or Azure Active Directory tenants.
Limitations
You can only deploy service endpoint policies on virtual networks deployed through the Azure Resource Manager
deployment model.
Virtual networks must be in the same region as the service endpoint policy.
You can only apply service endpoint policy on a subnet if service endpoints are configured for the Azure services listed in
the policy.
You can't use service endpoint policies for traffic from your on-premises network to Azure services.
Azure managed services do not currently support Endpoint policies. This includes managed services deployed into the
shared subnets (e.g. Azure HDInsight, Azure Batch, Azure ADDS, Azure Application Gateway, Azure VPN Gateway, Azure
Firewall) or into the dedicated subnets (e.g. Azure App Service Environment, Azure Redis Cache, Azure API Management,
Azure SQL MI, classic managed services).
WARNING
Azure services deployed into your virtual network, such as Azure HDInsight, access other Azure services, such as Azure Storage, for
infrastructure requirements. Restricting endpoint policy to specific resources could break access to these infrastructure resources for the
Azure services deployed in your virtual network.
Classic storage accounts are not supported in endpoint policies. Policies will deny access to all classic storage accounts, by
default. If your application needs access to Azure Resource Manager and classic storage accounts, endpoint policies
should not be used for this traffic.
ServiceEndpointPoliciesPerSubscription 500
ServiceEndpointPoliciesPerSubnet 100
ServiceResourcesPerServiceEndpointPolicyDefinition 200
Next Steps
Learn how to configure virtual network service endpoint policies
Learn more about Virtual network Service Endpoints
Azure Kubernetes Network Policies overview
11/2/2020 • 7 minutes to read • Edit Online
Network Policies provides micro-segmentation for pods just like Network Security Groups (NSGs) provide micro-
segmentation for VMs. The Azure Network Policy Manager (also known as Azure NPM) implementation supports
the standard Kubernetes Network Policy specification. You can use labels to select a group of pods and define a list
of ingress and egress rules to filter traffic to and from these pods. Learn more about the Kubernetes network
policies in the Kubernetes documentation.
Azure NPM implementation works in conjunction with the Azure CNI that provides VNet integration for containers.
NPM is supported only on Linux today. The implementation enforces traffic filtering by configuring allow and deny
IP rules in Linux IPTables based on the defined policies. These rules are grouped together using Linux IPSets.
{
"apiVersion": "vlabs",
"properties": {
"orchestratorProfile": {
"orchestratorType": "Kubernetes",
"kubernetesConfig": {
"networkPolicy": "azure"
}
},
"masterProfile": {
"count": 1,
"dnsPrefix": "<specify a cluster name>",
"vmSize": "Standard_D2s_v3"
},
"agentPoolProfiles": [
{
"name": "agentpool",
"count": 2,
"vmSize": "Standard_D2s_v3",
"availabilityProfile": "AvailabilitySet"
}
],
"linuxProfile": {
"adminUsername": "<specify admin username>",
"ssh": {
"publicKeys": [
{
"keyData": "<cut and paste your ssh key here>"
}
]
}
},
"servicePrincipalProfile": {
"clientId": "<enter the client ID of your service principal here >",
"secret": "<enter the password of your service principal here>"
}
}
}
The solution is also open source and the code is available on the Azure Container Networking repository.
npm_add_ipset_exec_time runtime for adding an IPSet Summary quantile (0.5, 0.9, or 0.99)
The different quantile levels in "exec_time" metrics help you differentiate between the general and worst case
scenarios.
There's also an "exec_time_count" and "exec_time_sum" metric for each "exec_time" Summary metric.
The metrics can be scraped through Azure Monitor for Containers or through Prometheus.
Setup for Azure Monitor
The first step is to enable Azure Monitor for containers for your Kubernetes cluster. Steps can be found in Azure
Monitor for containers Overview. Once you have Azure Monitor for containers enabled, configure the Azure
Monitor for containers ConfigMap to enable NPM integration and collection of Prometheus NPM metrics. Azure
monitor for containers ConfigMap has an integrations section with settings to collect NPM metrics. These settings
are disabled by default in the ConfigMap. Enabling the basic setting collect_basic_metrics = true , will collect basic
NPM metrics. Enabling advanced setting collect_advanced_metrics = true will collect advanced metrics in addition
to basic metrics.
After editing the ConfigMap, save it locally and apply the ConfigMap to your cluster as follows.
Below is a snippet from the Azure monitor for containers
kubectl apply -f container-azm-ms-agentconfig.yaml
ConfigMap, which shows the NPM integration enabled with advanced metrics collection.
integrations: |-
[integrations.azure_network_policy_manager]
collect_basic_metrics = false
collect_advanced_metrics = true
Advanced metrics are optional, and turning them on will automatically turn on basic metrics collection. Advanced
metrics currently include only npm_ipset_counts
Learn more about Azure monitor for containers collection settings in config map
Visualization Options for Azure Monitor
Once NPM metrics collection is enabled, you can view the metrics in the Azure portal using Container Insights or in
Grafana.
Viewing in Azure portal under Insights for the cluster
Open Azure portal. Once in your cluster's Insights, navigate to "Workbooks" and open "Network Policy Manager
(NPM) Configuration".
Besides viewing the workbook (pictures below), you can also directly query the Prometheus metrics in "Logs"
under the Insights section. For example, this query will return all the metrics being collected. | where
TimeGenerated > ago(5h) | where Name contains "npm_"
You can also query Log Analytics directly for the metrics. Learn more about it with Getting Started with Log
Analytics Queries
Viewing in Grafana Dashboard
Set up your Grafana Server and configure a Log Analytics Data Source as described here. Then, import Grafana
Dashboard with a Log Analytics backend into your Grafana Labs.
The dashboard has visuals similar to the Azure Workbook. You can add panels to chart & visualize NPM metrics
from InsightsMetrics table.
Setup for Prometheus Server
Some users may choose to collect metrics with a Prometheus Server instead of Azure Monitor for containers. You
merely need to add two jobs to your scrape config to collect NPM metrics.
To install a simple Prometheus Server, add this helm repo on your cluster
You can also replace the azure-npm-node-metrics job with the content below or incorporate it into a pre-existing job
for Kubernetes pods:
- job_name: "azure-npm-node-metrics-from-pod-config"
metrics_path: /node-metrics
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels: [__meta_kubernetes_namespace]
regex: kube-system
action: keep
- source_labels: [__meta_kubernetes_pod_annotationpresent_azure_npm_scrapeable]
action: keep
- source_labels: [__address__]
action: replace
regex: ([^:]+)(?::\d+)?
replacement: "$1:10091"
target_label: __address__
CI IPSet Entries
CI Runtime Quantiles
Grafana Dashboard Summary Counts
Next steps
Learn about Azure Kubernetes Service.
Learn about container networking.
Deploy the plug-in for Kubernetes clusters or Docker containers.
Virtual network TAP
11/2/2020 • 2 minutes to read • Edit Online
IMPORTANT
Virtual network TAP Preview is currently on hold in all Azure regions. You can email us at azurevnettap@microsoft.com with
your subscription ID and we will notify you with future updates about the preview. In the interim, you can use agent based or
NVA solutions that provide TAP/Network Visibility functionality through our Packet Broker partner solutions available in Azure
Marketplace Offerings.
Azure virtual network TAP (Terminal Access Point) allows you to continuously stream your virtual machine network
traffic to a network packet collector or analytics tool. The collector or analytics tool is provided by a network virtual
appliance partner. For a list of partner solutions that are validated to work with virtual network TAP, see partner
solutions. The following picture shows how virtual network TAP works. You can add a TAP configuration on a
network interface that is attached to a virtual machine deployed in your virtual network. The destination is a virtual
network IP address in the same virtual network as the monitored network interface or a peered virtual network.
The collector solution for virtual network TAP can be deployed behind an Azure Internal Load balancer for high
availability.
Prerequisites
Before you create a virtual network TAP, you must have received a confirmation mail that you are enrolled in the
preview, and have one or more virtual machines created using Azure Resource Manager deployment model and a
partner solution for aggregating the TAP traffic in the same Azure region. If you don't have a partner solution in
your virtual network, see partner solutions to deploy one. You can use the same virtual network TAP resource to
aggregate traffic from multiple network interfaces in the same or different subscriptions. If the monitored network
interfaces are in different subscriptions, the subscriptions must be associated to the same Azure Active Directory
tenant. Additionally, the monitored network interfaces and the destination endpoint for aggregating the TAP traffic
can be in peered virtual networks in the same region. If you are using this deployment model ensure that the
virtual network peering is enabled before you configure virtual network TAP.
Permissions
The accounts you use to apply TAP configuration on network interfaces must be assigned to the network
contributor role or a custom role that is assigned the necessary actions from the following table:
A C T IO N NAME
Next steps
Learn how to Create a virtual network TAP.
Azure Policy Regulatory Compliance controls for
Azure Virtual Network
11/2/2020 • 9 minutes to read • Edit Online
Regulatory Compliance in Azure Policy provides Microsoft created and managed initiative definitions, known as
built-ins, for the compliance domains and security controls related to different compliance standards. This
page lists the compliance domains and security controls for Azure Virtual Network. You can assign the built-
ins for a security control individually to help make your Azure resources compliant with the specific standard.
The title of each built-in policy definition links to the policy definition in the Azure portal. Use the link in the Policy
Version column to view the source on the Azure Policy GitHub repo.
IMPORTANT
Each control below is associated with one or more Azure Policy definitions. These policies may help you assess compliance
with the control; however, there often is not a one-to-one or complete match between a control and one or more policies. As
such, Compliant in Azure Policy refers only to the policies themselves; this doesn't ensure you're fully compliant with all
requirements of a control. In addition, the compliance standard includes controls that aren't addressed by any Azure Policy
definitions at this time. Therefore, compliance in Azure Policy is only a partial view of your overall compliance status. The
associations between controls and Azure Policy Regulatory Compliance definitions for these compliance standards may
change over time.
P O L IC Y P O L IC Y VERSIO N
DO M A IN C O N T RO L ID C O N T RO L T IT L E ( A ZURE PO RTA L) ( GIT HUB)
Network Security 1.2 Monitor and log the Network Watcher 1.1.0
configuration and should be enabled
traffic of Vnets,
Subnets, and NICs
P O L IC Y P O L IC Y VERSIO N
DO M A IN C O N T RO L ID C O N T RO L T IT L E ( A ZURE PO RTA L) ( GIT HUB)
Networking 6.1 Ensure that RDP RDP access from the 2.0.0
access is restricted Internet should be
from the internet blocked
Networking 6.2 Ensure that SSH SSH access from the 2.0.0
access is restricted Internet should be
from the internet blocked
P O L IC Y P O L IC Y VERSIO N
DO M A IN C O N T RO L ID C O N T RO L T IT L E ( A ZURE PO RTA L) ( GIT HUB)
Security of Network 0888.09n2Organizati The contract with the Network Watcher 1.1.0
Services onal.6 - 09.n external/outsourced should be enabled
service provider
includes the
specification that the
service provider is
responsible for the
protection of covered
information shared.
NIST SP 800-171 R2
To review how the available Azure Policy built-ins for all Azure services map to this compliance standard, see Azure
Policy Regulatory Compliance - NIST SP 800-171 R2. For more information about this compliance standard, see
NIST SP 800-171 R2.
P O L IC Y P O L IC Y VERSIO N
DO M A IN C O N T RO L ID C O N T RO L T IT L E ( A ZURE PO RTA L) ( GIT HUB)
NIST SP 800-53 R4
To review how the available Azure Policy built-ins for all Azure services map to this compliance standard, see Azure
Policy Regulatory Compliance - NIST SP 800-53 R4. For more information about this compliance standard, see
NIST SP 800-53 R4.
P O L IC Y P O L IC Y VERSIO N
DO M A IN C O N T RO L ID C O N T RO L T IT L E ( A ZURE PO RTA L) ( GIT HUB)
Next steps
Learn more about Azure Policy Regulatory Compliance.
See the built-ins on the Azure Policy GitHub repo.
Subnet extension
11/4/2019 • 2 minutes to read • Edit Online
Workload migration to the public cloud requires careful planning and coordination. One of the key considerations
can be the ability to retain your IP addresses. Which can be important especially if your applications have IP
address dependency or you have compliance requirements to use specific IP addresses. Azure Virtual Network
solves this problem for you by allowing you to create VNet and Subnets using an IP address range of your choice.
Migrations can get a bit challenging when the above requirement is coupled with an additional requirement to
keep some applications on-premises. In such as a situation, you'll have to split the applications between Azure and
on-premises, without renumbering the IP addresses on either side. Additionally, you'll have to allow the
applications to communicate as if they are in the same network.
One solution to the above problem is subnet extension. Extending a network allows applications to talk over the
same broadcast domain when they exist at different physical locations, removing the need to rearchitect your
network topology.
While extending your network isn't a good practice in general, below use cases can make it necessary.
Phased Migration : The most common scenario is that you want to phase your migration. You want to bring a
few applications first and over time migrate rest of the applications to Azure.
Latency : Low latency requirements can be another reason for you to keep some applications on-premises to
ensure that they're as close as possible to your datacenter.
Compliance : Another use case is that you might have compliance requirements to keep some of your
applications on-premises.
NOTE
You should not extend your subnets unless it is necessary. In the cases where you do extend your subnets, you should try to
make it an intermediate step. With time, you should try re-number applications in your on-premises network and migrate
them to Azure.
In the next section, we'll discuss how you can extend your subnets into Azure.
Next steps
Extend your subnet to Azure using vendor solutions.
What is subnet delegation?
11/2/2020 • 2 minutes to read • Edit Online
Subnet delegation enables you to designate a specific subnet for an Azure PaaS service of your choice that needs to
be injected into your virtual network. Subnet delegation provides full control to the customer on managing the
integration of Azure services into their virtual networks.
When you delegate a subnet to an Azure service, you allow that service to establish some basic network
configuration rules for that subnet, which help the Azure service operate their instances in a stable manner. As a
result, the Azure service may establish some pre or post deployment conditions, such as:
deploy the service in a shared versus dedicated subnet.
add to the service a set of Network Intent Policies post deployment that is required for the service to work
properly.
Next steps
Delegate a subnet
Plan virtual networks
11/2/2020 • 10 minutes to read • Edit Online
Creating a virtual network to experiment with is easy enough, but chances are, you will deploy multiple virtual
networks over time to support the production needs of your organization. With some planning, you will be able to
deploy virtual networks and connect the resources you need more effectively. The information in this article is most
helpful if you're already familiar with virtual networks and have some experience working with them. If you are not
familiar with virtual networks, it's recommended that you read Virtual network overview.
Naming
All Azure resources have a name. The name must be unique within a scope, that may vary for each resource type.
For example, the name of a virtual network must be unique within a resource group, but can be duplicated within a
subscription or Azure region. Defining a naming convention that you can use consistently when naming resources
is helpful when managing several network resources over time. For suggestions, see Naming conventions.
Regions
All Azure resources are created in an Azure region and subscription. A resource can only be created in a virtual
network that exists in the same region and subscription as the resource. You can however, connect virtual networks
that exist in different subscriptions and regions. For more information, see connectivity. When deciding which
region(s) to deploy resources in, consider where consumers of the resources are physically located:
Consumers of resources typically want the lowest network latency to their resources. To determine relative
latencies between a specified location and Azure regions, see View relative latencies.
Do you have data residency, sovereignty, compliance, or resiliency requirements? If so, choosing the region that
aligns to the requirements is critical. For more information, see Azure geographies.
Do you require resiliency across Azure Availability Zones within the same Azure region for the resources you
deploy? You can deploy resources, such as virtual machines (VM) to different availability zones within the same
virtual network. Not all Azure regions support availability zones however. To learn more about availability zones
and the regions that support them, see Availability zones.
Subscriptions
You can deploy as many virtual networks as required within each subscription, up to the limit. Some organizations
have different subscriptions for different departments, for example. For more information and considerations
around subscriptions, see Subscription governance.
Segmentation
You can create multiple virtual networks per subscription and per region. You can create multiple subnets within
each virtual network. The considerations that follow help you determine how many virtual networks and subnets
you require:
Virtual networks
A virtual network is a virtual, isolated portion of the Azure public network. Each virtual network is dedicated to
your subscription. Things to consider when deciding whether to create one virtual network, or multiple virtual
networks in a subscription:
Do any organizational security requirements exist for isolating traffic into separate virtual networks? You can
choose to connect virtual networks or not. If you connect virtual networks, you can implement a network virtual
appliance, such as a firewall, to control the flow of traffic between the virtual networks. For more information,
see security and connectivity.
Do any organizational requirements exist for isolating virtual networks into separate subscriptions or regions?
A network interface enables a VM to communicate with other resources. Each network interface has one or
more private IP addresses assigned to it. How many network interfaces and private IP addresses do you require
in a virtual network? There are limits to the number of network interfaces and private IP addresses that you can
have within a virtual network.
Do you want to connect the virtual network to another virtual network or on-premises network? You may
choose to connect some virtual networks to each other or on-premises networks, but not others. For more
information, see connectivity. Each virtual network that you connect to another virtual network, or on-premises
network, must have a unique address space. Each virtual network has one or more public or private address
ranges assigned to its address space. An address range is specified in classless internet domain routing (CIDR)
format, such as 10.0.0.0/16. Learn more about address ranges for virtual networks.
Do you have any organizational administration requirements for resources in different virtual networks? If so,
you might separate resources into separate virtual network to simplify permission assignment to individuals in
your organization or to assign different policies to different virtual networks.
When you deploy some Azure service resources into a virtual network, they create their own virtual network. To
determine whether an Azure service creates its own virtual network, see information for each Azure service that
can be deployed into a virtual network.
Subnets
A virtual network can be segmented into one or more subnets up to the limits. Things to consider when deciding
whether to create one subnet, or multiple virtual networks in a subscription:
Each subnet must have a unique address range, specified in CIDR format, within the address space of the virtual
network. The address range cannot overlap with other subnets in the virtual network.
If you plan to deploy some Azure service resources into a virtual network, they may require, or create, their own
subnet, so there must be enough unallocated space for them to do so. To determine whether an Azure service
creates its own subnet, see information for each Azure service that can be deployed into a virtual network. For
example, if you connect a virtual network to an on-premises network using an Azure VPN Gateway, the virtual
network must have a dedicated subnet for the gateway. Learn more about gateway subnets.
Azure routes network traffic between all subnets in a virtual network, by default. You can override Azure's
default routing to prevent Azure routing between subnets, or to route traffic between subnets through a
network virtual appliance, for example. If you require that traffic between resources in the same virtual network
flow through a network virtual appliance (NVA), deploy the resources to different subnets. Learn more in
security.
You can limit access to Azure resources such as an Azure storage account or Azure SQL Database, to specific
subnets with a virtual network service endpoint. Further, you can deny access to the resources from the internet.
You may create multiple subnets, and enable a service endpoint for some subnets, but not others. Learn more
about service endpoints, and the Azure resources you can enable them for.
You can associate zero or one network security group to each subnet in a virtual network. You can associate the
same, or a different, network security group to each subnet. Each network security group contains rules, which
allow or deny traffic to and from sources and destinations. Learn more about network security groups.
Security
You can filter network traffic to and from resources in a virtual network using network security groups and network
virtual appliances. You can control how Azure routes traffic from subnets. You can also limit who in your
organization can work with resources in virtual networks.
Traffic filtering
You can filter network traffic between resources in a virtual network using a network security group, an NVA
that filters network traffic, or both. To deploy an NVA, such as a firewall, to filter network traffic, see the Azure
Marketplace. When using an NVA, you also create custom routes to route traffic from subnets to the NVA. Learn
more about traffic routing.
A network security group contains several default security rules that allow or deny traffic to or from resources. A
network security group can be associated to a network interface, the subnet the network interface is in, or both.
To simplify management of security rules, it's recommended that you associate a network security group to
individual subnets, rather than individual network interfaces within the subnet, whenever possible.
If different VMs within a subnet need different security rules applied to them, you can associate the network
interface in the VM to one or more application security groups. A security rule can specify an application security
group in its source, destination, or both. That rule then only applies to the network interfaces that are members
of the application security group. Learn more about network security groups and application security groups.
Azure creates several default security rules within each network security group. One default rule allows all traffic
to flow between all resources in a virtual network. To override this behavior, use network security groups,
custom routing to route traffic to an NVA, or both. It's recommended that you familiarize yourself with all of
Azure's default security rules and understand how network security group rules are applied to a resource.
You can view sample designs for implementing a perimeter network (also known as a DMZ) between Azure and the
internet using an NVA.
Traffic routing
Azure creates several default routes for outbound traffic from a subnet. You can override Azure's default routing by
creating a route table and associating it to a subnet. Common reasons for overriding Azure's default routing are:
Because you want traffic between subnets to flow through an NVA. To learn more about how to configure route
tables to force traffic through an NVA.
Because you want to force all internet-bound traffic through an NVA, or on-premises, through an Azure VPN
gateway. Forcing internet traffic on-premises for inspection and logging is often referred to as forced tunneling.
Learn more about how to configure forced tunneling.
If you need to implement custom routing, it's recommended that you familiarize yourself with routing in Azure.
Connectivity
You can connect a virtual network to other virtual networks using virtual network peering, or to your on-premises
network, using an Azure VPN gateway.
Peering
When using virtual network peering, the virtual networks can be in the same, or different, supported Azure regions.
The virtual networks can be in the same or different Azure subscriptions (even subscriptions belonging to different
Azure Active Directory tenants). Before creating a peering, it's recommended that you familiarize yourself with all of
the peering requirements and constraints. Bandwidth between resources in virtual networks peered in the same
region is the same as if the resources were in the same virtual network.
VPN gateway
You can use an Azure VPN Gateway to connect a virtual network to your on-premises network using a site-to-site
VPN, or using a dedicated connection with Azure ExpressRoute.
You can combine peering and a VPN gateway to create hub and spoke networks, where spoke virtual networks
connect to a hub virtual network, and the hub connects to an on-premises network, for example.
Name resolution
Resources in one virtual network cannot resolve the names of resources in a peered virtual network using Azure's
built-in DNS. To resolve names in a peered virtual network, deploy your own DNS server, or use Azure DNS private
domains. Resolving names between resources in a virtual network and on-premises networks also requires you to
deploy your own DNS server.
Permissions
Azure utilizes Azure role-based access control (Azure RBAC) to resources. Permissions are assigned to a scope in
the following hierarchy: management group, subscription, resource group, and individual resource. To learn more
about the hierarchy, see Organize your resources. To work with Azure virtual networks and all of their related
capabilities such as peering, network security groups, service endpoints, and route tables, you can assign members
of your organization to the built-in Owner, Contributor, or Network contributor roles, and then assign the role to
the appropriate scope. If you want to assign specific permissions for a subset of virtual network capabilities, create
a custom role and assign the specific permissions required for virtual networks, subnets and service endpoints,
network interfaces, peering, network and application security groups, or route tables to the role.
Policy
Azure Policy enables you to create, assign, and manage policy definitions. Policy definitions enforce different rules
over your resources, so the resources stay compliant with your organizational standards and service level
agreements. Azure Policy runs an evaluation of your resources, scanning for resources that are not compliant with
the policy definitions you have. For example, you can define and apply a policy that allows creation of virtual
networks in only a specific resource group or region. Another policy can require that every subnet has a network
security group associated to it. The policies are then evaluated when creating and updating resources.
Policies are applied to the following hierarchy: management group, subscription, and resource group. Learn more
about Azure Policy or deploy some virtual network Azure Policy definitions.
Next steps
Learn about all tasks, settings, and options for a virtual network, subnet and service endpoint, network interface,
peering, network and application security group, or route table.
Name resolution for resources in Azure virtual
networks
11/2/2020 • 15 minutes to read • Edit Online
Depending on how you use Azure to host IaaS, PaaS, and hybrid solutions, you might need to allow the virtual
machines (VMs), and other resources deployed in a virtual network to communicate with each other. Although
you can enable communication by using IP addresses, it is much simpler to use names that can be easily
remembered, and do not change.
When resources deployed in virtual networks need to resolve domain names to internal IP addresses, they can
use one of three methods:
Azure DNS private zones
Azure-provided name resolution
Name resolution that uses your own DNS server (which might forward queries to the Azure-provided DNS
servers)
The type of name resolution you use depends on how your resources need to communicate with each other. The
following table illustrates scenarios and corresponding name resolution solutions:
NOTE
Azure DNS private zones is the preferred solution and gives you flexibility in managing your DNS zones and records. For
more information, see Using Azure DNS for private domains.
NOTE
If you use Azure Provided DNS then appropriate DNS suffix will be automatically applied to your virtual machines. For all
other options you must either use Fully Qualified Domain Names (FQDN) or manually apply appropriate DNS suffix to your
virtual machines.
SC EN A RIO SO L UT IO N DN S SUF F IX
Name resolution between VMs located Azure DNS private zones or Azure- Hostname or FQDN
in the same virtual network, or Azure provided name resolution
Cloud Services role instances in the
same cloud service.
Name resolution between VMs in Azure DNS private zones or, Customer- FQDN only
different virtual networks or role managed DNS servers forwarding
instances in different cloud services. queries between virtual networks for
resolution by Azure (DNS proxy). See
Name resolution using your own DNS
server.
Name resolution from an Azure App Customer-managed DNS servers FQDN only
Service (Web App, Function, or Bot) forwarding queries between virtual
using virtual network integration to networks for resolution by Azure (DNS
role instances or VMs in the same proxy). See Name resolution using your
virtual network. own DNS server.
SC EN A RIO SO L UT IO N DN S SUF F IX
Name resolution from App Service Web Customer-managed DNS servers FQDN only
Apps to VMs in the same virtual forwarding queries between virtual
network. networks for resolution by Azure (DNS
proxy). See Name resolution using your
own DNS server.
Name resolution from App Service Web Customer-managed DNS servers FQDN only
Apps in one virtual network to VMs in forwarding queries between virtual
a different virtual network. networks for resolution by Azure (DNS
proxy). See Name resolution using your
own DNS server.
Reverse DNS for internal IPs. Azure DNS private zones or Azure- Not applicable
provided name resolution or Name
resolution using your own DNS server.
Name resolution between VMs or role Not applicable. Connectivity between Not applicable
instances located in different cloud VMs and role instances in different
services, not in a virtual network. cloud services is not supported outside
a virtual network.
Features
Azure-provided name resolution includes the following features:
Ease of use. No configuration is required.
High availability. You don't need to create and manage clusters of your own DNS servers.
You can use the service in conjunction with your own DNS servers, to resolve both on-premises and Azure
host names.
You can use name resolution between VMs and role instances within the same cloud service, without the need
for an FQDN.
You can use name resolution between VMs in virtual networks that use the Azure Resource Manager
deployment model, without need for an FQDN. Virtual networks in the classic deployment model require an
FQDN when you are resolving names in different cloud services.
You can use host names that best describe your deployments, rather than working with auto-generated names.
Considerations
Points to consider when you are using Azure-provided name resolution:
The Azure-created DNS suffix cannot be modified.
DNS lookup is scoped to a virtual network. DNS names created for one virtual networks can't be resolved from
other virtual networks.
You cannot manually register your own records.
WINS and NetBIOS are not supported. You cannot see your VMs in Windows Explorer.
Host names must be DNS-compatible. Names must use only 0-9, a-z, and '-', and cannot start or end with a '-'.
DNS query traffic is throttled for each VM. Throttling shouldn't impact most applications. If request throttling is
observed, ensure that client-side caching is enabled. For more information, see DNS client configuration.
Only VMs in the first 180 cloud services are registered for each virtual network in a classic deployment model.
This limit does not apply to virtual networks in Azure Resource Manager.
The Azure DNS IP address is 168.63.129.16. This is a static IP address and will not change.
Reverse DNS Considerations
Reverse DNS is supported in all ARM based virtual networks. You can issue reverse DNS queries (PTR queries) to
map IP addresses of virtual machines to FQDNs of virtual machines.
All PTR queries for IP addresses of virtual machines will return FQDNs of form [vmname].internal.cloudapp.net
Forward lookup on FQDNs of form [vmname].internal.cloudapp.net will resolve to IP address assigned to the
virtual machine.
If the virtual network is linked to an Azure DNS private zones as a registration virtual network, the reverse
DNS queries will return two records. One record will be of the form [vmname].[privatednszonename] and the
other will be of the form [vmname].internal.cloudapp.net
Reverse DNS lookup is scoped to a given virtual network even if it is peered to other virtual networks. Reverse
DNS queries (PTR queries) for IP addresses of virtual machines located in peered virtual networks will return
NXDOMAIN.
If you want to turn off reverse DNS function in a virtual network you can do so by creating a reverse lookup
zone using Azure DNS private zones and link this zone to your virtual network. For example if the IP address
space of your virtual network is 10.20.0.0/16 then you can create a empty private DNS zone 20.10.in-addr.arpa
and link it to the virtual network. While linking the zone to your virtual network you should disable auto
registration on the link. This zone will override the default reverse lookup zones for the virtual network and
since this zone is empty you will get NXDOMAIN for your reverse DNS queries. See our Quickstart guide for
details on how to create a private DNS zone and link it to a virtual network.
NOTE
If you want reverse DNS lookup to span across virtual network you can create a reverse lookup zone (in-addr.arpa) Azure
DNS private zones and links it to multiple virtual networks. You'll however have to manually manage the reverse DNS
records for the virtual machines.
NOTE
The dnsmasq package is only one of many DNS caches available for Linux. Before using it, check its suitability for your
particular needs, and check that no other cache is installed.
Client-side retries
DNS is primarily a UDP protocol. Because the UDP protocol doesn't guarantee message delivery, retry logic is
handled in the DNS protocol itself. Each DNS client (operating system) can exhibit different retry logic, depending
on the creator's preference:
Windows operating systems retry after one second, and then again after another two seconds, four seconds,
and another four seconds.
The default Linux setup retries after five seconds. We recommend changing the retry specifications to five
times, at one-second intervals.
Check the current settings on a Linux VM with cat /etc/resolv.conf . Look at the options line, for example:
The resolv.conf file is usually auto-generated, and should not be edited. The specific steps for adding the options
line vary by distribution:
Ubuntu (uses resolvconf):
1. Add the options line to /etc/resolvconf/resolv.conf.d/tail .
2. Run resolvconf -u to update.
SUSE (uses netconf):
1. Add timeout:1 attempts:5 to the NETCONFIG_DNS_RESOLVER_OPTIONS="" parameter in
/etc/sysconfig/network/config .
2. Run netconfig update to update.
CentOS (uses NetworkManager):
1. Add echo "options timeout:1 attempts:5" to /etc/NetworkManager/dispatcher.d/11-dhclient .
2. Update with service network restart .
Role instances that need to perform name resolution of VMs in another virtual network (FQDN by using the
internal.cloudapp.net suffix) have to do so by using the method described in this section (custom DNS servers
forwarding between the two virtual networks).
When you are using Azure-provided name resolution, Azure Dynamic Host Configuration Protocol (DHCP)
provides an internal DNS suffix (.internal.cloudapp.net ) to each VM. This suffix enables host name resolution
because the host name records are in the internal.cloudapp.net zone. When you are using your own name
resolution solution, this suffix is not supplied to VMs because it interferes with other DNS architectures (like
domain-joined scenarios). Instead, Azure provides a non-functioning placeholder (reddog.microsoft.com).
If necessary, you can determine the internal DNS suffix by using PowerShell or the API:
For virtual networks in Azure Resource Manager deployment models, the suffix is available via the network
interface REST API, the Get-AzNetworkInterface PowerShell cmdlet, and the az network nic show Azure CLI
command.
In classic deployment models, the suffix is available via the Get Deployment API call or the Get-AzureVM -
Debug cmdlet.
If forwarding queries to Azure doesn't suit your needs, you should provide your own DNS solution. Your DNS
solution needs to:
Provide appropriate host name resolution, via DDNS, for example. If you are using DDNS, you might need to
disable DNS record scavenging. Azure DHCP leases are long, and scavenging might remove DNS records
prematurely.
Provide appropriate recursive resolution to allow resolution of external domain names.
Be accessible (TCP and UDP on port 53) from the clients it serves, and be able to access the internet.
Be secured against access from the internet, to mitigate threats posed by external agents.
NOTE
For best performance, when you are using Azure VMs as DNS servers, IPv6 should be disabled.
Web apps
Suppose you need to perform name resolution from your web app built by using App Service, linked to a virtual
network, to VMs in the same virtual network. In addition to setting up a custom DNS server that has a DNS
forwarder that forwards queries to Azure (virtual IP 168.63.129.16), perform the following steps:
1. Enable virtual network integration for your web app, if not done already, as described in Integrate your app
with a virtual network.
2. In the Azure portal, for the App Service plan hosting the web app, select Sync Network under
Networking , Vir tual Network Integration .
If you need to perform name resolution from your web app built by using App Service, linked to a virtual network,
to VMs in a different virtual network, you have to use custom DNS servers on both virtual networks, as follows:
Set up a DNS server in your target virtual network, on a VM that can also forward queries to the recursive
resolver in Azure (virtual IP 168.63.129.16). An example DNS forwarder is available in the Azure Quickstart
Templates gallery and GitHub.
Set up a DNS forwarder in the source virtual network on a VM. Configure this DNS forwarder to forward
queries to the DNS server in your target virtual network.
Configure your source DNS server in your source virtual network's settings.
Enable virtual network integration for your web app to link to the source virtual network, following the
instructions in Integrate your app with a virtual network.
In the Azure portal, for the App Service plan hosting the web app, select Sync Network under Networking ,
Vir tual Network Integration .
NOTE
Network connection properties, such as DNS server IPs, should not be edited directly within VMs. This is because they
might get erased during service heal when the virtual network adaptor gets replaced. This applies to both Windows and
Linux VMs.
When you are using the Azure Resource Manager deployment model, you can specify DNS servers for a virtual
network and a network interface. For details, see Manage a virtual network and Manage a network interface.
NOTE
If you opt for custom DNS server for your virtual network, you must specify at least one DNS server IP address; otherwise,
virtual network will ignore the configuration and use Azure-provided DNS instead.
When you are using the classic deployment model, you can specify DNS servers for the virtual network in the
Azure portal or the Network Configuration file. For cloud services, you can specify DNS servers via the Service
Configuration file or by using PowerShell, with New-AzureVM.
NOTE
If you change the DNS settings for a virtual network or virtual machine that is already deployed, for the new DNS settings
to take effect, you must perform a DHCP lease renewal on all affected VMs in the virtual network. For VMs running the
Windows OS, you can do this by typing ipconfig /renew directly in the VM. The steps vary depending on the OS. See the
relevant documentation for your OS type.
Next steps
Azure Resource Manager deployment model:
Manage a virtual network
Manage a network interface
Classic deployment model:
Azure Service Configuration Schema
Virtual Network Configuration Schema
Configure a Virtual Network by using a network configuration file
Use dynamic DNS to register hostnames in your own
DNS server
11/2/2020 • 3 minutes to read • Edit Online
Azure provides name resolution for virtual machines (VM) and role instances. When your name resolution needs
exceed the capabilities provided by Azure's default DNS, you can provide your own DNS servers. Using your own
DNS servers gives you the ability to tailor your DNS solution to suit your own specific needs. For example, you may
need to access on-premises resources via your Active Directory domain controller.
When your custom DNS servers are hosted as Azure VMs, you can forward hostname queries for the same virtual
network to Azure to resolve hostnames. If you do not wish to use this option, you can register your VM hostnames
in your DNS server using dynamic DNS (DDNS). Azure doesn't have the credentials to directly create records in
your DNS servers, so alternative arrangements are often needed. Some common scenarios, with alternatives
follow:
Windows clients
Non-domain-joined Windows clients attempt unsecured DDNS updates when they boot, or when their IP address
changes. The DNS name is the hostname plus the primary DNS suffix. Azure leaves the primary DNS suffix blank,
but you can set the suffix in the VM, via the user interface or PowerShell.
Domain-joined Windows clients register their IP addresses with the domain controller by using secure DDNS. The
domain-join process sets the primary DNS suffix on the client and creates and maintains the trust relationship.
Linux clients
Linux clients generally don't register themselves with the DNS server on startup, they assume the DHCP server
does it. Azure's DHCP servers do not have the credentials to register records in your DNS server. You can use a tool
called nsupdate , which is included in the Bind package, to send DDNS updates. Because the DDNS protocol is
standardized, you can use nsupdate even when you're not using Bind on the DNS server.
You can use the hooks that are provided by the DHCP client to create and maintain the hostname entry in the DNS
server. During the DHCP cycle, the client executes the scripts in /etc/dhcp/dhclient-exit-hooks.d/. You can use the
hooks to register the new IP address using nsupdate . For example:
#!/bin/sh
requireddomain=mydomain.local
nsupdate $nsupdatecmds
fi
You can also use the nsupdate command to perform secure DDNS updates. For example, when you're using a Bind
DNS server, a public-private key pair is generated ( http://linux.yyz.us/nsupdate/ ). The DNS server is configured (
http://linux.yyz.us/dns/ddns-server.html ) with the public part of the key, so that it can verify the signature on the
request. To provide the key-pair to nsupdate , use the -k option, for the DDNS update request to be signed.
When you're using a Windows DNS server, you can use Kerberos authentication with the -g parameter in
nsupdate , but it's not available in the Windows version of nsupdate . To use Kerberos, use kinit to load the
credentials. For example, you can load credentials from a keytab file), then nsupdate -g picks up the credentials,
from the cache.
If needed, you can add a DNS search suffix to your VMs. The DNS suffix is specified in the /etc/resolv.conf file. Most
Linux distros automatically manage the content of this file, so usually you can't edit it. However, you can override
the suffix by using the DHCP client's supersede command. To override the suffix, add the following line to the
/etc/dhcp/dhclient.conf file:
Azure virtual machines (VM) have default network settings that can be further optimized for network throughput.
This article describes how to optimize network throughput for Microsoft Azure Windows and Linux VMs, including
major distributions such as Ubuntu, CentOS, and Red Hat.
Windows VM
If your Windows VM supports Accelerated Networking, enabling that feature would be the optimal configuration
for throughput. For all other Windows VMs, using Receive Side Scaling (RSS) can reach higher maximal throughput
than a VM without RSS. RSS may be disabled by default in a Windows VM. To determine whether RSS is enabled,
and enable it if it's currently disabled, complete the following steps:
1. See if RSS is enabled for a network adapter with the Get-NetAdapterRss PowerShell command. In the
following example output returned from the Get-NetAdapterRss , RSS is not enabled.
Name : Ethernet
InterfaceDescription : Microsoft Hyper-V Network Adapter
Enabled : False
The previous command does not have an output. The command changed NIC settings, causing temporary
connectivity loss for about one minute. A Reconnecting dialog box appears during the connectivity loss.
Connectivity is typically restored after the third attempt.
3. Confirm that RSS is enabled in the VM by entering the Get-NetAdapterRss command again. If successful, the
following example output is returned:
Name : Ethernet
InterfaceDescription : Microsoft Hyper-V Network Adapter
Enabled : True
Linux VM
RSS is always enabled by default in an Azure Linux VM. Linux kernels released since October 2017 include new
network optimizations options that enable a Linux VM to achieve higher network throughput.
Ubuntu for new deployments
The Ubuntu Azure kernel is the most optimized for network performance on Azure. To get the latest optimizations,
first install the latest supported version of 18.04-LTS, as follows:
"Publisher": "Canonical",
"Offer": "UbuntuServer",
"Sku": "18.04-LTS",
"Version": "latest"
After the creation is complete, enter the following commands to get the latest updates. These steps also work for
VMs currently running the Ubuntu Azure kernel.
The following optional command set may be helpful for existing Ubuntu deployments that already have the Azure
kernel but that have failed to further updates with errors.
#optional steps may be helpful in existing deployments with the Azure kernel
#run as root or preface with sudo
apt-get -f install
apt-get --fix-missing install
apt-get clean
apt-get -y update
apt-get -y upgrade
apt-get -y dist-upgrade
If your VM does not have the Azure kernel, the version number usually begins with "4.4." If the VM does not have
the Azure kernel, run the following commands as root:
CentOS
In order to get the latest optimizations, it is best to create a VM with the latest supported version by specifying the
following parameters:
"Publisher": "OpenLogic",
"Offer": "CentOS",
"Sku": "7.7",
"Version": "latest"
New and existing VMs can benefit from installing the latest Linux Integration Services (LIS). The throughput
optimization is in LIS, starting from 4.2.2-2, although later versions contain further improvements. Enter the
following commands to install the latest LIS:
Red Hat
In order to get the optimizations, it is best to create a VM with the latest supported version by specifying the
following parameters:
"Publisher": "RedHat"
"Offer": "RHEL"
"Sku": "7-RAW"
"Version": "latest"
New and existing VMs can benefit from installing the latest Linux Integration Services (LIS). The throughput
optimization is in LIS, starting from 4.2. Enter the following commands to download and install LIS:
wget https://aka.ms/lis
tar xvf lis
cd LISISO
sudo ./install.sh #or upgrade.sh if prior LIS was previously installed
Learn more about Linux Integration Services Version 4.2 for Hyper-V by viewing the download page.
Next steps
Deploy VMs close to each other for low latency with Proximity Placement Group
See the optimized result with Bandwidth/Throughput testing Azure VM for your scenario.
Read about how bandwidth is allocated to virtual machines
Learn more with Azure Virtual Network frequently asked questions (FAQ)
Viewing and modifying hostnames
11/2/2020 • 2 minutes to read • Edit Online
To allow your role instances to be referenced by host name, you must set the value for the host name in the service
configuration file for each role. You do that by adding the desired host name to the vmName attribute of the Role
element. The value of the vmName attribute is used as a base for the host name of each role instance. For example,
if vmName is webrole and there are three instances of that role, the host names of the instances will be webrole0,
webrole1, and webrole2. You do not need to specify a host name for virtual machines in the configuration file,
because the host name for a virtual machine is populated based on the virtual machine name. For more
information about configuring a Microsoft Azure service, see Azure Service Configuration Schema (.cscfg File)
Viewing hostnames
You can view the host names of virtual machines and role instances in a cloud service by using any of the tools
below.
Service configuration file
You can download the service configuration file for a deployed service from the Configure blade of the service in
the Azure portal. You can then look for the vmName attribute for the Role name element to see the host name.
Keep in mind that this host name is used as a base for the host name of each role instance. For example, if
vmName is webrole and there are three instances of that role, the host names of the instances will be webrole0,
webrole1, and webrole2.
Remote Desktop
After you enable Remote Desktop (Windows), Windows PowerShell remoting (Windows), or SSH (Linux and
Windows) connections to your virtual machines or role instances, you can view the host name from an active
Remote Desktop connection in various ways:
Type hostname at the command prompt or SSH terminal.
Type ipconfig /all at the command prompt (Windows only).
View the computer name in the system settings (Windows only).
Azure Service Management REST API
From a REST client, follow these instructions:
1. Ensure that you have a client certificate to connect to the Azure portal. To obtain a client certificate, follow the
steps presented in How to: Download and Import Publish Settings and Subscription Information.
2. Set a header entry named x-ms-version with a value of 2013-11-01.
3. Send a request in the following format: https://management.core.windows.net/<subscrition-
id>/services/hostedservices/<service-name>?embed-detail=true
4. Look for the HostName element for each RoleInstance element.
WARNING
You can also view the internal domain suffix for your cloud service from the REST call response by checking the
InternalDnsSuffix element, or by running ipconfig /all from a command prompt in a Remote Desktop session (Windows), or
by running cat /etc/resolv.conf from an SSH terminal (Linux).
Modifying a hostname
You can modify the host name for any virtual machine or role instance by uploading a modified service
configuration file, or by renaming the computer from a Remote Desktop session.
Next steps
Name Resolution (DNS)
Azure Service Configuration Schema (.cscfg)
Azure Virtual Network Configuration Schema
Specify DNS settings using network configuration files
Resource logging for a network security group
11/2/2020 • 7 minutes to read • Edit Online
A network security group (NSG) includes rules that allow or deny traffic to a virtual network subnet, network
interface, or both.
When you enable logging for an NSG, you can gather the following types of resource log information:
Event: Entries are logged for which NSG rules are applied to VMs, based on MAC address.
Rule counter : Contains entries for how many times each NSG rule is applied to deny or allow traffic. The
status for these rules is collected every 300 seconds.
Resource logs are only available for NSGs deployed through the Azure Resource Manager deployment model. You
cannot enable resource logging for NSGs deployed through the classic deployment model. For a better
understanding of the two models, see Understanding Azure deployment models.
Resource logging is enabled separately for each NSG you want to collect diagnostic data for. If you're interested in
activity (operational) logs instead, see Azure activity logging.
Enable logging
You can use the Azure Portal, PowerShell, or the Azure CLI to enable resource logging.
Azure Portal
1. Sign in to the portal.
2. Select All ser vices , then type network security groups. When Network security groups appear in the
search results, select it.
3. Select the NSG you want to enable logging for.
4. Under MONITORING , select Diagnostics logs , and then select Turn on diagnostics , as shown in the
following picture:
5. Under Diagnostics settings , enter, or select the following information, and then select Save :
SET T IN G VA L UE
Archive to a storage account , Stream to an event You can select as many destinations as you choose. To
hub , and Send to Log Analytics learn more about each, see Log destinations.
6. View and analyze logs. For more information, see View and analyze logs.
PowerShell
NOTE
This article has been updated to use the new Azure PowerShell Az module. You can still use the AzureRM module, which will
continue to receive bug fixes until at least December 2020. To learn more about the new Az module and AzureRM
compatibility, see Introducing the new Azure PowerShell Az module. For Az module installation instructions, see Install Azure
PowerShell.
You can run the commands that follow in the Azure Cloud Shell, or by running PowerShell from your computer. The
Azure Cloud Shell is a free interactive shell. It has common Azure tools preinstalled and configured to use with
your account. If you run PowerShell from your computer, you need the Azure PowerShell module, version 1.0.0 or
later. Run Get-Module -ListAvailable Az on your computer, 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
sign in to Azure with an account that has the necessary permissions.
To enable resource logging, you need the Id of an existing NSG. If you don't have an existing NSG, you can create
one with New-AzNetworkSecurityGroup.
Retrieve the network security group that you want to enable resource logging for with Get-
AzNetworkSecurityGroup. For example, to retrieve an NSG named myNsg that exists in a resource group named
myResourceGroup, enter the following command:
$Nsg=Get-AzNetworkSecurityGroup `
-Name myNsg `
-ResourceGroupName myResourceGroup
You can write resource logs to three destination types. For more information, see Log destinations. In this article,
logs are sent to the Log Analytics destination, as an example. Retrieve an existing Log Analytics workspace with
Get-AzOperationalInsightsWorkspace. For example, to retrieve an existing workspace named myWorkspace in a
resource group named myWorkspaces, enter the following command:
$Oms=Get-AzOperationalInsightsWorkspace `
-ResourceGroupName myWorkspaces `
-Name myWorkspace
If you don't have an existing workspace, you can create one with New-AzOperationalInsightsWorkspace.
There are two categories of logging you can enable logs for. For more information, see Log categories. Enable
resource logging for the NSG with Set-AzDiagnosticSetting. The following example logs both event and counter
category data to the workspace for an NSG, using the IDs for the NSG and workspace you retrieved previously:
Set-AzDiagnosticSetting `
-ResourceId $Nsg.Id `
-WorkspaceId $Oms.ResourceId `
-Enabled $true
If you only want to log data for one category or the other, rather than both, add the -Categories option to the
previous command, followed by NetworkSecurityGroupEvent or NetworkSecurityGroupRuleCounter. If you want
to log to a different destination than a Log Analytics workspace, use the appropriate parameters for an Azure
Storage account or Event Hub.
View and analyze logs. For more information, see View and analyze logs.
Azure CLI
You can run the commands that follow in the Azure Cloud Shell, or by running the Azure CLI from your computer.
The Azure Cloud Shell is a free interactive shell. It has common Azure tools preinstalled and configured to use with
your account. If you run the CLI from your computer, you need version 2.0.38 or later. Run az --version on your
computer, to find the installed version. If you need to upgrade, see Install Azure CLI. If you are running the CLI
locally, you also need to run az login to sign in to Azure with an account that has the necessary permissions.
To enable resource logging, you need the Id of an existing NSG. If you don't have an existing NSG, you can create
one with az network nsg create.
Retrieve the network security group that you want to enable resource logging for with az network nsg show. For
example, to retrieve an NSG named myNsg that exists in a resource group named myResourceGroup, enter the
following command:
You can write resource logs to three destination types. For more information, see Log destinations. In this article,
logs are sent to the Log Analytics destination, as an example. For more information, see Log categories.
Enable resource logging for the NSG with az monitor diagnostic-settings create. The following example logs both
event and counter category data to an existing workspace named myWorkspace, which exists in a resource group
named myWorkspaces, and the ID of the NSG you retrieved previously:
If you don't have an existing workspace, you can create one using the Azure portal or PowerShell. There are two
categories of logging you can enable logs for.
If you only want to log data for one category or the other, remove the category you don't want to log data for in
the previous command. If you want to log to a different destination than a Log Analytics workspace, use the
appropriate parameters for an Azure Storage account or Event Hub.
View and analyze logs. For more information, see View and analyze logs.
Log destinations
Diagnostics data can be:
Written to an Azure Storage account, for auditing or manual inspection. You can specify the retention time (in
days) using resource diagnostic settings.
Streamed to an Event hub for ingestion by a third-party service, or custom analytics solution, such as PowerBI.
Written to Azure Monitor logs.
Log categories
JSON-formatted data is written for the following log categories:
Event
The event log contains information about which NSG rules are applied to VMs, based on MAC address. The
following data is logged for each event. In the following example, the data is logged for a virtual machine with the
IP address 192.168.1.4 and a MAC address of 00-0D-3A-92-6A-7C:
{
"time": "[DATE-TIME]",
"systemId": "[ID]",
"category": "NetworkSecurityGroupEvent",
"resourceId": "/SUBSCRIPTIONS/[SUBSCRIPTION-ID]/RESOURCEGROUPS/[RESOURCE-GROUP-
NAME]/PROVIDERS/MICROSOFT.NETWORK/NETWORKSECURITYGROUPS/[NSG-NAME]",
"operationName": "NetworkSecurityGroupEvents",
"properties": {
"vnetResourceGuid":"[ID]",
"subnetPrefix":"192.168.1.0/24",
"macAddress":"00-0D-3A-92-6A-7C",
"primaryIPv4Address":"192.168.1.4",
"ruleName":"[SECURITY-RULE-NAME]",
"direction":"[DIRECTION-SPECIFIED-IN-RULE]",
"priority":"[PRIORITY-SPECIFIED-IN-RULE]",
"type":"[ALLOW-OR-DENY-AS-SPECIFIED-IN-RULE]",
"conditions":{
"protocols":"[PROTOCOLS-SPECIFIED-IN-RULE]",
"destinationPortRange":"[PORT-RANGE-SPECIFIED-IN-RULE]",
"sourcePortRange":"[PORT-RANGE-SPECIFIED-IN-RULE]",
"sourceIP":"[SOURCE-IP-OR-RANGE-SPECIFIED-IN-RULE]",
"destinationIP":"[DESTINATION-IP-OR-RANGE-SPECIFIED-IN-RULE]"
}
}
}
Rule counter
The rule counter log contains information about each rule applied to resources. The following example data is
logged each time a rule is applied. In the following example, the data is logged for a virtual machine with the IP
address 192.168.1.4 and a MAC address of 00-0D-3A-92-6A-7C:
{
"time": "[DATE-TIME]",
"systemId": "[ID]",
"category": "NetworkSecurityGroupRuleCounter",
"resourceId": "/SUBSCRIPTIONS/[SUBSCRIPTION ID]/RESOURCEGROUPS/[RESOURCE-GROUP-
NAME]/PROVIDERS/MICROSOFT.NETWORK/NETWORKSECURITYGROUPS/[NSG-NAME]",
"operationName": "NetworkSecurityGroupCounters",
"properties": {
"vnetResourceGuid":"[ID]",
"subnetPrefix":"192.168.1.0/24",
"macAddress":"00-0D-3A-92-6A-7C",
"primaryIPv4Address":"192.168.1.4",
"ruleName":"[SECURITY-RULE-NAME]",
"direction":"[DIRECTION-SPECIFIED-IN-RULE]",
"type":"[ALLOW-OR-DENY-AS-SPECIFIED-IN-RULE]",
"matchedConnections":125
}
}
NOTE
The source IP address for the communication is not logged. You can enable NSG flow logging for an NSG however, which
logs all of the rule counter information, as well as the source IP address that initiated the communication. NSG flow log data
is written to an Azure Storage account. You can analyze the data with the traffic analytics capability of Azure Network
Watcher.
Next steps
Learn more about Activity logging. Activity logging is enabled by default for NSGs created through either Azure
deployment model. To determine which operations were completed on NSGs in the activity log, look for entries
that contain the following resource types:
Microsoft.ClassicNetwork/networkSecurityGroups
Microsoft.ClassicNetwork/networkSecurityGroups/securityRules
Microsoft.Network/networkSecurityGroups
Microsoft.Network/networkSecurityGroups/securityRules
To learn how to log diagnostic information, to include the source IP address for each flow, see NSG flow logging.
Tutorial: Route network traffic with a route table
using the Azure portal
11/2/2020 • 9 minutes to read • Edit Online
Azure routes traffic between all subnets within a virtual network, by default. You can create your own routes to
override Azure's default routing. Custom routes are helpful when, for example, you want to route traffic between
subnets through a network virtual appliance (NVA). In this tutorial, you learn how to:
Create an NVA that routes traffic
Create a route table
Create a route
Associate a route table to a subnet
Deploy virtual machines (VM) into different subnets
Route traffic from one subnet to another through an NVA
This tutorial uses the Azure portal. You can also use Azure CLI or Azure PowerShell.
If you don't have an Azure subscription, create a free account before you begin.
Create an NVA
Network virtual appliances (NVAs) are virtual machines that help with network functions, such as routing and
firewall optimization. This tutorial assumes you're using Windows Ser ver 2016 Datacenter . You can select a
different operating system if you want.
1. On the Azure portal menu or from the Home page, select Create a resource .
2. Choose Security > Windows Ser ver 2016 Datacenter .
3. In the Create a vir tual machine page, under Basics , enter or select this information:
SEC T IO N SET T IN G A C T IO N
SUB N ET N A M E A DDRESS RA N GE
Public 10.0.0.0/24
Private 10.0.1.0/24
DMZ 10.0.2.0/24
SET T IN G VA L UE
Name mynvastorageaccount
Performance Standard
SET T IN G VA L UE
Name myRouteTablePublic
5. Select Create .
Create a route
1. Go to the Azure portal to manage your route table. Search for and select Route tables .
2. Pick the name of your route table (myRouteTablePublic ).
3. Choose Routes > Add .
4. In Add route , enter or select this information:
SET T IN G VA L UE
Next hop address 10.0.2.4 (an address within the address range of the DMZ
subnet)
5. Select OK .
Turn on IP forwarding
Next, turn on IP forwarding for your new NVA virtual machine, myVmNva. When Azure sends network traffic to
myVmNva, if the traffic is destined for a different IP address, IP forwarding sends the traffic to the correct location.
1. Go to the Azure portal to manage your VM. Search for and select Vir tual machines .
2. Pick the name of your VM (myVmNva ).
3. In your NVA virtual machine's menu bar, select Networking .
4. Select myvmnva123 . That's the network interface Azure created for your VM. Azure adds numbers to
ensure a unique name.
5. In the network interface menu bar, select IP configurations .
6. In the IP configurations page, set IP for warding to Enabled , and select Save .
Create public and private virtual machines
Create a public VM and a private VM in the virtual network. Later, you'll use them to see that Azure routes the
Public subnet traffic to the Private subnet through the NVA.
To create the public VM and the private VM, follow the steps of Create an NVA earlier. You don't need to wait for
deployment to finish or go to the VM resource. You'll use most of the same settings, except as described below.
Before you select Create to create the public or private VM, go to the following two subsections (Public VM and
Private VM), which show the values that have to be different. You may continue to the next section (Route traffic
through an NVA) after Azure finishes deploying both VMs.
Public VM
TA B SET T IN G VA L UE
You'll be using trace route to test routing in this tutorial. For production environments, we don't
recommend allowing ICMP through the Windows Firewall.
Turn on IP forwarding within myVmNva
You turned on IP forwarding for the VM's network interface using Azure. The VM's operating system also has to
forward network traffic. Turn on IP forwarding for myVmNva VM's operating system with these commands.
1. From a command prompt on the myVmPrivate VM, open a remote desktop to the myVmNva VM:
mstsc /v:myvmnva
2. From PowerShell on the myVmNva VM, enter this command to turn on IP forwarding:
3. Restart the myVmNva VM: From the taskbar, select Star t > Power , Other (Planned) > Continue .
This also disconnects the remote desktop session.
4. After the myVmNva VM restarts, create a remote desktop session to the myVmPublic VM. While still
connected to the myVmPrivate VM, open a command prompt and run this command:
mstsc /v:myVmPublic
tracert myVmPrivate
1 <1 ms * 1 ms 10.0.2.4
2 1 ms 1 ms 1 ms 10.0.1.4
Trace complete.
You can see the first hop is to 10.0.2.4, which is NVA's private IP address. The second hop is to the private IP
address of the myVmPrivate VM: 10.0.1.4. Earlier, you added the route to the myRouteTablePublic route
table and associated it to the Public subnet. As a result, Azure sent the traffic through the NVA and not
directly to the Private subnet.
2. Close the remote desktop session to the myVmPublic VM, which leaves you still connected to the
myVmPrivate VM.
3. From a command prompt on the myVmPrivate VM, enter this command:
tracert myVmPublic
This command tests the routing of network traffic from the myVmPrivate VM to the myVmPublic VM. The
response is similar to this example:
1 1 ms 1 ms 1 ms 10.0.0.4
Trace complete.
You can see that Azure routes traffic directly from the myVmPrivate VM to the myVmPublic VM. By default,
Azure routes traffic directly between subnets.
4. Close the remote desktop session to the myVmPrivate VM.
Clean up resources
When the resource group is no longer needed, delete myResourceGroup and all resources it has:
1. Go to the Azure portal to manage your resource group. Search for and select Resource groups .
2. Pick the name of your resource group (myResourceGroup ).
3. Select Delete resource group .
4. In the confirmation dialog box, enter myResourceGroup for TYPE THE RESOURCE GROUP NAME , and
then select Delete . Azure deletes the myResourceGroup and all resources tied to that resource group,
including your route tables, storage accounts, virtual networks, VMs, network interfaces, and public IP
addresses.
Next steps
In this tutorial, you created a route table and associated it to a subnet. You created a simple NVA that routed traffic
from a public subnet to a private subnet. Now you can deploy different preconfigured NVAs from the Azure
Marketplace, which provide many useful network functions. To learn more about routing, see Routing overview
and Manage a route table.
While you can deploy many Azure resources within a virtual network, Azure can't deploy resources for some PaaS
services into a virtual network. It's possible to restrict access to the resources of some Azure PaaS services,
though the restriction must only be traffic from a virtual network subnet. To learn how to restrict network access
to Azure PaaS resources, see the next tutorial.
Restrict network access to PaaS resources
NOTE
Azure services cost money. Azure Cost Management helps you set budgets and configure alerts to keep spending under
control. Analyze, manage, and optimize your Azure costs with Cost Management. To learn more, see the quickstart on
analyzing your costs.
Route network traffic with a route table using
PowerShell
11/2/2020 • 9 minutes to read • Edit Online
NOTE
This article has been updated to use the new Azure PowerShell Az module. You can still use the AzureRM module, which will
continue to receive bug fixes until at least December 2020. To learn more about the new Az module and AzureRM
compatibility, see Introducing the new Azure PowerShell Az module. For Az module installation instructions, see Install Azure
PowerShell.
Azure automatically routes traffic between all subnets within a virtual network, by default. You can create your own
routes to override Azure's default routing. The ability to create custom routes is helpful if, for example, you want to
route traffic between subnets through a network virtual appliance (NVA). In this article, you learn how to:
Create a route table
Create a route
Create a virtual network with multiple subnets
Associate a route table to a subnet
Create an NVA that routes traffic
Deploy virtual machines (VM) into different subnets
Route traffic from one subnet to another through an NVA
If you don't have an Azure subscription, create a free account before you begin.
O P T IO N EXA M P L E/ L IN K
Select the Cloud Shell button on the menu bar at the upper
right in the Azure portal.
Create a route table with New-AzRouteTable. The following example creates a route table named
myRouteTablePublic.
$routeTablePublic = New-AzRouteTable `
-Name 'myRouteTablePublic' `
-ResourceGroupName myResourceGroup `
-location EastUS
Create a route
Create a route by retrieving the route table object with Get-AzRouteTable, create a route with Add-AzRouteConfig,
then write the route configuration to the route table with Set-AzRouteTable.
Get-AzRouteTable `
-ResourceGroupName "myResourceGroup" `
-Name "myRouteTablePublic" `
| Add-AzRouteConfig `
-Name "ToPrivateSubnet" `
-AddressPrefix 10.0.1.0/24 `
-NextHopType "VirtualAppliance" `
-NextHopIpAddress 10.0.2.4 `
| Set-AzRouteTable
$virtualNetwork = New-AzVirtualNetwork `
-ResourceGroupName myResourceGroup `
-Location EastUS `
-Name myVirtualNetwork `
-AddressPrefix 10.0.0.0/16
Create three subnets by creating three subnet configurations with New-AzVirtualNetworkSubnetConfig. The
following example creates three subnet configurations for Public, Private, and DMZ subnets:
$subnetConfigPublic = Add-AzVirtualNetworkSubnetConfig `
-Name Public `
-AddressPrefix 10.0.0.0/24 `
-VirtualNetwork $virtualNetwork
$subnetConfigPrivate = Add-AzVirtualNetworkSubnetConfig `
-Name Private `
-AddressPrefix 10.0.1.0/24 `
-VirtualNetwork $virtualNetwork
$subnetConfigDmz = Add-AzVirtualNetworkSubnetConfig `
-Name DMZ `
-AddressPrefix 10.0.2.0/24 `
-VirtualNetwork $virtualNetwork
Write the subnet configurations to the virtual network with Set-AzVirtualNetwork, which creates the subnets in the
virtual network:
$virtualNetwork | Set-AzVirtualNetwork
Associate the myRouteTablePublic route table to the Public subnet with Set-AzVirtualNetworkSubnetConfig and
then write the subnet configuration to the virtual network with Set-AzVirtualNetwork.
Set-AzVirtualNetworkSubnetConfig `
-VirtualNetwork $virtualNetwork `
-Name 'Public' `
-AddressPrefix 10.0.0.0/24 `
-RouteTable $routeTablePublic | `
Set-AzVirtualNetwork
Create an NVA
An NVA is a VM that performs a network function, such as routing, firewalling, or WAN optimization.
Before creating a VM, create a network interface.
Create a network interface
Before creating a network interface, you have to retrieve the virtual network Id with Get-AzVirtualNetwork, then
the subnet Id with Get-AzVirtualNetworkSubnetConfig. Create a network interface with New-AzNetworkInterface
in the DMZ subnet with IP forwarding enabled:
# Retrieve the virtual network object into a variable.
$virtualNetwork=Get-AzVirtualNetwork `
-Name myVirtualNetwork `
-ResourceGroupName myResourceGroup
Create a VM
To create a VM and attach an existing network interface to it, you must first create a VM configuration with New-
AzVMConfig. The configuration includes the network interface created in the previous step. When prompted for a
username and password, select the user name and password you want to log into the VM with.
# Create a VM configuration.
$vmConfig = New-AzVMConfig `
-VMName 'myVmNva' `
-VMSize Standard_DS2 | `
Set-AzVMOperatingSystem -Windows `
-ComputerName 'myVmNva' `
-Credential $cred | `
Set-AzVMSourceImage `
-PublisherName MicrosoftWindowsServer `
-Offer WindowsServer `
-Skus 2016-Datacenter `
-Version latest | `
Add-AzVMNetworkInterface -Id $nic.Id
Create the VM using the VM configuration with New-AzVM. The following example creates a VM named
myVmNva.
$vmNva = New-AzVM `
-ResourceGroupName myResourceGroup `
-Location EastUS `
-VM $vmConfig `
-AsJob
The -AsJob option creates the VM in the background, so you can continue to the next step.
New-AzVm `
-ResourceGroupName "myResourceGroup" `
-Location "East US" `
-VirtualNetworkName "myVirtualNetwork" `
-SubnetName "Private" `
-ImageName "Win2016Datacenter" `
-Name "myVmPrivate"
The VM takes a few minutes to create. Don't continue with the next step until the VM is created and Azure returns
output to PowerShell.
Get-AzPublicIpAddress `
-Name myVmPrivate `
-ResourceGroupName myResourceGroup `
| Select IpAddress
Use the following command to create a remote desktop session with the myVmPrivate VM from your local
computer. Replace <publicIpAddress> with the IP address returned from the previous command.
mstsc /v:<publicIpAddress>
Though trace route is used to test routing in this article, allowing ICMP through the Windows Firewall for
production deployments is not recommended.
You enabled IP forwarding within Azure for the VM's network interface in Enable IP forwarding. Within the VM, the
operating system, or an application running within the VM, must also be able to forward network traffic. Enable IP
forwarding within the operating system of the myVmNva.
From a command prompt on the myVmPrivate VM, remote desktop to the myVmNva:
mstsc /v:myvmnva
To enable IP forwarding within the operating system, enter the following command in PowerShell from the
myVmNva VM:
Restart the myVmNva VM, which also disconnects the remote desktop session.
While still connected to the myVmPrivate VM, create a remote desktop session to the myVmPublic VM, after the
myVmNva VM restarts:
mstsc /v:myVmPublic
Enable ICMP through the Windows firewall by entering the following command from PowerShell on the
myVmPublic VM:
To test routing of network traffic to the myVmPrivate VM from the myVmPublic VM, enter the following command
from PowerShell on the myVmPublic VM:
tracert myVmPrivate
1 <1 ms * 1 ms 10.0.2.4
2 1 ms 1 ms 1 ms 10.0.1.4
Trace complete.
You can see that the first hop is 10.0.2.4, which is the NVA's private IP address. The second hop is 10.0.1.4, the
private IP address of the myVmPrivate VM. The route added to the myRouteTablePublic route table and associated
to the Public subnet caused Azure to route the traffic through the NVA, rather than directly to the Private subnet.
Close the remote desktop session to the myVmPublic VM, which leaves you still connected to the myVmPrivate
VM.
To test routing of network traffic to the myVmPublic VM from the myVmPrivate VM, enter the following command
from a command prompt on the myVmPrivate VM:
tracert myVmPublic
1 1 ms 1 ms 1 ms 10.0.0.4
Trace complete.
You can see that traffic is routed directly from the myVmPrivate VM to the myVmPublic VM. By default, Azure
routes traffic directly between subnets.
Close the remote desktop session to the myVmPrivate VM.
Clean up resources
When no longer needed, use Remove-AzResourcegroup to remove the resource group and all of the resources it
contains.
Next steps
In this article, you created a route table and associated it to a subnet. You created a simple network virtual
appliance that routed traffic from a public subnet to a private subnet. Deploy a variety of pre-configured network
virtual appliances that perform network functions such as firewall and WAN optimization from the Azure
Marketplace. To learn more about routing, see Routing overview and Manage a route table.
While you can deploy many Azure resources within a virtual network, resources for some Azure PaaS services
cannot be deployed into a virtual network. You can still restrict access to the resources of some Azure PaaS
services to traffic only from a virtual network subnet though. To learn how, see Restrict network access to PaaS
resources.
Route network traffic with a route table using the
Azure CLI
11/2/2020 • 7 minutes to read • Edit Online
Azure automatically routes traffic between all subnets within a virtual network, by default. You can create your own
routes to override Azure's default routing. The ability to create custom routes is helpful if, for example, you want to
route traffic between subnets through a network virtual appliance (NVA). In this article, you learn how to:
Create a route table
Create a route
Create a virtual network with multiple subnets
Associate a route table to a subnet
Create an NVA that routes traffic
Deploy virtual machines (VM) into different subnets
Route traffic from one subnet to another through an NVA
If you don't have an Azure subscription, create a free account before you begin.
O P T IO N EXA M P L E/ L IN K
Select the Cloud Shell button on the menu bar at the upper
right in the Azure portal.
Create a route table with az network route-table create. The following example creates a route table named
myRouteTablePublic.
Create a route
Create a route in the route table with az network route-table route create.
Associate the myRouteTablePublic route table to the Public subnet with az network vnet subnet update.
Create an NVA
An NVA is a VM that performs a network function, such as routing, firewalling, or WAN optimization.
Create an NVA in the DMZ subnet with az vm create. When you create a VM, Azure creates and assigns a public IP
address to the VM, by default. The --public-ip-address "" parameter instructs Azure not to create and assign a
public IP address to the VM, since the VM doesn't need to be connected to from the internet. If SSH keys do not
already exist in a default key location, the command creates them. To use a specific set of keys, use the
--ssh-key-value option.
az vm create \
--resource-group myResourceGroup \
--name myVmNva \
--image UbuntuLTS \
--public-ip-address "" \
--subnet DMZ \
--vnet-name myVirtualNetwork \
--generate-ssh-keys
The VM takes a few minutes to create. Do not continue to the next step until Azure finishes creating the VM and
returns output about the VM.
For a network interface to be able to forward network traffic sent to it, that is not destined for its own IP address, IP
forwarding must be enabled for the network interface. Enable IP forwarding for the network interface with az
network nic update.
Within the VM, the operating system, or an application running within the VM, must also be able to forward
network traffic. Enable IP forwarding within the VM's operating system with az vm extension set:
az vm extension set \
--resource-group myResourceGroup \
--vm-name myVmNva \
--name customScript \
--publisher Microsoft.Azure.Extensions \
--settings '{"commandToExecute":"sudo sysctl -w net.ipv4.ip_forward=1"}'
adminPassword="<replace-with-your-password>"
az vm create \
--resource-group myResourceGroup \
--name myVmPublic \
--image UbuntuLTS \
--vnet-name myVirtualNetwork \
--subnet Public \
--admin-username azureuser \
--admin-password $adminPassword \
--no-wait
az vm create \
--resource-group myResourceGroup \
--name myVmPrivate \
--image UbuntuLTS \
--vnet-name myVirtualNetwork \
--subnet Private \
--admin-username azureuser \
--admin-password $adminPassword
The VM takes a few minutes to create. After the VM is created, the Azure CLI shows information similar to the
following example:
{
"fqdns": "",
"id": "/subscriptions/00000000-0000-0000-0000-
000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVmPrivate",
"location": "eastus",
"macAddress": "00-0D-3A-23-9A-49",
"powerState": "VM running",
"privateIpAddress": "10.0.1.4",
"publicIpAddress": "13.90.242.231",
"resourceGroup": "myResourceGroup"
}
Take note of the publicIpAddress . This address is used to access the VM from the internet in a later step.
ssh azureuser@<publicIpAddress>
When prompted for a password, enter the password you selected in Create virtual machines.
Use the following command to install trace route on the myVmPrivate VM:
Use the following command to test routing for network traffic to the myVmPublic VM from the myVmPrivate VM.
traceroute myVmPublic
You can see that traffic is routed directly from the myVmPrivate VM to the myVmPublic VM. Azure's default routes,
route traffic directly between subnets.
Use the following command to SSH to the myVmPublic VM from the myVmPrivate VM:
ssh azureuser@myVmPublic
Use the following command to install trace route on the myVmPublic VM:
Use the following command to test routing for network traffic to the myVmPrivate VM from the myVmPublic VM.
traceroute myVmPrivate
You can see that the first hop is 10.0.2.4, which is the NVA's private IP address. The second hop is 10.0.1.4, the
private IP address of the myVmPrivate VM. The route added to the myRouteTablePublic route table and associated
to the Public subnet caused Azure to route the traffic through the NVA, rather than directly to the Private subnet.
Close the SSH sessions to both the myVmPublic and myVmPrivate VMs.
Clean up resources
When no longer needed, use az group delete to remove the resource group and all of the resources it contains.
Next steps
In this article, you created a route table and associated it to a subnet. You created a simple NVA that routed traffic
from a public subnet to a private subnet. Deploy a variety of pre-configured NVAs that perform network functions
such as firewall and WAN optimization from the Azure Marketplace. To learn more about routing, see Routing
overview and Manage a route table.
While you can deploy many Azure resources within a virtual network, resources for some Azure PaaS services
cannot be deployed into a virtual network. You can still restrict access to the resources of some Azure PaaS
services to traffic only from a virtual network subnet though. To learn how, see Restrict network access to PaaS
resources.
Create, change, or delete a route table
11/2/2020 • 11 minutes to read • Edit Online
Azure automatically routes traffic between Azure subnets, virtual networks, and on-premises networks. If you
want to change any of Azure's default routing, you do so by creating a route table. If you're new to routing in
virtual networks, you can learn more about it in virtual network traffic routing or by completing a tutorial.
PowerShell New-AzRouteTable
PowerShell Get-AzRouteTable
PowerShell Get-AzRouteTable
PowerShell Set-AzRouteTable
PowerShell Set-AzVirtualNetworkSubnetConfig
PowerShell Set-AzVirtualNetworkSubnetConfig
PowerShell Remove-AzRouteTable
Create a route
There's a limit to how many routes per route table can create per Azure location and subscription. For details, see
Networking limits - Azure Resource Manager.
1. Go to the Azure portal to manage your route tables. Search for and select Route tables .
2. In the route table list, choose the route table you want to add a route to.
3. From the route table menu bar, choose Routes > Add .
4. Enter a unique Route name for the route within the route table.
5. Enter the Address prefix , in Classless Inter-Domain Routing (CIDR) notation, that you want to route traffic
to. The prefix can't be duplicated in more than one route within the route table, though the prefix can be
within another prefix. For example, if you defined 10.0.0.0/16 as a prefix in one route, you can still define
another route with the 10.0.0.0/22 address prefix. Azure selects a route for traffic based on longest prefix
match. To learn more, see How Azure selects a route.
6. Choose a Next hop type . To learn more about next hop types, see Virtual network traffic routing.
7. If you chose a Next hop type of Vir tual appliance , enter an IP address for Next hop address .
8. Select OK .
Create a route - commands
TO O L C OMMAND
PowerShell New-AzRouteConfig
View routes
A route table contains zero or more routes. To learn more about the information listed when viewing routes, see
Virtual network traffic routing.
1. Go to the Azure portal to manage your route tables. Search for and select Route tables .
2. In the route table list, choose the route table you want to view routes for.
3. In the route table menu bar, choose Routes to see the list of routes.
View routes - commands
TO O L C OMMAND
PowerShell Get-AzRouteConfig
PowerShell Get-AzRouteConfig
Change a route
1. Go to the Azure portal to manage your route tables. Search for and select Route tables .
2. In the route table list, choose the route table containing the route you want to change.
3. In the route table menu bar, choose Routes to see the list of routes.
4. Choose the route you want to change.
5. Change existing settings to their new settings, then select Save .
Change a route - commands
TO O L C OMMAND
PowerShell Set-AzRouteConfig
Delete a route
1. Go to the Azure portal to manage your route tables. Search for and select Route tables .
2. In the route table list, choose the route table containing the route you want to delete.
3. In the route table menu bar, choose Routes to see the list of routes.
4. Choose the route you want to delete.
5. Select Delete , then select Yes in the confirmation dialog box.
Delete a route - commands
TO O L C OMMAND
PowerShell Remove-AzRouteConfig
PowerShell Get-AzEffectiveRouteTable
PowerShell Get-AzNetworkWatcherNextHop
Permissions
To do tasks on route tables and routes, your account must be assigned to the Network contributor role or to a
Custom role that's assigned the appropriate actions listed in the following table:
A C T IO N NAME
Next steps
Create a route table using PowerShell or Azure CLI sample scripts, or Azure Resource Manager templates
Create and assign Azure Policy definitions for virtual networks
Create, change, or delete a network interface
11/2/2020 • 21 minutes to read • Edit Online
Learn how to create, change settings for, and delete a network interface. A network interface enables an Azure
Virtual Machine to communicate with internet, Azure, and on-premises resources. When creating a virtual
machine using the Azure portal, the portal creates one network interface with default settings for you. You may
instead choose to create network interfaces with custom settings and add one or more network interfaces to a
virtual machine when you create it. You may also want to change default network interface settings for an
existing network interface. This article explains how to create a network interface with custom settings, change
existing settings, such as network filter (network security group) assignment, subnet assignment, DNS server
settings, and IP forwarding, and delete a network interface.
If you need to add, change, or remove IP addresses for a network interface, see Manage IP addresses. If you need
to add network interfaces to, or remove network interfaces from virtual machines, see Add or remove network
interfaces.
Complete the following tasks before completing steps in any section of this article:
If you don't already have an Azure account, sign up for a free trial account.
If using the portal, open https://portal.azure.com, and log in with your Azure account.
If using PowerShell commands to complete tasks in this article, either run the commands in the Azure Cloud
Shell, or by running PowerShell from your computer. The Azure Cloud Shell is a free interactive shell that you
can use to run the steps in this article. It has common Azure tools preinstalled and configured to use with your
account. This tutorial requires the Azure PowerShell module version 1.0.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.
If using Azure Command-line interface (CLI) commands to complete tasks in this article, either run the
commands in the Azure Cloud Shell, or by running the CLI from your computer. This tutorial requires the
Azure CLI version 2.0.28 or later. Run az --version to find the installed version. If you need to install or
upgrade, see Install Azure CLI. If you are running the Azure CLI locally, you also need to run az login to
create a connection with Azure.
The account you log into, or connect to Azure with, must be assigned to the network contributor role or to a
custom role that is assigned the appropriate actions listed in Permissions.
IPv6 name (only appears when the Yes, if the Private IP address This name is assigned to a
Private IP address (IPv6) (IPv6) checkbox is checked. secondary IP configuration for the
checkbox is checked) network interface. To learn more
about IP configurations, see View
network interface settings.
The portal doesn't provide the option to assign a public IP address to the network interface when you create it,
though the portal does create a public IP address and assign it to a network interface when you create a virtual
machine using the portal. To learn how to add a public IP address to the network interface after creating it, see
Manage IP addresses. If you want to create a network interface with a public IP address, you must use the CLI or
PowerShell to create the network interface.
The portal doesn't provide the option to assign the network interface to application security groups when
creating a network interface, but the Azure CLI and PowerShell do. You can assign an existing network interface to
an application security group using the portal however, as long as the network interface is attached to a virtual
machine. To learn how to assign a network interface to an application security group, see Add to or remove from
application security groups.
NOTE
Azure assigns a MAC address to the network interface only after the network interface is attached to a virtual machine and
the virtual machine is started the first time. You cannot specify the MAC address that Azure assigns to the network
interface. The MAC address remains assigned to the network interface until the network interface is deleted or the private
IP address assigned to the primary IP configuration of the primary network interface is changed. To learn more about IP
addresses and IP configurations, see Manage IP addresses
Commands
TO O L C OMMAND
PowerShell New-AzNetworkInterface
You can move a network interface to a different resource group or subscription by selecting
(change ) next to the Resource group or Subscription name . If you move the network interface
to a new subscription, you must move all resources related to the network interface with it. If the
network interface is attached to a virtual machine, for example, you must also move the virtual
machine, and other virtual machine-related resources. To move a network interface, see Move
resource to a new resource group or subscription. The article lists prerequisites, and how to move
resources using the Azure portal, PowerShell, and the Azure CLI.
IP configurations: Public and private IPv4 and IPv6 addresses assigned to IP configurations are
listed here. If an IPv6 address is assigned to an IP configuration, the address is not displayed. To
learn more about IP configurations and how to add and remove IP addresses, see Configure IP
addresses for an Azure network interface. IP forwarding and subnet assignment are also configured
in this section. To learn more about these settings, see Enable or disable IP forwarding and Change
subnet assignment.
DNS ser vers: You can specify which DNS server a network interface is assigned by the Azure
DHCP servers. The network interface can inherit the setting from the virtual network the network
interface is assigned to, or have a custom setting that overrides the setting for the virtual network
it's assigned to. To modify what's displayed, see Change DNS servers.
Network security group (NSG): Displays which NSG is associated to the network interface (if
any). An NSG contains inbound and outbound rules to filter network traffic for the network
interface. If an NSG is associated to the network interface, the name of the associated NSG is
displayed. To modify what's displayed, see Associate or dissociate a network security group.
Proper ties: Displays key settings about the network interface, including its MAC address (blank if
the network interface isn't attached to a virtual machine), and the subscription it exists in.
Effective security rules: Security rules are listed if the network interface is attached to a running
virtual machine, and an NSG is associated to the network interface, the subnet it's assigned to, or
both. To learn more about what's displayed, see View effective security rules. To learn more about
NSGs, see Network security groups.
Effective routes: Routes are listed if the network interface is attached to a running virtual
machine. The routes are a combination of the Azure default routes, any user-defined routes, and any
BGP routes that may exist for the subnet the network interface is assigned to. To learn more about
what's displayed, see View effective routes. To learn more about Azure default routes and user-
defined routes, see Routing overview. Common Azure Resource Manager settings: To learn more
about common Azure Resource Manager settings, see Activity log, Access control (IAM), Tags, Locks,
and Automation script.
Commands
If an IPv6 address is assigned to a network interface, the PowerShell output returns the fact that the address is
assigned, but it doesn't return the assigned address. Similarly, the CLI returns the fact that the address is assigned,
but returns null in its output for the address.
TO O L C OMMAND
NOTE
If the VM uses a NIC that's part of an availability set, all the DNS servers that are specified for each of the
VMs from all NICs that are part of the availability set will be inherited.
5. Select Save .
Commands
TO O L C OMMAND
PowerShell Set-AzNetworkInterface
TO O L C OMMAND
PowerShell Set-AzNetworkInterface
TO O L C OMMAND
PowerShell Set-AzNetworkInterfaceIpConfig
PowerShell Set-AzNetworkInterface
TO O L C OMMAND
PowerShell Remove-AzNetworkInterface
Permissions
To perform tasks on network interfaces, your account must be assigned to the network contributor role or to a
custom role that is assigned the appropriate permissions listed in the following table:
A C T IO N NAME
Next steps
Create a VM with multiple NICs using the Azure CLI or PowerShell
Create a single NIC VM with multiple IPv4 addresses using the Azure CLI or PowerShell
Create a single NIC VM with a private IPv6 address (behind an Azure Load Balancer) using the Azure CLI,
PowerShell, or Azure Resource Manager template
Create a network interface using PowerShell or Azure CLI sample scripts, or using Azure Resource Manager
template
Create and assign Azure Policy definitions for virtual networks
Create, change, or delete a virtual network
11/2/2020 • 13 minutes to read • Edit Online
NOTE
This article has been updated to use the new Azure PowerShell Az module. You can still use the AzureRM module, which will
continue to receive bug fixes until at least December 2020. To learn more about the new Az module and AzureRM
compatibility, see Introducing the new Azure PowerShell Az module. For Az module installation instructions, see Install Azure
PowerShell.
Learn how to create and delete a virtual network and change settings, like DNS servers and IP address spaces, for
an existing virtual network. If you're new to virtual networks, you can learn more about them in the Virtual
network overview or by completing a tutorial. A virtual network contains subnets. To learn how to create, change,
and delete subnets, see Manage subnets.
WARNING
If a virtual network has address ranges that overlap with another virtual network or on-premises network,
the two networks can't be connected. Before you define an address range, consider whether you might want
to connect the virtual network to other virtual networks or on-premises networks in the future. Microsoft
recommends configuring virtual network address ranges with private address space or public address space
owned by your organization.
Subnet name : The subnet name must be unique within the virtual network. You cannot
change the subnet name after the subnet is created. The portal requires that you define one
subnet when you create a virtual network, even though a virtual network isn't required to
have any subnets. In the portal, you can define only one subnet when you create a virtual
network. You can add more subnets to the virtual network later, after the virtual network is
created. To add a subnet to a virtual network, see Manage subnets. You can create a virtual
network that has multiple subnets by using Azure CLI or PowerShell.
TIP
Sometimes, administrators create different subnets to filter or control traffic routing between the
subnets. Before you define subnets, consider how you might want to filter and route traffic between
your subnets. To learn more about filtering traffic between subnets, see Network security groups.
Azure automatically routes traffic between subnets, but you can override Azure default routes. To
learn more about Azures default subnet traffic routing, see Routing overview.
Subnet address range : The range must be within the address space you entered for the
virtual network. The smallest range you can specify is /29, which provides eight IP addresses
for the subnet. Azure reserves the first and last address in each subnet for protocol
conformance. Three additional addresses are reserved for Azure service usage. As a result, a
virtual network with a subnet address range of /29 has only three usable IP addresses. If you
plan to connect a virtual network to a VPN gateway, you must create a gateway subnet. Learn
more about specific address range considerations for gateway subnets. You can change the
address range after the subnet is created, under specific conditions. To learn how to change a
subnet address range, see Manage subnets.
Subscription : Select a subscription. You cannot use the same virtual network in more than
one Azure subscription. However, you can connect a virtual network in one subscription to
virtual networks in other subscriptions with virtual network peering. Any Azure resource that
you connect to the virtual network must be in the same subscription as the virtual network.
Resource group : Select an existing resource group or create a new one. An Azure resource
that you connect to the virtual network can be in the same resource group as the virtual
network or in a different resource group.
Location : Select an Azure location, also known as a region. A virtual network can be in only
one Azure location. However, you can connect a virtual network in one location to a virtual
network in another location by using a VPN gateway. Any Azure resource that you connect to
the virtual network must be in the same location as the virtual network.
Commands
Azure CLI: az network vnet create
PowerShell: New-AzVirtualNetwork
You can move a virtual network to a different subscription or resource group by selecting Change
next to Resource group or Subscription name . To learn how to move a virtual network, see
Move resources to a different resource group or subscription. The article lists prerequisites, and how
to move resources by using the Azure portal, PowerShell, and Azure CLI. All resources that are
connected to the virtual network must move with the virtual network.
Address space : The address spaces that are assigned to the virtual network are listed. To learn how
to add and remove an address range to the address space, complete the steps in Add or remove an
address range.
Connected devices : Any resources that are connected to the virtual network are listed. In the
preceding screenshot, three network interfaces and one load balancer are connected to the virtual
network. Any new resources that you create and connect to the virtual network are listed. If you
delete a resource that was connected to the virtual network, it no longer appear in the list.
Subnets : A list of subnets that exist within the virtual network is shown. To learn how to add and
remove a subnet, see Manage subnets.
DNS ser vers : You can specify whether the Azure internal DNS server or a custom DNS server
provides name resolution for devices that are connected to the virtual network. When you create a
virtual network by using the Azure portal, Azure's DNS servers are used for name resolution within
a virtual network, by default. To modify the DNS servers, complete the steps in Change DNS servers
in this article.
Peerings : If there are existing peerings in the subscription, they are listed here. You can view
settings for existing peerings, or create, change, or delete peerings. To learn more about peerings,
see Virtual network peering.
Proper ties : Displays settings about the virtual network, including the virtual network's resource ID
and the Azure subscription it is in.
Diagram : The diagram provides a visual representation of all devices that are connected to the
virtual network. The diagram has some key information about the devices. To manage a device in
this view, in the diagram, select the device.
Common Azure settings : To learn more about common Azure settings, see the following
information:
Activity log
Access control (IAM)
Tags
Locks
Automation script
Commands
Azure CLI: az network vnet show
PowerShell: Get-AzVirtualNetwork
Permissions
To perform tasks on virtual networks, your account must be assigned to the network contributor role or to a
custom role that is assigned the appropriate actions listed in the following table:
A C T IO N NAME
Next steps
Create a virtual network using PowerShell or Azure CLI sample scripts, or using Azure Resource Manager
templates
Create and assign Azure Policy definitions for virtual networks
Add, change, or delete a virtual network subnet
11/2/2020 • 8 minutes to read • Edit Online
Learn how to add, change, or delete a virtual network subnet. All Azure resources deployed into a virtual network
are deployed into a subnet within a virtual network. If you're new to virtual networks, you can learn more about
them in the Virtual network overview or by completing a quickstart. To learn more about managing a virtual
network, see Create, change, or delete a virtual network.
Add a subnet
1. Go to the Azure portal to view your virtual networks. Search for and select Vir tual networks .
2. Select the name of the virtual network you want to add a subnet to.
3. From Settings , select Subnets > Subnet .
4. In the Add subnet dialog box, enter values for the following settings:
Name The name must be unique within the virtual network. For
maximum compatibility with other Azure services, we
recommend using a letter as the first character of the
name. For example, Azure Application Gateway won't
deploy into a subnet that has a name that starts with a
number.
SET T IN G DESC RIP T IO N
Address range The range must be unique within the address space
for the virtual network. The range can't overlap with
other subnet address ranges within the virtual
network. The address space must be specified by
using Classless Inter-Domain Routing (CIDR)
notation.
For example, in a virtual network with address space
10.0.0.0/16, you might define a subnet address space
of 10.0.0.0/22. The smallest range you can specify is
/29, which provides eight IP addresses for the
subnet. Azure reserves the first and last address in
each subnet for protocol conformance. Three
additional addresses are reserved for Azure service
usage. As a result, defining a subnet with a /29
address range results in three usable IP addresses in
the subnet.
If you plan to connect a virtual network to a VPN
gateway, you must create a gateway subnet. Learn
more about specific address range considerations for
gateway subnets. You can change the address range
after the subnet is added, under specific conditions.
To learn how to change a subnet address range, see
Change subnet settings.
Network security group To filter inbound and outbound network traffic for the
subnet, you may associate an existing network security
group to a subnet. The network security group must exist
in the same subscription and location as the virtual
network. Learn more about network security groups and
how to create a network security group.
Ser vice endpoints A subnet may optionally have one or more service
endpoints enabled for it. To enable a service endpoint
for a service, select the service or services that you
want to enable service endpoints for from the
Ser vices list. Azure configures the location
automatically for an endpoint. By default, Azure
configures the service endpoints for the virtual
network's region. To support regional failover
scenarios, Azure automatically configures endpoints
to Azure paired regions for Azure Storage.
To remove a service endpoint, unselect the service
you want to remove the service endpoint for. To learn
more about service endpoints, and the services they
can be enabled for, see Virtual network service
endpoints. Once you enable a service endpoint for a
service, you must also enable network access for the
subnet for a resource created with the service. For
example, if you enable the service endpoint for
Microsoft.Storage , you must also enable network
access to all Azure Storage accounts you want to
grant network access to. To enable network access to
subnets that a service endpoint is enabled for, see
the documentation for the individual service you
enabled the service endpoint for.
To validate that a service endpoint is enabled for a
subnet, view the effective routes for any network
interface in the subnet. When you configure an
endpoint, you see a default route with the address
prefixes of the service, and a next hop type of
Vir tualNetworkSer viceEndpoint . To learn more
about routing, see Virtual network traffic routing.
5. To add the subnet to the virtual network that you selected, select OK .
Commands
TO O L C OMMAND
PowerShell Add-AzVirtualNetworkSubnetConfig
Address range If no resources are deployed within the subnet, you can
change the address range. If any resources exist in the
subnet, you must either move the resources to another
subnet, or delete them from the subnet first. The steps
you take to move or delete a resource vary depending
on the resource. To learn how to move or delete
resources that are in subnets, read the documentation
for each of those resource types. See the constraints for
Address range in step 4 of Add a subnet.
Network security group and Route table See step 4 of Add a subnet.
6. Select Save .
Commands
TO O L C OMMAND
PowerShell Set-AzVirtualNetworkSubnetConfig
Delete a subnet
You can delete a subnet only if there are no resources in the subnet. If resources are in the subnet, you must
delete those resources before you can delete the subnet. The steps you take to delete a resource vary depending
on the resource. To learn how to delete resources that are in subnets, read the documentation for each of those
resource types.
1. Go to the Azure portal to view your virtual networks. Search for and select Vir tual networks .
2. Select the name of the virtual network containing the subnet you want to delete.
3. From Settings , select Subnets .
4. In the list of subnets, select the subnet you want to delete.
5. Select Delete , and then select Yes in the confirmation dialog box.
Commands
TO O L C OMMAND
PowerShell Remove-AzVirtualNetworkSubnetConfig
Permissions
To do tasks on subnets, your account must be assigned to the Network contributor role or to a Custom role that's
assigned the appropriate actions in the following table:
A C T IO N NAME
Next steps
Create a virtual network and subnets using PowerShell or Azure CLI sample scripts, or using Azure Resource
Manager templates
Create and assign Azure Policy definitions for virtual networks
Add or remove a subnet delegation
11/2/2020 • 6 minutes to read • Edit Online
Subnet delegation gives explicit permissions to the service to create service-specific resources in the subnet using
a unique identifier when deploying the service. This article describes how to add or remove a delegated subnet for
an Azure service.
Portal
Sign in to Azure
Sign in to the Azure portal at https://portal.azure.com.
Create the virtual network
In this section, you create a virtual network and the subnet that you'll later delegate to an Azure service.
1. On the upper-left side of the screen, select Create a resource > Networking > Vir tual network .
2. In Create vir tual network , enter or select this information:
SET T IN G VA L UE
The built-in Network Contributor role also contains the necessary permissions.
Delegate a subnet to an Azure service
In this section, you delegate the subnet that you created in the preceding section to an Azure service.
1. In the portal's search bar, enter myVirtualNetwork. When myVir tualNetwork appears in the search results,
select it.
2. In the search results, select myVirtualNetwork.
3. Select Subnets , under SETTINGS , and then select mySubnet .
4. On the mySubnet page, for the Subnet delegation list, select from the services listed under Delegate subnet
to a ser vice (for example, Microsoft.DBforPostgreSQL/ser versv2 ).
Remove subnet delegation from an Azure service
1. In the portal's search bar, enter myVirtualNetwork. When myVir tualNetwork appears in the search results,
select it.
2. In the search results, select myVirtualNetwork.
3. Select Subnets , under SETTINGS , and then select mySubnet .
4. In mySubnet page, for the Subnet delegation list, select None from the services listed under Delegate
subnet to a ser vice .
Azure CLI
Use Azure Cloud Shell
Azure hosts Azure Cloud Shell, an interactive shell environment that you can use through your browser. You can
use either Bash or PowerShell with Cloud Shell to work with Azure services. You can use the Cloud Shell
preinstalled commands to run the code in this article without having to install anything on your local environment.
To start Azure Cloud Shell:
O P T IO N EXA M P L E/ L IN K
Select the Cloud Shell button on the menu bar at the upper
right in the Azure portal.
Permissions
If you didn't create the subnet you would like to delegate to an Azure service, you need the following permission:
Microsoft.Network/virtualNetworks/subnets/write .
The built-in Network Contributor role also contains the necessary permissions.
Delegate a subnet to an Azure service
In this section, you delegate the subnet that you created in the preceding section to an Azure service.
Use az network vnet subnet update to update the subnet named mySubnet with a delegation to an Azure service.
In this example Microsoft.DBforPostgreSQL/ser versv2 is used for the example delegation:
To verify the delegation was applied, use az network vnet subnet show. Verify the service is delegated to the subnet
under the property ser viceName :
To verify the delegation was removed, use az network vnet subnet show. Verify the service is removed from the
subnet under the property ser viceName :
[]
Azure PowerShell
NOTE
This article has been updated to use the new Azure PowerShell Az module. You can still use the AzureRM module, which will
continue to receive bug fixes until at least December 2020. To learn more about the new Az module and AzureRM
compatibility, see Introducing the new Azure PowerShell Az module. For Az module installation instructions, see Install Azure
PowerShell.
Connect to Azure
Connect-AzAccount
Permissions
If you didn't create the subnet you would like to delegate to an Azure service, you need the following permission:
Microsoft.Network/virtualNetworks/subnets/write .
The built-in Network Contributor role also contains the necessary permissions.
Delegate a subnet to an Azure service
In this section, you delegate the subnet that you created in the preceding section to an Azure service.
Use Add-AzDelegation to update the subnet named mySubnet with a delegation named myDelegation to an
Azure service. In this example Microsoft.DBforPostgreSQL/ser versv2 is used for the example delegation:
ProvisioningState : Succeeded
ServiceName : Microsoft.DBforPostgreSQL/serversv2
Actions : {Microsoft.Network/virtualNetworks/subnets/join/action}
Name : myDelegation
Etag : W/"9cba4b0e-2ceb-444b-b553-454f8da07d8a"
Id : /subscriptions/3bf09329-ca61-4fee-88cb-
7e30b9ee305b/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubne
t/delegations/myDelegation
Next steps
Learn how to manage subnets in Azure.
Connect virtual networks with virtual network peering
using PowerShell
11/2/2020 • 6 minutes to read • Edit Online
NOTE
This article has been updated to use the new Azure PowerShell Az module. You can still use the AzureRM module, which will
continue to receive bug fixes until at least December 2020. To learn more about the new Az module and AzureRM
compatibility, see Introducing the new Azure PowerShell Az module. For Az module installation instructions, see Install Azure
PowerShell.
You can connect virtual networks to each other with virtual network peering. Once virtual networks are peered,
resources in both virtual networks are able to communicate with each other, with the same latency and bandwidth
as if the resources were in the same virtual network. In this article, you learn how to:
Create two virtual networks
Connect two virtual networks with a virtual network peering
Deploy a virtual machine (VM) into each virtual network
Communicate between VMs
If you don't have an Azure subscription, create a free account before you begin.
O P T IO N EXA M P L E/ L IN K
Select the Cloud Shell button on the menu bar at the upper
right in the Azure portal.
Create a virtual network with New-AzVirtualNetwork. The following example creates a virtual network named
myVirtualNetwork1 with the address prefix 10.0.0.0/16.
$virtualNetwork1 = New-AzVirtualNetwork `
-ResourceGroupName myResourceGroup `
-Location EastUS `
-Name myVirtualNetwork1 `
-AddressPrefix 10.0.0.0/16
Create a subnet configuration with New-AzVirtualNetworkSubnetConfig. The following example creates a subnet
configuration with a 10.0.0.0/24 address prefix:
$subnetConfig = Add-AzVirtualNetworkSubnetConfig `
-Name Subnet1 `
-AddressPrefix 10.0.0.0/24 `
-VirtualNetwork $virtualNetwork1
Write the subnet configuration to the virtual network with Set-AzVirtualNetwork, which creates the subnet:
$virtualNetwork1 | Set-AzVirtualNetwork
Create a virtual network with a 10.1.0.0/16 address prefix and one subnet:
Add-AzVirtualNetworkPeering `
-Name myVirtualNetwork1-myVirtualNetwork2 `
-VirtualNetwork $virtualNetwork1 `
-RemoteVirtualNetworkId $virtualNetwork2.Id
In the output returned after the previous command executes, you see that the PeeringState is Initiated. The
peering remains in the Initiated state until you create the peering from myVirtualNetwork2 to myVirtualNetwork1.
Create a peering from myVirtualNetwork2 to myVirtualNetwork1.
Add-AzVirtualNetworkPeering `
-Name myVirtualNetwork2-myVirtualNetwork1 `
-VirtualNetwork $virtualNetwork2 `
-RemoteVirtualNetworkId $virtualNetwork1.Id
In the output returned after the previous command executes, you see that the PeeringState is Connected. Azure
also changed the peering state of the myVirtualNetwork1-myVirtualNetwork2 peering to Connected. Confirm that
the peering state for the myVirtualNetwork1-myVirtualNetwork2 peering changed to Connected with Get-
AzVirtualNetworkPeering.
Get-AzVirtualNetworkPeering `
-ResourceGroupName myResourceGroup `
-VirtualNetworkName myVirtualNetwork1 `
| Select PeeringState
Resources in one virtual network cannot communicate with resources in the other virtual network until the
PeeringState for the peerings in both virtual networks is Connected.
New-AzVm `
-ResourceGroupName "myResourceGroup" `
-Location "East US" `
-VirtualNetworkName "myVirtualNetwork1" `
-SubnetName "Subnet1" `
-ImageName "Win2016Datacenter" `
-Name "myVm1" `
-AsJob
The VM takes a few minutes to create. Do not continue with later steps until Azure creates the VM and returns
output to PowerShell.
Get-AzPublicIpAddress `
-Name myVm1 `
-ResourceGroupName myResourceGroup | Select IpAddress
Use the following command to create a remote desktop session with the myVm1 VM from your local computer.
Replace <publicIpAddress> with the IP address returned from the previous command.
mstsc /v:<publicIpAddress>
A Remote Desktop Protocol (.rdp) file is created, downloaded to your computer, and opened. Enter the user name
and password (you may need to select More choices , then Use a different account , to specify the credentials
you entered when you created the VM), and then click OK . You may receive a certificate warning during the sign-in
process. Click Yes or Continue to proceed with the connection.
On the myVm1 VM, enable the Internet Control Message Protocol (ICMP) through the Windows firewall so you can
ping this VM from myVm2 in a later step, using PowerShell:
Though ping is used to communicate between VMs in this article, allowing ICMP through the Windows Firewall for
production deployments is not recommended.
To connect to the myVm2 VM, enter the following command from a command prompt on the myVm1 VM:
mstsc /v:10.1.0.4
Since you enabled ping on myVm1, you can now ping it by IP address from a command prompt on the myVm2
VM:
ping 10.0.0.4
You receive four replies. Disconnect your RDP sessions to both myVm1 and myVm2.
Clean up resources
When no longer needed, use Remove-AzResourcegroup to remove the resource group and all of the resources it
contains.
Next steps
In this article, you learned how to connect two networks in the same Azure region, with virtual network peering.
You can also peer virtual networks in different supported regions and in different Azure subscriptions, as well as
create hub and spoke network designs with peering. To learn more about virtual network peering, see Virtual
network peering overview and Manage virtual network peerings.
You can connect your own computer to a virtual network through a VPN, and interact with resources in a virtual
network, or in peered virtual networks. For reusable scripts to complete many of the tasks covered in the virtual
network articles, see script samples.
Connect virtual networks with virtual network peering
using the Azure CLI
11/2/2020 • 5 minutes to read • Edit Online
You can connect virtual networks to each other with virtual network peering. Once virtual networks are peered,
resources in both virtual networks are able to communicate with each other, with the same latency and bandwidth
as if the resources were in the same virtual network. In this article, you learn how to:
Create two virtual networks
Connect two virtual networks with a virtual network peering
Deploy a virtual machine (VM) into each virtual network
Communicate between VMs
If you don't have an Azure subscription, create a free account before you begin.
O P T IO N EXA M P L E/ L IN K
Select the Cloud Shell button on the menu bar at the upper
right in the Azure portal.
Create a virtual network with az network vnet create. The following example creates a virtual network named
myVirtualNetwork1 with the address prefix 10.0.0.0/16.
Create a virtual network named myVirtualNetwork2 with the address prefix 10.1.0.0/16:
Create a peering from myVirtualNetwork1 to myVirtualNetwork2 with az network vnet peering create. If the
--allow-vnet-access parameter is not specified, a peering is established, but no communication can flow through
it.
In the output returned after the previous command executes, you see that the peeringState is Initiated. The
peering remains in the Initiated state until you create the peering from myVirtualNetwork2 to myVirtualNetwork1.
Create a peering from myVirtualNetwork2 to myVirtualNetwork1.
In the output returned after the previous command executes, you see that the peeringState is Connected. Azure
also changed the peering state of the myVirtualNetwork1-myVirtualNetwork2 peering to Connected. Confirm that
the peering state for the myVirtualNetwork1-myVirtualNetwork2 peering changed to Connected with az network
vnet peering show.
Resources in one virtual network cannot communicate with resources in the other virtual network until the
peeringState for the peerings in both virtual networks is Connected.
az vm create \
--resource-group myResourceGroup \
--name myVm1 \
--image UbuntuLTS \
--vnet-name myVirtualNetwork1 \
--subnet Subnet1 \
--generate-ssh-keys \
--no-wait
az vm create \
--resource-group myResourceGroup \
--name myVm2 \
--image UbuntuLTS \
--vnet-name myVirtualNetwork2 \
--subnet Subnet1 \
--generate-ssh-keys
The VM takes a few minutes to create. After the VM is created, the Azure CLI shows information similar to the
following example:
{
"fqdns": "",
"id": "/subscriptions/00000000-0000-0000-0000-
000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVm2",
"location": "eastus",
"macAddress": "00-0D-3A-23-9A-49",
"powerState": "VM running",
"privateIpAddress": "10.1.0.4",
"publicIpAddress": "13.90.242.231",
"resourceGroup": "myResourceGroup"
}
Take note of the publicIpAddress . This address is used to access the VM from the internet in a later step.
ssh <publicIpAddress>
ping 10.0.0.4 -c 4
Clean up resources
When no longer needed, use az group delete to remove the resource group and all of the resources it contains.
Next steps
In this article, you learned how to connect two networks in the same Azure region, with virtual network peering.
You can also peer virtual networks in different supported regions and in different Azure subscriptions, as well as
create hub and spoke network designs with peering. To learn more about virtual network peering, see Virtual
network peering overview and Manage virtual network peerings.
You can connect your own computer to a virtual network through a VPN, and interact with resources in a virtual
network, or in peered virtual networks. For reusable scripts to complete many of the tasks covered in the virtual
network articles, see script samples.
Create a virtual network peering - Resource
Manager, different subscriptions and Azure Active
Directory tenants
11/2/2020 • 16 minutes to read • Edit Online
In this tutorial, you learn to create a virtual network peering between virtual networks created through Resource
Manager. The virtual networks exist in different subscriptions that may belong to different Azure Active Directory
(Azure AD) tenants. Peering two virtual networks enables resources in different virtual networks to communicate
with each other with the same bandwidth and latency as though the resources were in the same virtual network.
Learn more about Virtual network peering.
The steps to create a virtual network peering are different, depending on whether the virtual networks are in the
same, or different, subscriptions, and which Azure deployment model the virtual networks are created through.
Learn how to create a virtual network peering in other scenarios by selecting the scenario from the following table:
A virtual network peering cannot be created between two virtual networks deployed through the classic
deployment model. If you need to connect virtual networks that were both created through the classic deployment
model, you can use an Azure VPN Gateway to connect the virtual networks.
This tutorial peers virtual networks in the same region. You can also peer virtual networks in different supported
regions. It's recommended that you familiarize yourself with the peering requirements and constraints before
peering virtual networks.
You can use the Azure portal, the Azure command-line interface (CLI), Azure PowerShell, or an Azure Resource
Manager template to create a virtual network peering. Select any of the previous tool links to go directly to the
steps for creating a virtual network peering using your tool of choice.
If the virtual networks are in different subscriptions, and the subscriptions are associated with different Azure
Active Directory tenants, complete the following steps before continuing:
1. Add the user from each Active Directory tenant as a guest user in the opposite Azure Active Directory tenant.
2. Each user must accept the guest user invitation from the opposite Azure Active Directory tenant.
3. Log out of Azure as UserA using the az logout command, then log in to Azure as UserB. The account you
log in with must have the necessary permissions to create a virtual network peering. For a list of
permissions, see Virtual network peering permissions.
4. Create myVnetB. Copy the script contents in step 2 to a text editor on your PC. Replace <SubscriptionA-Id>
with the ID of SubscriptionB. Change 10.0.0.0/16 to 10.1.0.0/16, change all As to B, and all Bs to A. Copy the
modified script, paste it in to your CLI session, and press Enter .
5. Log out of Azure as UserB and log in to Azure as UserA.
6. Create a virtual network peering from myVnetA to myVnetB. Copy the following script contents to a text
editor on your PC. Replace <SubscriptionB-Id> with the ID of SubscriptionB. To execute the script, copy the
modified script, paste it into your CLI session, and press Enter.
# Get the id for myVnetA.
vnetAId=$(az network vnet show \
--resource-group myResourceGroupA \
--name myVnetA \
--query id --out tsv)
The state is Initiated . It changes to Connected once you create the peering to myVnetA from myVnetB.
8. Log out UserA from Azure and log in to Azure as UserB.
9. Create the peering from myVnetB to myVnetA. Copy the script contents in step 6 to a text editor on your PC.
Replace <SubscriptionB-Id> with the ID for SubscriptionA and change all As to B and all Bs to A. Once
you've made the changes, copy the modified script, paste it into your CLI session, and press Enter .
10. View the peering state of myVnetB. Copy the script contents in step 7 to a text editor on your PC. Change A
to B for the resource group and virtual network names, copy the script, paste the modified script in to your
CLI session, and then press Enter . The peering state is Connected . The peering state of myVnetA changes
to Connected after you've created the peering from myVnetB to myVnetA. You can log UserA back in to
Azure and complete step 7 again to verify the peering state of myVnetA.
NOTE
The peering is not established until the peering state is Connected for both virtual networks.
11. Optional : Though creating virtual machines is not covered in this tutorial, you can create a virtual machine
in each virtual network and connect from one virtual machine to the other, to validate connectivity.
12. Optional : To delete the resources that you create in this tutorial, complete the steps in Delete resources in
this article.
Any Azure resources you create in either virtual network are now able to communicate with each other through
their IP addresses. If you're using default Azure name resolution for the virtual networks, the resources in the
virtual networks are not able to resolve names across the virtual networks. If you want to resolve names across
virtual networks in a peering, you must create your own DNS server. Learn how to set up Name resolution using
your own DNS server.
This tutorial uses different accounts for each subscription. If you're using an account that has permissions to both
subscriptions, you can use the same account for all steps, skip the steps for logging out of Azure, and remove the
lines of script that create user role assignments. Replace UserA@azure.com and UserB@azure.com in all of the
following scripts with the usernames you're using for UserA and UserB.
1. Confirm that you have Azure PowerShell version 1.0.0 or higher. You can do this by running the
Get-Module -Name Az We recommend installing the latest version of the PowerShell Az module. If you're
new to Azure PowerShell, see Azure PowerShell overview.
2. Start a PowerShell session.
3. In PowerShell, log in to Azure as UserA by entering the Connect-AzAccount command. The account you log
in with must have the necessary permissions to create a virtual network peering. For a list of permissions,
see Virtual network peering permissions.
4. Create a resource group and virtual network A. Copy the following script to a text editor on your PC.
Replace <SubscriptionA-Id> with the ID of SubscriptionA. If you don't know your subscription Id, enter the
Get-AzSubscription command to view it. The value for Id in the returned output is your subscription ID. To
execute the script, copy the modified script, paste it in to PowerShell, and then press Enter .
5. Log out UserA from Azure and log in UserB. The account you log in with must have the necessary
permissions to create a virtual network peering. For a list of permissions, see Virtual network peering
permissions.
6. Copy the script contents in step 4 to a text editor on your PC. Replace <SubscriptionA-Id> with the ID for
subscription B. Change 10.0.0.0/16 to 10.1.0.0/16. Change all As to B and all Bs to A. To execute the script,
copy the modified script, paste into PowerShell, and then press Enter .
7. Log out UserB from Azure and log in UserA.
8. Create the peering from myVnetA to myVnetB. Copy the following script to a text editor on your PC. Replace
<SubscriptionB-Id> with the ID of subscription B. To execute the script, copy the modified script, paste in to
PowerShell, and then press Enter .
Get-AzVirtualNetworkPeering `
-ResourceGroupName myResourceGroupA `
-VirtualNetworkName myVnetA `
| Format-Table VirtualNetworkName, PeeringState
The state is Initiated . It changes to Connected once you set up the peering to myVnetA from myVnetB.
10. Log out UserA from Azure and log in UserB.
11. Create the peering from myVnetB to myVnetA. Copy the script contents in step 8 to a text editor on your PC.
Replace <SubscriptionB-Id> with the ID of subscription A and change all As to B and all Bs to A. To execute
the script, copy the modified script, paste it in to PowerShell, and then press Enter .
12. View the peering state of myVnetB. Copy the script contents in step 9 to a text editor on your PC. Change A
to B for the resource group and virtual network names. To execute the script, paste the modified script into
PowerShell, and then press Enter . The state is Connected . The peering state of myVnetA changes to
Connected after you've created the peering from myVnetB to myVnetA . You can log UserA back in to
Azure and complete step 9 again to verify the peering state of myVnetA.
NOTE
The peering is not established until the peering state is Connected for both virtual networks.
Any Azure resources you create in either virtual network are now able to communicate with each other
through their IP addresses. If you're using default Azure name resolution for the virtual networks, the
resources in the virtual networks are not able to resolve names across the virtual networks. If you want to
resolve names across virtual networks in a peering, you must create your own DNS server. Learn how to set
up Name resolution using your own DNS server.
13. Optional : Though creating virtual machines is not covered in this tutorial, you can create a virtual machine
in each virtual network and connect from one virtual machine to the other, to validate connectivity.
14. Optional : To delete the resources that you create in this tutorial, complete the steps in Delete resources in
this article.
3. Log in to Azure as UserA and deploy the template using the portal, PowerShell, or the Azure CLI. Specify the
file name you saved the example json text in step 2 to.
4. Copy the example json from step 2 to a file on your computer and make changes to the lines that begin
with:
name : Change myVnetA/myVnetAToMyVnetB to myVnetB/myVnetBToMyVnetA.
id : Replace <subscription ID> with UserB's subscription ID and change myVnetB to myVnetA.
5. Complete step 3 again, logged in to Azure as UserB.
6. Optional : Though creating virtual machines is not covered in this tutorial, you can create a virtual machine
in each virtual network and connect from one virtual machine to the other, to validate connectivity.
7. Optional : To delete the resources that you create in this tutorial, complete the steps in the Delete resources
section of this article, using either the Azure portal, PowerShell, or the Azure CLI.
Delete resources
When you've finished this tutorial, you might want to delete the resources you created in the tutorial, so you don't
incur usage charges. Deleting a resource group also deletes all resources that are in the resource group.
Azure portal
1. Log in to the Azure portal as UserA.
2. In the portal search box, enter myResourceGroupA . In the search results, select myResourceGroupA .
3. Select Delete .
4. To confirm the deletion, in the TYPE THE RESOURCE GROUP NAME box, enter myResourceGroupA , and
then select Delete .
5. Log out of the portal as UserA and log in as UserB.
6. Complete steps 2-4 for myResourceGroupB.
Azure CLI
1. Log in to Azure as UserA and execute the following command:
az group delete --name myResourceGroupA --yes
PowerShell
1. Log in to Azure as UserA and execute the following command:
Next steps
Thoroughly familiarize yourself with important virtual network peering constraints and behaviors before
creating a virtual network peering for production use.
Learn about all virtual network peering settings.
Learn how to create a hub and spoke network topology with virtual network peering.
Create a virtual network peering - different
deployment models, same subscription
11/2/2020 • 10 minutes to read • Edit Online
In this tutorial, you learn to create a virtual network peering between virtual networks created through different
deployment models. Both virtual networks exist in the same subscription. Peering two virtual networks enables
resources in different virtual networks to communicate with each other with the same bandwidth and latency as
though the resources were in the same virtual network. Learn more about Virtual network peering.
The steps to create a virtual network peering are different, depending on whether the virtual networks are in the
same, or different, subscriptions, and which Azure deployment model the virtual networks are created through.
Learn how to create a virtual network peering in other scenarios by clicking the scenario from the following table:
A virtual network peering can't be created between two virtual networks deployed through the classic deployment
model. If you need to connect virtual networks that were both created through the classic deployment model, you
can use an Azure VPN Gateway to connect the virtual networks.
This tutorial peers virtual networks in the same region. You can also peer virtual networks in different supported
regions. It's recommended that you familiarize yourself with the peering requirements and constraints before
peering virtual networks.
You can use the Azure portal, the Azure command-line interface (CLI), Azure PowerShell, or an Azure Resource
Manager template to create a virtual network peering. Click any of the previous tool links to go directly to the
steps for creating a virtual network peering using your tool of choice.
azure network vnet create --vnet myVnet2 --address-space 10.1.0.0 --cidr 16 --location "East US"
4. Execute the following bash CLI script using the CLI, not the classic CLI. For options on running bash CLI
scripts on Windows computer, see Install the Azure CLI on Windows.
#!/bin/bash
5. Create a virtual network peering between the two virtual networks created through the different
deployment models using the CLI. Copy the following script to a text editor on your PC. Replace
<subscription id> with your subscription ID. If you don't know your subscription ID, enter the
az account show command. The value for id in the output is your subscription ID. Paste the modified script
in to your CLI session, and then press Enter .
6. After the script executes, review the peering for the virtual network (Resource Manager). Copy the following
command, paste it in your CLI session, and then press Enter :
WARNING
Importing a changed network configuration file can cause changes to existing virtual networks (classic) in your
subscription. Ensure you only add the previous virtual network and that you don't change or remove any existing
virtual networks from your subscription.
5. Sign in to Azure to create the virtual network (Resource Manager) by entering the Connect-AzAccount
command. The account you sign in with must have the necessary permissions to create a virtual network
peering. For a list of permissions, see Virtual network peering permissions.
6. Create a resource group and a virtual network (Resource Manager). Copy the script, paste it into
PowerShell, and then press Enter .
# Create a resource group.
New-AzResourceGroup -Name myResourceGroup -Location eastus
7. Create a virtual network peering between the two virtual networks created through the different
deployment models. Copy the following script to a text editor on your PC. Replace <subscription id> with
your subscription ID. If you don't know your subscription ID, enter the Get-AzSubscription command to
view it. The value for Id in the returned output is your subscription ID. To execute the script, copy the
modified script from your text editor, then right-click in your PowerShell session, and then press Enter .
8. After the script executes, review the peering for the virtual network (Resource Manager). Copy the following
command, paste it in your PowerShell session, and then press Enter :
Get-AzVirtualNetworkPeering `
-ResourceGroupName myResourceGroup `
-VirtualNetworkName myVnet1 `
| Format-Table VirtualNetworkName, PeeringState
Delete resources
When you've finished this tutorial, you might want to delete the resources you created in the tutorial, so you don't
incur usage charges. Deleting a resource group also deletes all resources that are in the resource group.
Azure portal
1. In the portal search box, enter myResourceGroup . In the search results, click myResourceGroup .
2. On the myResourceGroup blade, click the Delete icon.
3. To confirm the deletion, in the TYPE THE RESOURCE GROUP NAME box, enter myResourceGroup , and
then click Delete .
Azure CLI
1. Use the Azure CLI to delete the virtual network (Resource Manager) with the following command:
2. Use the classic CLI to delete the virtual network (classic) with the following commands:
PowerShell
1. Enter the following command to delete the virtual network (Resource Manager):
2. To delete the virtual network (classic) with PowerShell, you must modify an existing network configuration
file. Learn how to export, update, and import network configuration files. Remove the following
VirtualNetworkSite element for the virtual network used in this tutorial:
WARNING
Importing a changed network configuration file can cause changes to existing virtual networks (classic) in your
subscription. Ensure you only remove the previous virtual network and that you don't change or remove any other
existing virtual networks from your subscription.
Next steps
Thoroughly familiarize yourself with important virtual network peering constraints and behaviors before
creating a virtual network peering for production use.
Learn about all virtual network peering settings.
Learn how to create a hub and spoke network topology with virtual network peering.
Create a virtual network peering - different
deployment models and subscriptions
11/2/2020 • 14 minutes to read • Edit Online
In this tutorial, you learn to create a virtual network peering between virtual networks created through different
deployment models. The virtual networks exist in different subscriptions. Peering two virtual networks enables
resources in different virtual networks to communicate with each other with the same bandwidth and latency as
though the resources were in the same virtual network. Learn more about Virtual network peering.
The steps to create a virtual network peering are different, depending on whether the virtual networks are in the
same, or different, subscriptions, and which Azure deployment model the virtual networks are created through.
Learn how to create a virtual network peering in other scenarios by clicking the scenario from the following table:
A virtual network peering cannot be created between two virtual networks deployed through the classic
deployment model. This tutorial uses virtual networks that exist in the same region. This tutorial peers virtual
networks in the same region. You can also peer virtual networks in different supported regions. It's recommended
that you familiarize yourself with the peering requirements and constraints before peering virtual networks.
When creating a virtual network peering between virtual networks that exist in different subscriptions, the
subscriptions can associated to the same Azure Active Directory tenant. If you don't already have an Azure Active
Directory tenant, you can quickly create one.
You can use the Azure portal, the Azure command-line interface (CLI), or Azure PowerShell to create a virtual
network peering. Click any of the previous tool links to go directly to the steps for creating a virtual network
peering using your tool of choice.
azure network vnet create --vnet myVnetB --address-space 10.1.0.0 --cidr 16 --location "East US"
4. The remaining steps must be completed using a bash shell with the Azure CLI (not the classic CLI).
5. Copy the following script to a text editor on your PC. Replace <SubscriptionB-Id> with your subscription ID.
If you don't know your subscription Id, enter the az account show command. The value for id in the output
is your subscription Id. Copy the modified script, paste it in to your CLI session, and then press Enter .
az role assignment create \
--assignee UserA@azure.com \
--role "Classic Network Contributor" \
--scope /subscriptions/<SubscriptionB-Id>/resourceGroups/Default-
Networking/providers/Microsoft.ClassicNetwork/virtualNetworks/myVnetB
When you created the virtual network (classic) in step 4, Azure created the virtual network in the Default-
Networking resource group.
6. Log UserB out of Azure and log in as UserA in the CLI.
7. Create a resource group and a virtual network (Resource Manager). Copy the following script, paste it in to
your CLI session, and then press Enter .
#!/bin/bash
8. Create a virtual network peering between the two virtual networks created through the different
deployment models. Copy the following script to a text editor on your PC. Replace <SubscriptionB-id> with
your subscription Id. If you don't know your subscription Id, enter the az account show command. The value
for id in the output is your subscription Id. Azure created the virtual network (classic) you created in step 4
in a resource group named Default-Networking. Paste the modified script in your CLI session, and then
press Enter .
5. Log in to UserB's subscription as UserB to use Resource Manager commands by entering the
Connect-AzAccount command.
6. Assign UserA permissions to virtual network B. Copy the following script to a text editor on your PC and
replace <SubscriptionB-id> with the ID of subscription B. If you don't know the subscription Id, enter the
Get-AzSubscription command to view it. The value for Id in the returned output is your subscription ID.
Azure created the virtual network (classic) you created in step 4 in a resource group named Default-
Networking. To execute the script, copy the modified script, paste it in to PowerShell, and then press Enter .
New-AzRoleAssignment `
-SignInName UserA@azure.com `
-RoleDefinitionName "Classic Network Contributor" `
-Scope /subscriptions/<SubscriptionB-id>/resourceGroups/Default-
Networking/providers/Microsoft.ClassicNetwork/virtualNetworks/myVnetB
7. Log out of Azure as UserB and log in to UserA's subscription as UserA by entering the Connect-AzAccount
command. The account you log in with must have the necessary permissions to create a virtual network
peering. For a list of permissions, see Virtual network peering permissions.
8. Create the virtual network (Resource Manager) by copying the following script, pasting it in to PowerShell,
and then pressing Enter :
9. Assign UserB permissions to myVnetA. Copy the following script to a text editor on your PC and replace
<SubscriptionA-Id> with the ID of subscription A. If you don't know the subscription Id, enter the
Get-AzSubscription command to view it. The value for Id in the returned output is your subscription ID.
Paste the modified version of the script in PowerShell, and then press Enter to execute it.
New-AzRoleAssignment `
-SignInName UserB@azure.com `
-RoleDefinitionName "Network Contributor" `
-Scope /subscriptions/<SubscriptionA-
Id>/resourceGroups/myResourceGroupA/providers/Microsoft.Network/VirtualNetworks/myVnetA
10. Copy the following script to a text editor on your PC, and replace <SubscriptionB-id> with the ID of
subscription B. To peer myVnetA to myVNetB, copy the modified script, paste it in to PowerShell, and then
press Enter .
Add-AzVirtualNetworkPeering `
-Name 'myVnetAToMyVnetB' `
-VirtualNetwork $vnetA `
-RemoteVirtualNetworkId /subscriptions/<SubscriptionB-id>/resourceGroups/Default-
Networking/providers/Microsoft.ClassicNetwork/virtualNetworks/myVnetB
11. View the peering state of myVnetA by copying the following script, pasting it into PowerShell, and pressing
Enter .
Get-AzVirtualNetworkPeering `
-ResourceGroupName $rgName `
-VirtualNetworkName myVnetA `
| Format-Table VirtualNetworkName, PeeringState
The state is Connected . It changes to Connected once you set up the peering to myVnetA from myVnetB.
Any Azure resources you create in either virtual network are now able to communicate with each other
through their IP addresses. If you're using default Azure name resolution for the virtual networks, the
resources in the virtual networks are not able to resolve names across the virtual networks. If you want to
resolve names across virtual networks in a peering, you must create your own DNS server. Learn how to set
up Name resolution using your own DNS server.
12. Optional : Though creating virtual machines is not covered in this tutorial, you can create a virtual machine
in each virtual network and connect from one virtual machine to the other, to validate connectivity.
13. Optional : To delete the resources that you create in this tutorial, complete the steps in Delete resources in
this article.
Delete resources
When you've finished this tutorial, you might want to delete the resources you created in the tutorial, so you don't
incur usage charges. Deleting a resource group also deletes all resources that are in the resource group.
Azure portal
1. In the portal search box, enter myResourceGroupA . In the search results, click myResourceGroupA .
2. On the myResourceGroupA blade, click the Delete icon.
3. To confirm the deletion, in the TYPE THE RESOURCE GROUP NAME box, enter myResourceGroupA , and
then click Delete .
4. In the Search resources box at the top of the portal, type myVnetB. Click myVnetB when it appears in the
search results. A blade appears for the myVnetB virtual network.
5. In the myVnetB blade, click Delete .
6. To confirm the deletion, click Yes in the Delete vir tual network box.
Azure CLI
1. Log in to Azure using the CLI to delete the virtual network (Resource Manager) with the following
command:
2. Sign in to Azure using the classic CLI to delete the virtual network (classic) with the following commands:
azure config mode asm
PowerShell
1. At the PowerShell command prompt, enter the following command to delete the virtual network (Resource
Manager):
2. To delete the virtual network (classic) with PowerShell, you must modify an existing network configuration
file. Learn how to export, update, and import network configuration files. Remove the following
VirtualNetworkSite element for the virtual network used in this tutorial:
WARNING
Importing a changed network configuration file can cause changes to existing virtual networks (classic) in your
subscription. Ensure you only remove the previous virtual network and that you don't change or remove any other
existing virtual networks from your subscription.
Next steps
Thoroughly familiarize yourself with important virtual network peering constraints and behaviors before
creating a virtual network peering for production use.
Learn about all virtual network peering settings.
Learn how to create a hub and spoke network topology with virtual network peering.
Create, change, or delete a virtual network peering
11/2/2020 • 17 minutes to read • Edit Online
Learn how to create, change, or delete a virtual network peering. Virtual network peering enables you to connect
virtual networks in the same region and across regions (also known as Global VNet Peering) through the Azure
backbone network. Once peered, the virtual networks are still managed as separate resources. If you're new to
virtual network peering, you can learn more about it in the virtual network peering overview or by completing a
tutorial.
Complete the following tasks before completing steps in any section of this article:
If you don't already have an Azure account, sign up for a free trial account.
If using the portal, open https://portal.azure.com, and log in with an account that has the necessary
permissions to work with peerings.
If using PowerShell commands to complete tasks in this article, either run the commands in the Azure Cloud
Shell, or by running PowerShell from your computer. The Azure Cloud Shell is a free interactive shell that you
can use to run the steps in this article. It has common Azure tools preinstalled and configured to use with your
account. This tutorial requires the Azure PowerShell module version 1.0.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 with an account that
has the necessary permissions to work with peering, to create a connection with Azure.
If using Azure Command-line interface (CLI) commands to complete tasks in this article, either run the
commands in the Azure Cloud Shell, or by running the CLI from your computer. This tutorial requires the Azure
CLI version 2.0.31 or later. Run az --version to find the installed version. If you need to install or upgrade, see
Install Azure CLI. If you are running the Azure CLI locally, you also need to run az login with an account that
has the necessary permissions to work with peering, to create a connection with Azure.
The account you log into, or connect to Azure with, must be assigned to the network contributor role or to a
custom role that is assigned the appropriate actions listed in Permissions.
Create a peering
Before creating a peering, familiarize yourself with the requirements and constraints and necessary permissions.
1. In the search box at the top of the Azure portal, enter virtual networks in the search box. When Vir tual
networks appear in the search results, select it. Do not select Vir tual networks (classic) if it appears in
the list, as you cannot create a peering from a virtual network deployed through the classic deployment
model.
2. Select the virtual network in the list that you want to create a peering for.
3. Under SETTINGS , select Peerings .
4. Select + Add .
5. Enter or select values for the following settings:
Name: The name for the peering must be unique within the virtual network.
Vir tual network deployment model: Select which deployment model the virtual network you
want to peer with was deployed through.
I know my resource ID: If you have read access to the virtual network you want to peer with,
leave this checkbox unchecked. If you don't have read access to the virtual network or subscription
you want to peer with, check this box. Enter the full resource ID of the virtual network you want to
peer with in the Resource ID box that appeared when you checked the box. The resource ID you
enter must be for a virtual network that exists in the same, or supported different Azure region as
this virtual network. The full resource ID looks similar to
/subscriptions/<Id>/resourceGroups/<resource-group-
name>/providers/Microsoft.Network/virtualNetworks/<virtual-network-name>
. You can get the resource ID for a virtual network by viewing the properties for a virtual network. To
learn how to view the properties for a virtual network, see Manage virtual networks. If the
subscription is associated to a different Azure Active Directory tenant than the subscription with the
virtual network you're creating the peering from, first add a user from each tenant as a guest user in
the opposite tenant.
Subscription: Select the subscription of the virtual network you want to peer with. One or more
subscriptions are listed, depending on how many subscriptions your account has read access to. If
you checked the Resource ID checkbox, this setting isn't available.
Vir tual network : Select the virtual network you want to peer with. You can select a virtual network
created through either Azure deployment model. If you want to select a virtual network in a different
region, you must select a virtual network in a supported region. You must have read access to the
virtual network for it to be visible in the list. If a virtual network is listed, but grayed out, it may be
because the address space for the virtual network overlaps with the address space for this virtual
network. If virtual network address spaces overlap, they cannot be peered. If you checked the
Resource ID checkbox, this setting isn't available.
Allow vir tual network access: Select Enabled (default) if you want to enable communication
between the two virtual networks. Enabling communication between virtual networks allows
resources connected to either virtual network to communicate with each other with the same
bandwidth and latency as if they were connected to the same virtual network. All communication
between resources in the two virtual networks is over the Azure private network. The
Vir tualNetwork service tag for network security groups encompasses the virtual network and
peered virtual network. To learn more about network security group service tags, see Network
security groups overview. Select Disabled if you don't want traffic to flow to the peered virtual
network. You might select Disabled if you've peered a virtual network with another virtual network,
but occasionally want to disable traffic flow between the two virtual networks. You may find
enabling/disabling is more convenient than deleting and re-creating peerings. When this setting is
disabled, traffic doesn't flow between the peered virtual networks.
Allow for warded traffic: Check this box to allow traffic forwarded by a network virtual appliance
in a virtual network (that didn't originate from the virtual network) to flow to this virtual network
through a peering. For example, consider three virtual networks named Spoke1, Spoke2, and Hub. A
peering exists between each spoke virtual network and the Hub virtual network, but peerings don't
exist between the spoke virtual networks. A network virtual appliance is deployed in the Hub virtual
network, and user-defined routes are applied to each spoke virtual network that route traffic
between the subnets through the network virtual appliance. If this checkbox is not checked for the
peering between each spoke virtual network and the hub virtual network, traffic doesn't flow
between the spoke virtual networks because the hub is not forwarding the traffic between the
virtual networks. While enabling this capability allows the forwarded traffic through the peering, it
does not create any user-defined routes or network virtual appliances. User-defined routes and
network virtual appliances are created separately. Learn about user-defined routes. You don't need
to check this setting if traffic is forwarded between virtual networks through an Azure VPN Gateway.
Allow gateway transit: Check this box if you have a virtual network gateway attached to this
virtual network and want to allow traffic from the peered virtual network to flow through the
gateway. For example, this virtual network may be attached to an on-premises network through a
virtual network gateway. The gateway can be an ExpressRoute or VPN gateway. Checking this box
allows traffic from the peered virtual network to flow through the gateway attached to this virtual
network to the on-premises network. If you check this box, the peered virtual network cannot have a
gateway configured. The peered virtual network must have the Use remote gateways checkbox
checked when setting up the peering from the other virtual network to this virtual network. If you
leave this box unchecked (default), traffic from the peered virtual network still flows to this virtual
network, but cannot flow through a virtual network gateway attached to this virtual network. If the
peering is between a virtual network (Resource Manager) and a virtual network (classic), the
gateway must be in the virtual network (Resource Manager).
In addition to forwarding traffic to an on-premises network, a VPN gateway can forward network
traffic between virtual networks that are peered with the virtual network the gateway is in, without
the virtual networks needing to be peered with each other. Using a VPN gateway to forward traffic is
useful when you want to use a VPN gateway in a hub (see the hub and spoke example described for
Allow for warded traffic ) virtual network to route traffic between spoke virtual networks that
aren't peered with each other. To learn more about allowing use of a gateway for transit, see
Configure a VPN gateway for transit in a virtual network peering. This scenario requires
implementing user-defined routes that specify the virtual network gateway as the next hop type.
Learn about user-defined routes. You can only specify a VPN gateway as a next hop type in a user-
defined route, you cannot specify an ExpressRoute gateway as the next hop type in a user-defined
route.
Use remote gateways: Check this box to allow traffic from this virtual network to flow through a
virtual network gateway attached to the virtual network you're peering with. For example, the virtual
network you're peering with has a VPN gateway attached that enables communication to an on-
premises network. Checking this box allows traffic from this virtual network to flow through the
VPN gateway attached to the peered virtual network. If you check this box, the peered virtual
network must have a virtual network gateway attached to it and must have the Allow gateway
transit checkbox checked. If you leave this box unchecked (default), traffic from the peered virtual
network can still flow to this virtual network, but cannot flow through a virtual network gateway
attached to this virtual network.
Only one peering for this virtual network can have this setting enabled.
You can't use remote gateways if you already have a gateway configured in your virtual network. To
learn more about using a gateway for transit, see Configure a VPN gateway for transit in a virtual
network peering
NOTE
If you use a Virtual Network Gateway to send on-premises traffic transitively to a peered VNet, the peered VNet IP
range for the on-premises VPN device must be set to 'interesting' traffic. Otherwise, your on-premises resources
won't be able to communicate with resources in the peered VNet.
6. Select OK to add the peering to the virtual network you selected.
For step-by-step instructions for implementing peering between virtual networks in different subscriptions and
deployment models, see next steps.
Commands
Azure CLI : az network vnet peering create
PowerShell : Add-AzVirtualNetworkPeering
Delete a peering
Before deleting a peering, ensure your account has the necessary permissions.
When a peering is deleted, traffic from a virtual network no longer flows to the peered virtual network. When
virtual networks deployed through Resource Manager are peered, each virtual network has a peering to the other
virtual network. Though deleting the peering from one virtual network disables the communication between the
virtual networks, it does not delete the peering from the other virtual network. The peering status for the peering
that exists in the other virtual network is Disconnected . You cannot recreate the peering until you re-create the
peering in the first virtual network and the peering status for both virtual networks changes to Connected.
If you want virtual networks to communicate sometimes, but not always, rather than deleting a peering, you can
set the Allow vir tual network access setting to Disabled instead. To learn how, read step 6 of the Create a
peering section of this article. You may find disabling and enabling network access easier than deleting and
recreating peerings.
1. In the search box at the top of the portal, enter virtual networks in the search box. When Vir tual networks
appear in the search results, select it. Do not select Vir tual networks (classic) if it appears in the list, as you
cannot create a peering from a virtual network deployed through the classic deployment model.
2. Select the virtual network in the list that you want to delete a peering for.
3. Under SETTINGS , select Peerings .
4. On the right side of the peering you want to delete, select ..., select Delete , then select Yes to delete the
peering from the first virtual network.
5. Complete the previous steps to delete the peering from the other virtual network in the peering.
Commands
Azure CLI : az network vnet peering delete
PowerShell : Remove-AzVirtualNetworkPeering
Permissions
The accounts you use to work with virtual network peering must be assigned to the following roles:
Network Contributor: For a virtual network deployed through Resource Manager.
Classic Network Contributor: For a virtual network deployed through the classic deployment model.
If your account is not assigned to one of the previous roles, it must be assigned to a custom role that is assigned
the necessary actions from the following table:
A C T IO N NAME
Different
Different
This article helps you connect virtual networks by using the VNet-to-VNet connection type. The virtual networks
can be in the same or different regions, and from the same or different subscriptions. When connecting VNets
from different subscriptions, the subscriptions do not need to be associated with the same Active Directory tenant.
The steps in this article apply to the Resource Manager deployment model and use PowerShell. You can also create
this configuration using a different deployment tool or deployment model by selecting a different option from the
following list:
VNets that reside in different subscriptions: The steps for this configuration use TestVNet1 and TestVNet5.
NOTE
This article has been updated to use the new Azure PowerShell Az module. You can still use the AzureRM module, which will
continue to receive bug fixes until at least December 2020. To learn more about the new Az module and AzureRM
compatibility, see Introducing the new Azure PowerShell Az module. For Az module installation instructions, see Install Azure
PowerShell.
Because it takes up to 45 minutes to create a gateway, Azure Cloud Shell will timeout periodically during
this exercise. You can restart Cloud Shell by clicking in the upper left of the terminal. Be sure to redeclare
any variables when you restart the terminal.
If you would rather install latest version of the Azure PowerShell module locally, see How to install and
configure Azure PowerShell.
Step 1 - Plan your IP address ranges
In the following steps, you create two virtual networks along with their respective gateway subnets and
configurations. You then create a VPN connection between the two VNets. It’s important to plan the IP address
ranges for your network configuration. Keep in mind that you must make sure that none of your VNet ranges or
local network ranges overlap in any way. In these examples, we do not include a DNS server. If you want name
resolution for your virtual networks, see Name resolution.
We use the following values in the examples:
Values for TestVNet1:
VNet Name: TestVNet1
Resource Group: TestRG1
Location: East US
TestVNet1: 10.11.0.0/16 & 10.12.0.0/16
FrontEnd: 10.11.0.0/24
BackEnd: 10.12.0.0/24
GatewaySubnet: 10.12.255.0/27
GatewayName: VNet1GW
Public IP: VNet1GWIP
VPNType: RouteBased
Connection(1to4): VNet1toVNet4
Connection(1to5): VNet1toVNet5 (For VNets in different subscriptions)
ConnectionType: VNet2VNet
Values for TestVNet4:
VNet Name: TestVNet4
TestVNet2: 10.41.0.0/16 & 10.42.0.0/16
FrontEnd: 10.41.0.0/24
BackEnd: 10.42.0.0/24
GatewaySubnet: 10.42.255.0/27
Resource Group: TestRG4
Location: West US
GatewayName: VNet4GW
Public IP: VNet4GWIP
VPNType: RouteBased
Connection: VNet4toVNet1
ConnectionType: VNet2VNet
Step 2 - Create and configure TestVNet1
1. Verify your subscription settings.
Connect to your account if you are running PowerShell locally on your computer. If you are using Azure
Cloud Shell, you are connected automatically.
Connect-AzAccount
Get-AzSubscription
If you have more than one subscription, specify the subscription that you want to use.
Select-AzSubscription -SubscriptionName nameofsubscription
2. Declare your variables. This example declares the variables using the values for this exercise. In most cases,
you should replace the values with your own. However, you can use these variables if you are running
through the steps to become familiar with this type of configuration. Modify the variables if needed, then
copy and paste them into your PowerShell console.
$RG1 = "TestRG1"
$Location1 = "East US"
$VNetName1 = "TestVNet1"
$FESubName1 = "FrontEnd"
$BESubName1 = "Backend"
$VNetPrefix11 = "10.11.0.0/16"
$VNetPrefix12 = "10.12.0.0/16"
$FESubPrefix1 = "10.11.0.0/24"
$BESubPrefix1 = "10.12.0.0/24"
$GWSubPrefix1 = "10.12.255.0/27"
$GWName1 = "VNet1GW"
$GWIPName1 = "VNet1GWIP"
$GWIPconfName1 = "gwipconf1"
$Connection14 = "VNet1toVNet4"
$Connection15 = "VNet1toVNet5"
4. Create the subnet configurations for TestVNet1. This example creates a virtual network named TestVNet1
and three subnets, one called GatewaySubnet, one called FrontEnd, and one called Backend. When
substituting values, it's important that you always name your gateway subnet specifically GatewaySubnet. If
you name it something else, your gateway creation fails. For this reason, it is not assigned via variable
below.
The following example uses the variables that you set earlier. In this example, the gateway subnet is using a
/27. While it is possible to create a gateway subnet as small as /29, we recommend that you create a larger
subnet that includes more addresses by selecting at least /28 or /27. This will allow for enough addresses to
accommodate possible additional configurations that you may want in the future.
5. Create TestVNet1.
6. Request a public IP address to be allocated to the gateway you will create for your VNet. Notice that the
AllocationMethod is Dynamic. You cannot specify the IP address that you want to use. It's dynamically
allocated to your gateway.
8. Create the gateway for TestVNet1. In this step, you create the virtual network gateway for your TestVNet1.
VNet-to-VNet configurations require a RouteBased VpnType. Creating a gateway can often take 45 minutes
or more, depending on the selected gateway SKU.
After you finish the commands, it will take up to 45 minutes to create this gateway. If you are using Azure Cloud
Shell, you can restart your Cloud Shell session by clicking in the upper left of the Cloud Shell terminal, then
configure TestVNet4. You don't need to wait until the TestVNet1 gateway completes.
Step 3 - Create and configure TestVNet4
Once you've configured TestVNet1, create TestVNet4. Follow the steps below, replacing the values with your own
when needed.
1. Connect and declare your variables. Be sure to replace the values with the ones that you want to use for
your configuration.
$RG4 = "TestRG4"
$Location4 = "West US"
$VnetName4 = "TestVNet4"
$FESubName4 = "FrontEnd"
$BESubName4 = "Backend"
$VnetPrefix41 = "10.41.0.0/16"
$VnetPrefix42 = "10.42.0.0/16"
$FESubPrefix4 = "10.41.0.0/24"
$BESubPrefix4 = "10.42.0.0/24"
$GWSubPrefix4 = "10.42.255.0/27"
$GWName4 = "VNet4GW"
$GWIPName4 = "VNet4GWIP"
$GWIPconfName4 = "gwipconf4"
$Connection41 = "VNet4toVNet1"
4. Create TestVNet4.
New-AzVirtualNetwork -Name $VnetName4 -ResourceGroupName $RG4 `
-Location $Location4 -AddressPrefix $VnetPrefix41,$VnetPrefix42 -Subnet $fesub4,$besub4,$gwsub4
7. Create the TestVNet4 gateway. Creating a gateway can often take 45 minutes or more, depending on the
selected gateway SKU.
2. Create the TestVNet1 to TestVNet4 connection. In this step, you create the connection from TestVNet1 to
TestVNet4. You'll see a shared key referenced in the examples. You can use your own values for the shared
key. The important thing is that the shared key must match for both connections. Creating a connection can
take a short while to complete.
3. Create the TestVNet4 to TestVNet1 connection. This step is similar to the one above, except you are creating
the connection from TestVNet4 to TestVNet1. Make sure the shared keys match. The connection will be
established after a few minutes.
4. Verify your connection. See the section How to verify your connection.
2. Connect to subscription 5. Open your PowerShell console and connect to your account. Use the following
sample to help you connect:
Connect-AzAccount
Get-AzSubscription
5. Create TestVNet5.
Copy the output of the following elements and send these to the administrator of Subscription 5 via email
or another method.
$vnet1gw.Name
$vnet1gw.Id
These two elements will have values similar to the following example output:
PS D:\> $vnet1gw.Name
VNet1GW
PS D:\> $vnet1gw.Id
/subscriptions/b636ca99-6f88-4df4-a7c3-
2f8dc4545509/resourceGroupsTestRG1/providers/Microsoft.Network/virtualNetworkGateways/VNet1GW
2. [Subscription 5] Get the virtual network gateway for Subscription 5. Sign in and connect to Subscription 5
before running the following example:
Copy the output of the following elements and send these to the administrator of Subscription 1 via email
or another method.
$vnet5gw.Name
$vnet5gw.Id
These two elements will have values similar to the following example output:
PS C:\> $vnet5gw.Name
VNet5GW
PS C:\> $vnet5gw.Id
/subscriptions/66c8e4f1-ecd6-47ed-9de7-
7e530de23994/resourceGroups/TestRG5/providers/Microsoft.Network/virtualNetworkGateways/VNet5GW
3. [Subscription 1] Create the TestVNet1 to TestVNet5 connection. In this step, you create the connection
from TestVNet1 to TestVNet5. The difference here is that $vnet5gw cannot be obtained directly because it is
in a different subscription. You will need to create a new PowerShell object with the values communicated
from Subscription 1 in the steps above. Use the example below. Replace the Name, ID, and shared key with
your own values. The important thing is that the shared key must match for both connections. Creating a
connection can take a short while to complete.
Connect to Subscription 1 before running the following example:
4. [Subscription 5] Create the TestVNet5 to TestVNet1 connection. This step is similar to the one above,
except you are creating the connection from TestVNet5 to TestVNet1. The same process of creating a
PowerShell object based on the values obtained from Subscription 1 applies here as well. In this step, be
sure that the shared keys match.
Connect to Subscription 5 before running the following example:
You can verify that your connection succeeded by using the 'Get-AzVirtualNetworkGatewayConnection' cmdlet,
with or without '-Debug'.
1. Use the following cmdlet example, configuring the values to match your own. If prompted, select 'A' in
order to run 'All'. In the example, '-Name' refers to the name of the connection that you want to test.
2. After the cmdlet has finished, view the values. In the example below, the connection status shows as
'Connected' and you can see ingress and egress bytes.
"connectionStatus": "Connected",
"ingressBytesTransferred": 33509044,
"egressBytesTransferred": 4142431
VNet-to-VNet FAQ
The VNet-to-VNet FAQ applies to VPN gateway connections. For information about VNet peering, see Virtual
network peering.
Does Azure charge for traffic between VNets?
VNet-to-VNet traffic within the same region is free for both directions when you use a VPN gateway connection.
Cross-region VNet-to-VNet egress traffic is charged with the outbound inter-VNet data transfer rates based on the
source regions. For more information, see VPN Gateway pricing page. If you're connecting your VNets by using
VNet peering instead of a VPN gateway, see Virtual network pricing.
Does VNet-to -VNet traffic travel across the internet?
No. VNet-to-VNet traffic travels across the Microsoft Azure backbone, not the internet.
Can I establish a VNet-to -VNet connection across Azure Active Directory (AAD) tenants?
Yes, VNet-to-VNet connections that use Azure VPN gateways work across AAD tenants.
Is VNet-to -VNet traffic secure?
Yes, it's protected by IPsec/IKE encryption.
Do I need a VPN device to connect VNets together?
No. Connecting multiple Azure virtual networks together doesn't require a VPN device unless cross-premises
connectivity is required.
Do my VNets need to be in the same region?
No. The virtual networks can be in the same or different Azure regions (locations).
If the VNets aren't in the same subscription, do the subscriptions need to be associated with the same Active
Directory tenant?
No.
Can I use VNet-to -VNet to connect virtual networks in separate Azure instances?
No. VNet-to-VNet supports connecting virtual networks within the same Azure instance. For example, you can’t
create a connection between global Azure and Chinese/German/US government Azure instances. Consider using a
Site-to-Site VPN connection for these scenarios.
Can I use VNet-to -VNet along with multi-site connections?
Yes. Virtual network connectivity can be used simultaneously with multi-site VPNs.
How many on-premises sites and virtual networks can one virtual network connect to?
See the Gateway requirements table.
Can I use VNet-to -VNet to connect VMs or cloud services outside of a VNet?
No. VNet-to-VNet supports connecting virtual networks. It doesn't support connecting virtual machines or cloud
services that aren't in a virtual network.
Can a cloud service or a load-balancing endpoint span VNets?
No. A cloud service or a load-balancing endpoint can't span across virtual networks, even if they're connected
together.
Can I use a PolicyBased VPN type for VNet-to -VNet or Multi-Site connections?
No. VNet-to-VNet and Multi-Site connections require Azure VPN gateways with RouteBased (previously called
dynamic routing) VPN types.
Can I connect a VNet with a RouteBased VPN Type to another VNet with a PolicyBased VPN type?
No, both virtual networks MUST use route-based (previously called dynamic routing) VPNs.
Do VPN tunnels share bandwidth?
Yes. All VPN tunnels of the virtual network share the available bandwidth on the Azure VPN gateway and the same
VPN gateway uptime SLA in Azure.
Are redundant tunnels supported?
Redundant tunnels between a pair of virtual networks are supported when one virtual network gateway is
configured as active-active.
Can I have overlapping address spaces for VNet-to -VNet configurations?
No. You can't have overlapping IP address ranges.
Can there be overlapping address spaces among connected virtual networks and on-premises local sites?
No. You can't have overlapping IP address ranges.
Next steps
Once your connection is complete, you can add virtual machines to your virtual networks. See the Virtual
Machines documentation for more information.
For information about BGP, see the BGP Overview and How to configure BGP.
Connect virtual networks from different deployment
models using the portal
11/2/2020 • 21 minutes to read • Edit Online
This article shows you how to connect classic VNets to Resource Manager VNets to allow the resources located in
the separate deployment models to communicate with each other. The steps in this article primarily use the Azure
portal, but you can also create this configuration using the PowerShell by selecting the article from this list.
Connecting a classic VNet to a Resource Manager VNet is similar to connecting a VNet to an on-premises site
location. Both connectivity types use a VPN gateway to provide a secure tunnel using IPsec/IKE. You can create a
connection between VNets that are in different subscriptions and in different regions. You can also connect VNets
that already have connections to on-premises networks, as long as the gateway that they have been configured
with is dynamic or route-based. For more information about VNet-to-VNet connections, see the VNet-to-VNet FAQ
at the end of this article.
If you do not already have a virtual network gateway and do not want to create one, you may want to instead
consider connecting your VNets using VNet Peering. VNet peering does not use a VPN gateway. For more
information, see VNet peering.
Before you begin
These steps assume that both VNets have already been created. If you are using this article as an exercise and
don't have VNets, there are links in the steps to help you create them.
Verify that the address ranges for the VNets do not overlap with each other, or overlap with any of the ranges
for other connections that the gateways may be connected to.
Install the latest PowerShell cmdlets for both Resource Manager and Service Management (classic). In this
article, we use both the Azure portal and PowerShell. PowerShell is required to create the connection from the
classic VNet to the Resource Manager VNet. For more information, see How to install and configure Azure
PowerShell.
Example settings
You can use these values to create a test environment, or refer to them to better understand the examples in this
article.
Classic VNet
VNet name = ClassicVNet
Address space = 10.0.0.0/24
Subnet name = Subnet-1
Subnet address range = 10.0.0.0/27
Subscription = the subscription you want to use
Resource Group = ClassicRG
Location = West US
GatewaySubnet = 10.0.0.32/28
Local site = RMVNetLocal
Resource Manager VNet
VNet name = RMVNet
Address space = 192.168.0.0/16
Resource Group = RG1
Location = East US
Subnet name = Subnet-1
Address range = 192.168.1.0/24
GatewaySubnet = 192.168.0.0/26
Virtual network gateway name = RMGateway
Gateway type = VPN
VPN type = Route-based
SKU = VpnGw1
Location = East US
Virtual network = RMVNet
(associate the VPN gateway to this VNet) First IP configuration = rmgwpip
(gateway public IP address) Local network gateway = ClassicVNetLocal
Connection name = RMtoClassic
Connection overview
For this configuration, you create a VPN gateway connection over an IPsec/IKE VPN tunnel between the virtual
networks. Make sure that none of your VNet ranges overlap with each other, or with any of the local networks that
they connect to.
The following table shows an example of how the example VNets and local sites are defined:
C O N N EC T S TO LO C A L
VIRT UA L N ET W O RK A DDRESS SPA C E REGIO N N ET W O RK SIT E
3. Click Subnet - Configure required settings to open the Add subnet page. The Name is already
configured with the required value: GatewaySubnet .
4. The Address range refers to the range for the gateway subnet. Although you can create a gateway subnet
with a /29 address range (3 addresses), we recommend creating a gateway subnet that contains more IP
addresses. This will accommodate future configurations that may require more available IP addresses. If
possible, use /27 or /28. If you are using these steps as an exercise, you can refer to the Example values. For
this example, we use '10.0.0.32/28'. Click OK to create the gateway subnet.
5. On the Gateway configuration page, Size refers to the gateway SKU. Select the gateway SKU for your
VPN gateway.
6. Verify the Routing Type is Dynamic , then click OK to return to the New VPN Connection page.
7. On the New VPN Connection page, click OK to begin creating your VPN gateway. Creating a VPN
gateway can take up to 45 minutes to complete.
4. Copy the virtual network gateway Public IP address
After the virtual network gateway has been created, you can view the gateway IP address.
1. Navigate to your classic VNet, and click Over view .
2. Click VPN connections to open the VPN connections page. On the VPN connections page, you can view the
Public IP address. This is the Public IP address assigned to your virtual network gateway. Make a note of the IP
address. You use it in later steps when you work with your Resource Manager local network gateway
configuration settings.
3. You can view the status of your gateway connections. Notice the local network site you created is listed as
'Connecting'. The status will change after you have created your connections. You can close this page when you
are finished viewing the status.
2. On the Vir tual network gateway page, select + Add . This opens the Create vir tual network gateway
page.
3. On the Basics tab, fill in the values for your virtual network gateway.
Project details
Subscription : Select the subscription you want to use from the dropdown.
Resource Group : This setting is autofilled when you select your virtual network on this page.
Instance details
Name : Name your gateway. Naming your gateway not the same as naming a gateway subnet. It's the
name of the gateway object you are creating.
Region : Select the region in which you want to create this resource. The region for the gateway must be
the same as the virtual network.
Gateway type : Select VPN . VPN gateways use the virtual network gateway type VPN .
VPN type : Select the VPN type that is specified for your configuration. Most configurations require a
Route-based VPN type.
SKU : Select the gateway SKU from the dropdown. The SKUs listed in the dropdown depend on the VPN
type you select. For more information about gateway SKUs, see Gateway SKUs.
Generation : For information about VPN Gateway Generation, see Gateway SKUs.
Vir tual network : From the dropdown, select the virtual network to which you want to add this gateway.
Gateway subnet address range : This field only appears if your VNet doesn't have a gateway subnet. If
possible, make the range /27 or larger (/26,/25 etc.). We don't recommend creating a range any smaller
than /28. If you already have a gateway subnet, you can view GatewaySubnet details by navigating to
your virtual network. Click Subnets to view the range. If you want to change the range, you can delete
and recreate the GatewaySubnet.
Public IP address
This setting specifies the public IP address object that gets associated to the VPN gateway. The public IP
address is dynamically assigned to this object when the VPN gateway is created. The only time the Public IP
address changes is when the gateway is deleted and re-created. It doesn't change across resizing, resetting,
or other internal maintenance/upgrades of your VPN gateway.
Public IP address : Leave Create new selected.
Public IP address name : In the text box, type a name for your public IP address instance.
Assignment : VPN gateway supports only Dynamic.
Enable active-active mode : Only select Enable active-active mode if you are creating an active-
active gateway configuration. Otherwise, leave this setting Disabled .
Leave Configure BGP as Disabled , unless your configuration specifically requires this setting. If you do
require this setting, the default ASN is 65515, although this can be changed.
4. Select Review + create to run validation.
5. Once validation passes, select Create to deploy the VPN gateway. A gateway can take up to 45 minutes to
fully create and deploy. You can see the deployment status on the Overview page for your gateway.
After the gateway is created, you can view the IP address that has been assigned to it by looking at the virtual
network in the portal. The gateway appears as a connected device.
IMPORTANT
When working with gateway subnets, avoid associating a network security group (NSG) to the gateway subnet. Associating a
network security group to this subnet may cause your Virtual Network gateway(VPN, Express Route gateway) to stop
functioning as expected. For more information about network security groups, see What is a network security group?
C O N N EC T S TO LO C A L GAT EWAY P UB L IC IP
VIRT UA L N ET W O RK A DDRESS SPA C E REGIO N N ET W O RK SIT E A DDRESS
The local network gateway specifies the address range and the Public IP address associated with your classic VNet
and its virtual network gateway. If you are doing these steps as an exercise, refer to the Example values.
1. From the Azure portal, in Search resources, ser vices, and docs (G+/) type local network gateway .
Locate local network gateway under Marketplace in the search results and select it. This opens the
Create local network gateway page.
2. On the Create local network gateway page , specify the values for your local network gateway.
4. On the Site-to-site VPN connections page, click the name of the site.
5. On the connection page for your local site, click the name of the local site to open the Local site page.
6. On the Local site page, replace the VPN gateway IP address with the IP address of the Resource
Manager gateway.
Connect-AzAccount
Get-AzSubscription
If you have more than one subscription, specify the subscription that you want to use.
Next, log in to use the classic PowerShell cmdlets (Service Management). Use the following command to add your
Azure account for the classic deployment model:
Add-AzureAccount
Get a list of your subscriptions. This step may be necessary when adding the Service Management cmdlets,
depending on your Azure module install.
Get-AzureSubscription
If you have more than one subscription, specify the subscription that you want to use.
Open the file with a text editor and view the name for your classic VNet. Use the names in the network
configuration file when running your PowerShell cmdlets.
VNet names are listed as Vir tualNetworkSite name =
Site names are listed as LocalNetworkSite name=
3. Create the connection
Set the shared key and create the connection from the classic VNet to the Resource Manager VNet. You cannot set
the shared key using the portal. Make sure you run these steps while logged in using the classic version of the
PowerShell cmdlets. To do so, use Add-AzureAccount . Otherwise, you will not be able to set the '-
AzureVNetGatewayKey'.
In this example, -VNetName is the name of the classic VNet as found in your network configuration file.
The -LocalNetworkSiteName is the name you specified for the local site, as found in your network
configuration file.
The -SharedKey is a value that you generate and specify. For this example, we used abc123, but you can
generate something more complex. The important thing is that the value you specify here must be the same
value that you specified when creating your Resource Manager to classic connection.
3. On the Site-to-site connections page, under Name , select the site connection you want to view.
4. On the Proper ties page, view the information about the connection.
To verify the connection from your Resource Manager VNet to your classic VNet
In the Azure portal, you can view the connection status of a Resource Manager VPN Gateway by navigating to the
connection. The following steps show one way to navigate to your connection and verify.
1. In the Azure portal, click All resources and navigate to your virtual network gateway.
2. On the blade for your virtual network gateway, click Connections . You can see the status of each
connection.
3. Click the name of the connection that you want to verify. In Essentials , you can view more information
about your connection. The Status values are 'Succeeded' and 'Connected' when you have made a
successful connection.
VNet-to-VNet FAQ
The VNet-to-VNet FAQ applies to VPN gateway connections. For information about VNet peering, see Virtual
network peering.
Does Azure charge for traffic between VNets?
VNet-to-VNet traffic within the same region is free for both directions when you use a VPN gateway connection.
Cross-region VNet-to-VNet egress traffic is charged with the outbound inter-VNet data transfer rates based on the
source regions. For more information, see VPN Gateway pricing page. If you're connecting your VNets by using
VNet peering instead of a VPN gateway, see Virtual network pricing.
Does VNet-to -VNet traffic travel across the internet?
No. VNet-to-VNet traffic travels across the Microsoft Azure backbone, not the internet.
Can I establish a VNet-to -VNet connection across Azure Active Directory (AAD) tenants?
Yes, VNet-to-VNet connections that use Azure VPN gateways work across AAD tenants.
Is VNet-to -VNet traffic secure?
Yes, it's protected by IPsec/IKE encryption.
Do I need a VPN device to connect VNets together?
No. Connecting multiple Azure virtual networks together doesn't require a VPN device unless cross-premises
connectivity is required.
Do my VNets need to be in the same region?
No. The virtual networks can be in the same or different Azure regions (locations).
If the VNets aren't in the same subscription, do the subscriptions need to be associated with the same Active
Directory tenant?
No.
Can I use VNet-to -VNet to connect virtual networks in separate Azure instances?
No. VNet-to-VNet supports connecting virtual networks within the same Azure instance. For example, you can’t
create a connection between global Azure and Chinese/German/US government Azure instances. Consider using a
Site-to-Site VPN connection for these scenarios.
Can I use VNet-to -VNet along with multi-site connections?
Yes. Virtual network connectivity can be used simultaneously with multi-site VPNs.
How many on-premises sites and virtual networks can one virtual network connect to?
See the Gateway requirements table.
Can I use VNet-to -VNet to connect VMs or cloud services outside of a VNet?
No. VNet-to-VNet supports connecting virtual networks. It doesn't support connecting virtual machines or cloud
services that aren't in a virtual network.
Can a cloud service or a load-balancing endpoint span VNets?
No. A cloud service or a load-balancing endpoint can't span across virtual networks, even if they're connected
together.
Can I use a PolicyBased VPN type for VNet-to -VNet or Multi-Site connections?
No. VNet-to-VNet and Multi-Site connections require Azure VPN gateways with RouteBased (previously called
dynamic routing) VPN types.
Can I connect a VNet with a RouteBased VPN Type to another VNet with a PolicyBased VPN type?
No, both virtual networks MUST use route-based (previously called dynamic routing) VPNs.
Do VPN tunnels share bandwidth?
Yes. All VPN tunnels of the virtual network share the available bandwidth on the Azure VPN gateway and the same
VPN gateway uptime SLA in Azure.
Are redundant tunnels supported?
Redundant tunnels between a pair of virtual networks are supported when one virtual network gateway is
configured as active-active.
Can I have overlapping address spaces for VNet-to -VNet configurations?
No. You can't have overlapping IP address ranges.
Can there be overlapping address spaces among connected virtual networks and on-premises local sites?
No. You can't have overlapping IP address ranges.
Create a Site-to-Site connection in the Azure portal
11/2/2020 • 18 minutes to read • Edit Online
This article shows you how to use the Azure portal to create a Site-to-Site VPN gateway connection from your on-
premises network to the VNet. The steps in this article apply to the Resource Manager deployment model. You can
also create this configuration using a different deployment tool or deployment model by selecting a different
option from the following list:
A Site-to-Site VPN gateway connection is used to connect your on-premises network to an Azure virtual network
over an IPsec/IKE (IKEv1 or IKEv2) VPN tunnel. This type of connection requires a VPN device located on-premises
that has an externally facing public IP address assigned to it. For more information about VPN gateways, see About
VPN gateway.
Prerequisites
Verify that you have met the following criteria before beginning your configuration:
An Azure account with an active subscription. If you don't have one, create one for free.
Make sure you have a compatible VPN device and someone who is able to configure it. For more information
about compatible VPN devices and device configuration, see About VPN Devices.
Verify that you have an externally facing public IPv4 address for your VPN device.
If you are unfamiliar with the IP address ranges located in your on-premises network configuration, you need
to coordinate with someone who can provide those details for you. When you create this configuration, you
must specify the IP address range prefixes that Azure will route to your on-premises location. None of the
subnets of your on-premises network can over lap with the virtual network subnets that you want to connect
to.
5. Once you select Create , the Create vir tual network page opens.
6. On the Basics tab, configure Project details and Instance details VNet settings.
When you fill in the fields, you see a green check mark when the characters you enter in the field are
validated. Some values are autofilled, which you can replace with your own values:
Subscription : Verify that the subscription listed is the correct one. You can change subscriptions by
using the drop-down.
Resource group : Select an existing resource group, or click Create new to create a new one. For more
information about resource groups, see Azure Resource Manager overview.
Name : Enter the name for your virtual network.
Region : Select the location for your VNet. The location determines where the resources that you deploy
to this VNet will live.
7. On the IP Addresses tab, configure the values. The values shown in the examples below are for
demonstration purposes. Adjust these values according to the settings that you require.
IPv4 address space : By default, an address space is automatically created. You can click the address
space to adjust it to reflect your own values. You can also add additional address spaces.
Subnet : If you use the default address space, a default subnet is created automatically. If you change the
address space, you need to add a subnet. Select + Add subnet to open the Add subnet window.
Configure the following settings and then select Add to add the values:
Subnet name : In this example, we named the subnet "FrontEnd".
Subnet address range : The address range for this subnet.
8. On the Security tab, at this time, leave the default values:
DDos protection : Basic
Firewall : Disabled
9. Select Review + create to validate the virtual network settings.
10. After the settings have been validated, select Create .
3. On the Basics tab, fill in the values for your virtual network gateway.
Subscription : Select the subscription you want to use from the dropdown.
Resource Group : This setting is autofilled when you select your virtual network on this page.
Instance details
Name : Name your gateway. Naming your gateway not the same as naming a gateway subnet. It's the
name of the gateway object you are creating.
Region : Select the region in which you want to create this resource. The region for the gateway must be
the same as the virtual network.
Gateway type : Select VPN . VPN gateways use the virtual network gateway type VPN .
VPN type : Select the VPN type that is specified for your configuration. Most configurations require a
Route-based VPN type.
SKU : Select the gateway SKU from the dropdown. The SKUs listed in the dropdown depend on the VPN
type you select. For more information about gateway SKUs, see Gateway SKUs.
Generation : For information about VPN Gateway Generation, see Gateway SKUs.
Vir tual network : From the dropdown, select the virtual network to which you want to add this
gateway.
Gateway subnet address range : This field only appears if your VNet doesn't have a gateway subnet.
If possible, make the range /27 or larger (/26,/25 etc.). We don't recommend creating a range any
smaller than /28. If you already have a gateway subnet, you can view GatewaySubnet details by
navigating to your virtual network. Click Subnets to view the range. If you want to change the range,
you can delete and recreate the GatewaySubnet.
Public IP address
This setting specifies the public IP address object that gets associated to the VPN gateway. The public IP
address is dynamically assigned to this object when the VPN gateway is created. The only time the Public IP
address changes is when the gateway is deleted and re-created. It doesn't change across resizing, resetting,
or other internal maintenance/upgrades of your VPN gateway.
Public IP address : Leave Create new selected.
Public IP address name : In the text box, type a name for your public IP address instance.
Assignment : VPN gateway supports only Dynamic.
Enable active-active mode : Only select Enable active-active mode if you are creating an active-
active gateway configuration. Otherwise, leave this setting Disabled .
Leave Configure BGP as Disabled , unless your configuration specifically requires this setting. If you do
require this setting, the default ASN is 65515, although this can be changed.
4. Select Review + create to run validation.
5. Once validation passes, select Create to deploy the VPN gateway.
A gateway can take up to 45 minutes to fully create and deploy. You can see the deployment status on the
Overview page for your gateway. After the gateway is created, you can view the IP address that has been assigned
to it by looking at the virtual network in the portal. The gateway appears as a connected device.
IMPORTANT
When working with gateway subnets, avoid associating a network security group (NSG) to the gateway subnet. Associating
a network security group to this subnet may cause your Virtual Network gateway(VPN, Express Route gateway) to stop
functioning as expected. For more information about network security groups, see What is a network security group?
NOTE
Azure VPN supports only one IPv4 address for each FQDN. If the domain name resolves to multiple IP addresses,
Azure VPN Gateway will use the first IP address returned by the DNS servers. To eliminate the uncertainty, we
recommend that your FQDN always resolve to a single IPv4 address. IPv6 is not supported.
Azure VPN Gateway maintains a DNS cache refreshed every 5 minutes. The gateway tries to resolve the FQDNs
for disconnected tunnels only. Resetting the gateway will also trigger FQDN resolution.
3. When you have finished specifying the values, select the Create button at the bottom of the page to create
the local network gateway.
foreach($Nic in $Nics)
{
$VM = $VMs | Where-Object -Property Id -eq $Nic.VirtualMachine.Id
$Prv = $Nic.IpConfigurations | Select-Object -ExpandProperty PrivateIpAddress
$Alloc = $Nic.IpConfigurations | Select-Object -ExpandProperty PrivateIpAllocationMethod
Write-Output "$($VM.Name): $Prv,$Alloc"
}
2. Verify that you are connected to your VNet using the Point-to-Site VPN connection.
3. Open Remote Desktop Connection by typing "RDP" or "Remote Desktop Connection" in the search box
on the taskbar, then select Remote Desktop Connection. You can also open Remote Desktop Connection
using the 'mstsc' command in PowerShell.
4. In Remote Desktop Connection, enter the private IP address of the VM. You can click "Show Options" to
adjust additional settings, then connect.
Troubleshoot a connection
If you are having trouble connecting to a virtual machine over your VPN connection, check the following:
Verify that your VPN connection is successful.
Verify that you are connecting to the private IP address for the VM.
If you can connect to the VM using the private IP address, but not the computer name, verify that you have
configured DNS properly. For more information about how name resolution works for VMs, see Name
Resolution for VMs.
For more information about RDP connections, see Troubleshoot Remote Desktop connections to a VM.
Next steps
For information about BGP, see the BGP Overview and How to configure BGP.
For information about forced tunneling, see About forced tunneling.
For information about Highly Available Active-Active connections, see Highly Available cross-premises and
VNet-to-VNet connectivity.
For information about how to limit network traffic to resources in a virtual network, see Network Security.
For information about how Azure routes traffic between Azure, on-premises, and Internet resources, see Virtual
network traffic routing.
For information about creating a Site-to-Site VPN connection using Azure Resource Manager template, see
Create a Site-to-Site VPN Connection.
For information about creating a VNet-to-VNet VPN connection using Azure Resource Manager template, see
Deploy HBase geo replication.
Tutorial: Connect a virtual network to an
ExpressRoute circuit using the portal
11/2/2020 • 5 minutes to read • Edit Online
This tutorial helps you create a connection to link a virtual network to an Azure ExpressRoute circuit using the
Azure portal. The virtual networks that you connect to your Azure ExpressRoute circuit can either be in the same
subscription or be part of another subscription.
In this tutorial, you learn how to:
Connect a virtual networking to a circuit in the same subscription.
Connect a virtual networking to a circuit in a different subscription.
Delete the link between the virtual network and ExpressRoute circuit.
Prerequisites
Review the prerequisites, routing requirements, and workflows before you begin configuration.
You must have an active ExpressRoute circuit.
Follow the instructions to create an ExpressRoute circuit and have the circuit enabled by your
connectivity provider.
Ensure that you have Azure private peering configured for your circuit. See the Create and modify
peering for an ExpressRoute circuit article for peering and routing instructions.
Ensure that Azure private peering gets configured and establishes BGP peering between your network
and Microsoft for end-to-end connectivity.
Ensure that you have a virtual network and a virtual network gateway created and fully provisioned.
Follow the instructions to create a virtual network gateway for ExpressRoute. A virtual network gateway
for ExpressRoute uses the GatewayType 'ExpressRoute', not VPN.
You can link up to 10 virtual networks to a standard ExpressRoute circuit. All virtual networks must be in the
same geopolitical region when using a standard ExpressRoute circuit.
A single VNet can be linked to up to four ExpressRoute circuits. Use the following process to create a new
connection object for each ExpressRoute circuit you're connecting to. The ExpressRoute circuits can be in the
same subscription, different subscriptions, or a mix of both.
If you enable the ExpressRoute premium add-on, you can link virtual networks outside of the geopolitical
region of the ExpressRoute circuit. The premium add-on will also allow you to connect more than 10 virtual
networks to your ExpressRoute circuit depending on the bandwidth chosen. Check the FAQ for more details
on the premium add-on.
You can view a video before beginning to better understand the steps.
2. You can now start provisioning a connection to link your virtual network gateway to your ExpressRoute
circuit. Select Connection > Add to open the Add connection page.
3. Enter a name for the connection and then select Next: Settings > .
4. Select the gateway that belongs to the virtual network that you want to link to the circuit and select Review
+ create . Then select Create after validation completes.
5. After your connection has been successfully configured, your connection object will show the information
for the connection.
Connect a VNet to a circuit - different subscription
You can share an ExpressRoute circuit across multiple subscriptions. The following figure shows a simple schematic
of how sharing works for ExpressRoute circuits across multiple subscriptions.
Each of the smaller clouds within the large cloud is used to represent subscriptions that belong to different
departments within an organization. Each of the departments within the organization uses their own subscription
for deploying their services--but they can share a single ExpressRoute circuit to connect back to your on-premises
network. A single department (in this example: IT) can own the ExpressRoute circuit. Other subscriptions within the
organization may use the ExpressRoute circuit.
NOTE
Connectivity and bandwidth charges for the dedicated circuit will be applied to the ExpressRoute circuit owner. All virtual
networks share the same bandwidth.
NOTE
Each connection requires a separate authorization.
1. In the ExpressRoute page, select Authorizations and then type a name for the authorization and select
Save .
2. Once the configuration is saved, copy the Resource ID and the Authorization Key .
NOTE
The location must match the virtual network gateway location you're creating the connection for.
3. In the Settings page, Select the Virtual network gateway and check the Redeem authorization check box.
Enter the Authorization key and the Peer circuit URI and give the connection a name. Select OK .
NOTE
The Peer Circuit URI is the Resource ID of the ExpressRoute circuit (which you can find under the Properties Setting
pane of the ExpressRoute Circuit).
Next steps
In this tutorial, you learned how to connect a virtual network to a circuit in the same subscription and a different
subscription. For more information about the ExpressRoute gateway, see:
About ExpressRoute virtual network gateways
Work with a virtual network TAP using the Azure CLI
11/2/2020 • 3 minutes to read • Edit Online
Azure virtual network TAP (Terminal Access Point) allows you to continuously stream your virtual machine network
traffic to a network packet collector or analytics tool. The collector or analytics tool is provided by a network virtual
appliance partner. For a list of partner solutions that are validated to work with virtual network TAP, see partner
solutions.
2. Set the subscription id that you will use to create a virtual network TAP resource.
3. Re-register the subscription ID that you'll use to create a virtual network TAP resource. If you get a
registration error when you create a TAP resource, run the following command:
4. If the destination for the virtual network TAP is the network interface on the network virtual appliance for
collector or analytics tool -
Retrieve the IP configuration of the network virtual appliance's network interface into a variable that
is used in a later step. The ID is the end point that will aggregate the TAP traffic. The following
example retrieves the ID of the ipconfig1 IP configuration for a network interface named
myNetworkInterface, in a resource group named myResourceGroup:
5. If the destination for the virtual network TAP is an azure internal load balancer:
Retrieve the front end IP configuration of the Azure internal load balancer into a variable that is used
in a later step. The ID is the end point that will aggregate the TAP traffic. The following example
retrieves the ID of the frontendipconfig1 front end IP configuration for a load balancer named
myInternalLoadBalancer, in a resource group named myResourceGroup:
Create the virtual network TAP using the ID of the frontend IP configuration as the destination and an
optional port property. The port specifies the destination port on front end IP configuration where
the TAP traffic will be received :
2. Create a TAP configuration on the network interface of the monitored virtual machine. The following
example creates a TAP configuration for a network interface named myNetworkInterface:
az network nic vtap-config create \
--resource-group myResourceGroup \
--nic myNetworkInterface \
--vnet-tap $tapId \
--name mytapconfig \
--subscription subscriptionId
The Azure Virtual Network container network interface (CNI) plug-in installs in an Azure virtual machine and
brings virtual network capabilities to Kubernetes Pods and Docker containers. To learn more about the plug-in, see
Enable containers to use Azure Virtual Network capabilities. Additionally, the plug-in can be used with the Azure
Kubernetes Service (AKS) by choosing the Advanced Networking option, which automatically places AKS
containers in a virtual network.
clusterSubnet under kubernetesConfig CIDR of the virtual network subnet where the cluster is
deployed, and from which IP addresses are allocated to Pods
vnetSubnetId under masterProfile Specifies the Azure Resource Manager resource ID of the
subnet where the cluster is to be deployed
max-Pods under kubeletConfig Maximum number of Pods on every agent virtual machine.
For the plug-in, the default is 30. You can specify up to 250
Example configuration
The json example that follows is for a cluster with the following properties:
1 Master node and 2 Agent nodes
Is deployed in a subnet named KubeClusterSubnet (10.0.0.0/20), with both Master and Agent nodes residing in
it.
{
"apiVersion": "vlabs",
"properties": {
"orchestratorProfile": {
"orchestratorType": "Kubernetes",
"kubernetesConfig": {
"clusterSubnet": "10.0.0.0/20" --> Subnet allocated for the cluster
}
},
"masterProfile": {
"count": 1,
"dnsPrefix": "ACSKubeMaster",
"vmSize": "Standard_A2",
"vnetSubnetId": "/subscriptions/<subscription ID>/resourceGroups/<Resource Group
Name>/providers/Microsoft.Network/virtualNetworks/<Vnet Name>/subnets/KubeClusterSubnet",
"firstConsecutiveStaticIP": "10.0.1.50", --> IP address allocated to the Master node
"vnetCidr": "10.0.0.0/16" --> Virtual network address space
},
"agentPoolProfiles": [
{
"name": "k8sagentpoo1",
"count": 2,
"vmSize": "Standard_A2_v2",
"vnetSubnetId": "/subscriptions/<subscription ID>/resourceGroups/<Resource Group
Name>/providers/Microsoft.Network/virtualNetworks/<VNet Name>/subnets/KubeClusterSubnet",
"availabilityProfile": "AvailabilitySet"
}
],
"linuxProfile": {
"adminUsername": "KubeServerAdmin",
"ssh": {
"publicKeys": [
{…}
]
}
},
"servicePrincipalProfile": {
"clientId": "dd438987-aa12-4754-b47d-375811889714",
"secret": "azure123"
}
}
}
The rules NAT traffic that is not destined to the specified IP ranges. The assumption is that all traffic outside
the previous ranges is internet traffic. You can choose to specify the IP ranges of the virtual machine's virtual
network, that of peered virtual networks, and on-premises networks.
Windows virtual machines automatically source NAT traffic that has a destination outside the subnet to
which the virtual machine belongs. It is not possible to specify custom IP ranges.
After completing the previous steps, Pods brought up on the Kubernetes Agent virtual machines are automatically
assigned private IP addresses from the virtual network.
The containers automatically start receiving IP addresses from the allocated pool. If you want to load balance traffic
to the Docker containers, they must be placed behind a software load balancer, and you must configure a load
balancer probe, the same way you create a policy and probes for a virtual machine.
CNI network configuration file
The CNI network configuration file is described in JSON format. It is, by default, present in /etc/cni/net.d for
Linux and c:\cni\netconf for Windows. The file specifies the configuration of the plug-in and is different for
Windows and Linux. The json that follows is a sample Linux configuration file, followed by an explanation for some
of the key settings. You don't need to make any changes to the file:
{
"cniVersion":"0.3.0",
"name":"azure",
"plugins":[
{
"type":"azure-vnet",
"mode":"bridge",
"bridge":"azure0",
"ipam":{
"type":"azure-vnet-ipam"
}
},
{
"type":"portmap",
"capabilities":{
"portMappings":true
},
"snat":true
}
]
}
Settings explanation
cniVersion : The Azure Virtual Network CNI plug-ins support versions 0.3.0 and 0.3.1 of the CNI spec.
name : Name of the network. This property can be set to any unique value.
type : Name of the network plug-in. Set to azure-vnet.
mode : Operational mode. This field is optional. The only mode supported is "bridge". For more information,
see operational modes.
bridge : Name of the bridge that will be used to connect containers to a virtual network. This field is optional. If
omitted, the plugin automatically picks a unique name, based on the master interface index.
ipam type : Name of the IPAM plug-in. Always set to azure-vnet-ipam.
\$scripts/install-cni-plugin.sh [version]
The script installs the plug-in under /opt/cni/bin for Linux and c:\cni\bin for Windows. The installed plug-in
comes with a simple network configuration file that works after installation. It doesn't need to be updated. To learn
more about the settings in the file, see CNI network configuration file.
Upgrade an IPv4 application to IPv6 in Azure virtual
network - PowerShell
11/2/2020 • 4 minutes to read • Edit Online
This article shows you how to add IPv6 connectivity to an existing IPv4 application
in an Azure virtual network with a Standard Load Balancer and Public IP. The in-place upgrade includes:
IPv6 address space for the virtual network and subnet
a Standard Load Balancer with both IPv4 and IPV6 frontend configurations
VMs with NICs that have both an IPv4 + IPv6 configuration
IPv6 Public IP so the load balancer has Internet-facing IPv6 connectivity
O P T IO N EXA M P L E/ L IN K
Select the Cloud Shell button on the menu bar at the upper
right in the Azure portal.
Prerequisites
This article assumes that you deployed a Standard Load Balancer as described in Quickstart: Create a Standard
Load Balancer - Azure PowerShell.
$PublicIP_v6 = New-AzPublicIpAddress `
-Name "PublicIP_v6" `
-ResourceGroupName $rg.ResourceGroupName `
-Location $rg.Location `
-Sku Standard `
-AllocationMethod Static `
-IpAddressVersion IPv6
# Add IPv6 components to the local copy of the load balancer configuration
$lb | Add-AzLoadBalancerFrontendIpConfig `
-Name "dsLbFrontEnd_v6" `
-PublicIpAddress $PublicIP_v6
# Update the running load balancer with the new backend pool
$lb | Set-AzLoadBalancer
#Finalize all the load balancer updates on the running load balancer
$lb | Set-AzLoadBalancer
#Retrieve the subnet object from the local copy of the VNET
$subnet= $vnet.subnets[0]
#Add IPv6 prefix to the Subnet (subnet of the VNET prefix, of course)
$subnet.addressprefix.add("ace:cab:deca::/64")
#Add an IPv6 IPconfig to NIC_1 and update the NIC on the running VM
$NIC_1 | Add-AzNetworkInterfaceIpConfig -Name MyIPv6Config -Subnet $vnet.Subnets[0] -
PrivateIpAddressVersion IPv6 -LoadBalancerBackendAddressPool $backendPoolv6
$NIC_1 | Set-AzNetworkInterface
#Add an IPv6 IPconfig to NIC_2 and update the NIC on the running VM
$NIC_2 | Add-AzNetworkInterfaceIpConfig -Name MyIPv6Config -Subnet $vnet.Subnets[0] -
PrivateIpAddressVersion IPv6 -LoadBalancerBackendAddressPool $backendPoolv6
$NIC_2 | Set-AzNetworkInterface
#Add an IPv6 IPconfig to NIC_3 and update the NIC on the running VM
$NIC_3 | Add-AzNetworkInterfaceIpConfig -Name MyIPv6Config -Subnet $vnet.Subnets[0] -
PrivateIpAddressVersion IPv6 -LoadBalancerBackendAddressPool $backendPoolv6
$NIC_3 | Set-AzNetworkInterface
Clean up resources
When no longer needed, you can use the Remove-AzResourceGroup command to remove the resource group, VM,
and all related resources.
Next steps
In this article, you updated an existing Standard Load Balancer with a IPv4 frontend IP configuration to a dual stack
(IPv4 and IPv6) configuration. You also added IPv6 configurations to the NICs of the VMs in the backend pool and
to the Virtual Network that hosts them. To learn more about IPv6 support in Azure virtual networks, see What is
IPv6 for Azure Virtual Network?
Add IPv6 to an IPv4 application in Azure virtual
network - Azure CLI
11/2/2020 • 4 minutes to read • Edit Online
This article shows you how to add IPv6 addresses to an application that is using IPv4 public IP address in an Azure
virtual network for a Standard Load Balancer using Azure CLI. The in-place upgrade includes a virtual network and
subnet, a Standard Load Balancer with IPv4 + IPV6 frontend configurations, VMs with NICs that have a IPv4 + IPv6
configurations, network security group, and public IPs.
O P T IO N EXA M P L E/ L IN K
Select the Cloud Shell button on the menu bar at the upper
right in the Azure portal.
Prerequisites
This article assumes that you deployed a Standard Load Balancer as described in Quickstart: Create a Standard
Load Balancer - Azure CLI.
Next steps
In this article, you updated an existing Standard Load Balancer with a IPv4 frontend IP configuration to a dual stack
(IPv4 and IPv6) configuration. You also added IPv6 configurations to the NICs of the VMs in the backend pool. To
learn more about IPv6 support in Azure virtual networks, see What is IPv6 for Azure Virtual Network?
Deploy an IPv6 dual stack application using Basic
Load Balancer - PowerShell
11/2/2020 • 9 minutes to read • Edit Online
This article shows you how to deploy a dual stack (IPv4 + IPv6) application with Basic Load Balancer using Azure
PowerShell that includes a dual stack virtual network and subnet, a Basic Load Balancer with dual (IPv4 + IPv6)
front-end configurations, VMs with NICs that have a dual IP configuration, network security group, and public IPs.
To deploy a dual stack (IPV4 + IPv6) application using Standard Load Balancer, see Deploy an IPv6 dual stack
application with Standard Load Balancer using Azure PowerShell.
O P T IO N EXA M P L E/ L IN K
Select the Cloud Shell button on the menu bar at the upper
right in the Azure portal.
$PublicIP_v4 = New-AzPublicIpAddress `
-Name "dsPublicIP_v4" `
-ResourceGroupName $rg.ResourceGroupName `
-Location $rg.Location `
-AllocationMethod Dynamic `
-IpAddressVersion IPv4
$PublicIP_v6 = New-AzPublicIpAddress `
-Name "dsPublicIP_v6" `
-ResourceGroupName $rg.ResourceGroupName `
-Location $rg.Location `
-AllocationMethod Dynamic `
-IpAddressVersion IPv6
To access your virtual machines using a RDP connection, create a IPV4 public IP addresses for the virtual machines
with New-AzPublicIpAddress.
$RdpPublicIP_1 = New-AzPublicIpAddress `
-Name "RdpPublicIP_1" `
-ResourceGroupName $rg.ResourceGroupName `
-Location $rg.Location `
-AllocationMethod Dynamic `
-IpAddressVersion IPv4
$RdpPublicIP_2 = New-AzPublicIpAddress `
-Name "RdpPublicIP_2" `
-ResourceGroupName $rg.ResourceGroupName `
-Location $rg.Location `
-AllocationMethod Dynamic `
-IpAddressVersion IPv4
$frontendIPv6 = New-AzLoadBalancerFrontendIpConfig `
-Name "dsLbFrontEnd_v6" `
-PublicIpAddress $PublicIP_v6
$backendPoolv4 = New-AzLoadBalancerBackendAddressPoolConfig `
-Name "dsLbBackEndPool_v4"
$backendPoolv6 = New-AzLoadBalancerBackendAddressPoolConfig `
-Name "dsLbBackEndPool_v6"
$probe = New-AzLoadBalancerProbeConfig -Name MyProbe -Protocol tcp -Port 3389 -IntervalInSeconds 15 -ProbeCount
2
$lbrule_v4 = New-AzLoadBalancerRuleConfig `
-Name "dsLBrule_v4" `
-FrontendIpConfiguration $frontendIPv4 `
-BackendAddressPool $backendPoolv4 `
-Protocol Tcp `
-FrontendPort 80 `
-BackendPort 80 `
-probe $probe
$lbrule_v6 = New-AzLoadBalancerRuleConfig `
-Name "dsLBrule_v6" `
-FrontendIpConfiguration $frontendIPv6 `
-BackendAddressPool $backendPoolv6 `
-Protocol Tcp `
-FrontendPort 80 `
-BackendPort 80 `
-probe $probe
$lb = New-AzLoadBalancer `
-ResourceGroupName $rg.ResourceGroupName `
-Location $rg.Location `
-Name "MyLoadBalancer" `
-Sku "Basic" `
-FrontendIpConfiguration $frontendIPv4,$frontendIPv6 `
-BackendAddressPool $backendPoolv4,$backendPoolv6 `
-LoadBalancingRule $lbrule_v4,$lbrule_v6
$avset = New-AzAvailabilitySet `
-ResourceGroupName $rg.ResourceGroupName `
-Location $rg.Location `
-Name "dsAVset" `
-PlatformFaultDomainCount 2 `
-PlatformUpdateDomainCount 2 `
-Sku aligned
$rule1 = New-AzNetworkSecurityRuleConfig `
-Name 'myNetworkSecurityGroupRuleRDP' `
-Description 'Allow RDP' `
-Access Allow `
-Protocol Tcp `
-Direction Inbound `
-Priority 100 `
-SourceAddressPrefix * `
-SourcePortRange * `
-DestinationAddressPrefix * `
-DestinationPortRange 3389
$nsg = New-AzNetworkSecurityGroup `
-ResourceGroupName $rg.ResourceGroupName `
-Location $rg.Location `
-Name "dsNSG1" `
-SecurityRules $rule1,$rule2
Create NICs
Create virtual NICs with New-AzNetworkInterface. The following example creates two virtual NICs both with IPv4
and IPv6 configurations. (One virtual NIC for each VM you create for your app in the following steps).
$Ip4Config=New-AzNetworkInterfaceIpConfig `
-Name dsIp4Config `
-Subnet $vnet.subnets[0] `
-PrivateIpAddressVersion IPv4 `
-LoadBalancerBackendAddressPool $backendPoolv4 `
-PublicIpAddress $RdpPublicIP_1
$Ip6Config=New-AzNetworkInterfaceIpConfig `
-Name dsIp6Config `
-Subnet $vnet.subnets[0] `
-PrivateIpAddressVersion IPv6 `
-LoadBalancerBackendAddressPool $backendPoolv6
$NIC_1 = New-AzNetworkInterface `
-Name "dsNIC1" `
-ResourceGroupName $rg.ResourceGroupName `
-Location $rg.Location `
-NetworkSecurityGroupId $nsg.Id `
-IpConfiguration $Ip4Config,$Ip6Config
$Ip4Config=New-AzNetworkInterfaceIpConfig `
-Name dsIp4Config `
-Subnet $vnet.subnets[0] `
-PrivateIpAddressVersion IPv4 `
-LoadBalancerBackendAddressPool $backendPoolv4 `
-PublicIpAddress $RdpPublicIP_2
$NIC_2 = New-AzNetworkInterface `
-Name "dsNIC2" `
-ResourceGroupName $rg.ResourceGroupName `
-Location $rg.Location `
-NetworkSecurityGroupId $nsg.Id `
-IpConfiguration $Ip4Config,$Ip6Config
$cred = get-credential -Message "DUAL STACK VNET SAMPLE: Please enter the Administrator credential to log into
the VMs."
Now you can create the VMs with New-AzVM. The following example creates two VMs and the required virtual
network components if they do not already exist.
$vmsize = "Standard_A2"
$ImagePublisher = "MicrosoftWindowsServer"
$imageOffer = "WindowsServer"
$imageSKU = "2019-Datacenter"
$vmName= "dsVM1"
$VMconfig1 = New-AzVMConfig -VMName $vmName -VMSize $vmsize -AvailabilitySetId $avset.Id 3> $null | Set-
AzVMOperatingSystem -Windows -ComputerName $vmName -Credential $cred -ProvisionVMAgent 3> $null | Set-
AzVMSourceImage -PublisherName $ImagePublisher -Offer $imageOffer -Skus $imageSKU -Version "latest" 3> $null |
Set-AzVMOSDisk -Name "$vmName.vhd" -CreateOption fromImage 3> $null | Add-AzVMNetworkInterface -Id $NIC_1.Id
3> $null
$VM1 = New-AzVM -ResourceGroupName $rg.ResourceGroupName -Location $rg.Location -VM $VMconfig1
$vmName= "dsVM2"
$VMconfig2 = New-AzVMConfig -VMName $vmName -VMSize $vmsize -AvailabilitySetId $avset.Id 3> $null | Set-
AzVMOperatingSystem -Windows -ComputerName $vmName -Credential $cred -ProvisionVMAgent 3> $null | Set-
AzVMSourceImage -PublisherName $ImagePublisher -Offer $imageOffer -Skus $imageSKU -Version "latest" 3> $null |
Set-AzVMOSDisk -Name "$vmName.vhd" -CreateOption fromImage 3> $null | Add-AzVMNetworkInterface -Id $NIC_2.Id
3> $null
$VM2 = New-AzVM -ResourceGroupName $rg.ResourceGroupName -Location $rg.Location -VM $VMconfig2
$rgName= "dsRG1"
$NICsInRG= get-AzNetworkInterface -resourceGroupName $rgName
write-host `nSummary of IPs in this Deployment:
write-host ******************************************
foreach ($NIC in $NICsInRG) {
$VMid= $NIC.virtualmachine.id
$VMnamebits= $VMid.split("/")
$VMname= $VMnamebits[($VMnamebits.count-1)]
write-host `nPrivate IP addresses for $VMname
$IPconfigsInNIC= $NIC.IPconfigurations
foreach ($IPconfig in $IPconfigsInNIC) {
$IPaddress= $IPconfig.privateipaddress
write-host " "$IPaddress
IF ($IPconfig.PublicIpAddress.ID) {
$IDbits= ($IPconfig.PublicIpAddress.ID).split("/")
$PipName= $IDbits[($IDbits.count-1)]
$PipObject= get-azPublicIpAddress -name $PipName -resourceGroup $rgName
write-host " "RDP address: $PipObject.IpAddress
}
}
}
The following figure shows a sample output that lists the private IPv4 and IPv6 addresses of the two VMs, and the
frontend IPv4 and IPv6 IP addresses of the Load Balancer.
View IPv6 dual stack virtual network in Azure portal
You can view the IPv6 dual stack virtual network in Azure portal as follows:
1. In the portal's search bar, enter dsVnet.
2. When myVir tualNetwork appears in the search results, select it. This launches the Over view page of the dual
stack virtual network named dsVnet. The dual stack virtual network shows the two NICs with both IPv4 and IPv6
configurations located in the dual stack subnet named dsSubnet.
Clean up resources
When no longer needed, you can use the Remove-AzResourceGroup command to remove the resource group, VM,
and all related resources.
Next steps
In this article, you created a Basic Load Balancer with a dual frontend IP configuration (IPv4 and IPv6). You also
created a two virtual machines that included NICs with dual IP configurations (IPV4 + IPv6) that were added to the
back-end pool of the load balancer. To learn more about IPv6 support in Azure virtual networks, see What is IPv6
for Azure Virtual Network?
Deploy an IPv6 dual stack application using Basic
Load Balancer - CLI
11/2/2020 • 8 minutes to read • Edit Online
This article shows you how to deploy a dual stack (IPv4 + IPv6) application with Basic Load Balancer using Azure
CLI that includes a dual stack virtual network with a dual stack subnet, a Basic Load Balancer with dual (IPv4 + IPv6)
front-end configurations, VMs with NICs that have a dual IP configuration, dual network security group rules, and
dual public IPs.
To deploy a dual stack (IPV4 + IPv6) application using Standard Load Balancer, see Deploy an IPv6 dual stack
application with Standard Load Balancer using Azure CLI.
If you don't have an Azure subscription, create a free account now.
O P T IO N EXA M P L E/ L IN K
Select the Cloud Shell button on the menu bar at the upper
right in the Azure portal.
az network lb create \
--name dsLB \
--resource-group DsResourceGroup01 \
--sku Basic \
--location eastus \
--frontend-ip-name dsLbFrontEnd_v4 \
--public-ip-address dsPublicIP_v4 \
--backend-pool-name dsLbBackEndPool_v4
az network lb probe create -g DsResourceGroup01 --lb-name dsLB -n dsProbe --protocol tcp --port 3389
az vm availability-set create \
--name dsAVset \
--resource-group DsResourceGroup01 \
--location eastus \
--platform-fault-domain-count 2 \
--platform-update-domain-count 2
Create a network security group rule for inbound and outbound connections
Create a network security group rule to allow RDP connections through port 3389, internet connection through
port 80, and for outbound connections with az network nsg rule create.
# Create inbound rule for port 3389
az network nsg rule create \
--name allowRdpIn \
--nsg-name dsNSG1 \
--resource-group DsResourceGroup01 \
--priority 100 \
--description "Allow Remote Desktop In" \
--access Allow \
--protocol "*" \
--direction Inbound \
--source-address-prefixes "*" \
--source-port-ranges "*" \
--destination-address-prefixes "*" \
--destination-port-ranges 3389
Create NICs
Create virtual NICs for each VM with az network nic create. The following example creates a virtual NIC for each
VM. Each NIC has two IP configurations (1 IPv4 config, 1 IPv6 config). You create the IPV6 configuration with az
network nic ip-config create.
# Create NICs
az network nic create \
--name dsNIC0 \
--resource-group DsResourceGroup01 \
--network-security-group dsNSG1 \
--vnet-name dsVNET \
--subnet dsSubNet \
--private-ip-address-version IPv4 \
--lb-address-pools dsLbBackEndPool_v4 \
--lb-name dsLB \
--public-ip-address dsVM0_remote_access
az vm create \
--name dsVM0 \
--resource-group DsResourceGroup01 \
--nics dsNIC0 \
--size Standard_A2 \
--availability-set dsAVset \
--image MicrosoftWindowsServer:WindowsServer:2019-Datacenter:latest
Clean up resources
When no longer needed, you can use the az group delete command to remove the resource group, VM, and all
related resources.
Next steps
In this article, you created a Basic Load Balancer with a dual frontend IP configuration (IPv4 and IPv6). You also
created a two virtual machines that included NICs with dual IP configurations (IPV4 + IPv6) that were added to the
back-end pool of the load balancer. To learn more about IPv6 support in Azure virtual networks, see What is IPv6
for Azure Virtual Network?
Deploy an IPv6 dual stack application with Basic Load
Balancer in Azure - Template
11/2/2020 • 2 minutes to read • Edit Online
This article provides a list of IPv6 configuration tasks with the portion of the Azure Resource Manager VM template
that applies to. Use the template described in this article to deploy a dual stack (IPv4 + IPv6) application with Basic
Load Balancer that includes a dual stack virtual network with IPv4 and IPv6 subnets, a Basic Load Balancer with dual
(IPv4 + IPv6) front-end configurations, VMs with NICs that have a dual IP configuration, network security group,
and public IPs.
To deploy a dual stack (IPV4 + IPv6) application using Standard Load Balancer, see Deploy an IPv6 dual stack
application with Standard Load Balancer - Template.
Required configurations
Search for the template sections in the template to see where they should occur.
IPv6 addressSpace for the virtual network
Template section to add:
"addressSpace": {
"addressPrefixes": [
"[variables('vnetv4AddressRange')]",
"[variables('vnetv6AddressRange')]"
{
"name": "V6Subnet",
"properties": {
"addressPrefix": "[variables('subnetv6AddressRange')]"
}
{
"name": "ipconfig-v6",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"privateIPAddressVersion":"IPv6",
"subnet": {
"id": "[variables('v6-subnet-id')]"
},
"loadBalancerBackendAddressPools": [
{
"id": "
[concat(resourceId('Microsoft.Network/loadBalancers','loadBalancer'),'/backendAddressPools/LBBAP-v6')]"
}
IPv6 network security group (NSG ) rules
{
"name": "default-allow-rdp",
"properties": {
"description": "Allow RDP",
"protocol": "Tcp",
"sourcePortRange": "33819-33829",
"destinationPortRange": "5000-6000",
"sourceAddressPrefix": "ace:cab:deca:deed::/64",
"destinationAddressPrefix": "cab:ace:deca:deed::/64",
"access": "Allow",
"priority": 1003,
"direction": "Inbound"
}
Conditional configuration
If you're using a network virtual appliance, add IPv6 routes in the Route Table. Otherwise, this configuration is
optional.
{
"type": "Microsoft.Network/routeTables",
"name": "v6route",
"apiVersion": "[variables('ApiVersion')]",
"location": "[resourceGroup().location]",
"properties": {
"routes": [
{
"name": "v6route",
"properties": {
"addressPrefix": "ace:cab:deca:deed::/64",
"nextHopType": "VirtualAppliance",
"nextHopIpAddress": "deca:cab:ace:f00d::1"
}
Optional configuration
IPv6 Internet access for the virtual network
{
"name": "LBFE-v6",
"properties": {
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses','lbpublicip-v6')]"
}
{
"apiVersion": "[variables('ApiVersion')]",
"type": "Microsoft.Network/publicIPAddresses",
"name": "lbpublicip-v6",
"location": "[resourceGroup().location]",
"properties": {
"publicIPAllocationMethod": "Dynamic",
"publicIPAddressVersion": "IPv6"
}
IPv6 Front end for Load Balancer
{
"name": "LBFE-v6",
"properties": {
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses','lbpublicip-v6')]"
}
"backendAddressPool": {
"id": "[concat(resourceId('Microsoft.Network/loadBalancers', 'loadBalancer'),
'/backendAddressPools/LBBAP-v6')]"
},
"protocol": "Tcp",
"frontendPort": 8080,
"backendPort": 8080
},
"name": "lbrule-v6"
{
"name": "ipconfig-v6",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"privateIPAddressVersion":"IPv6",
"subnet": {
"id": "[variables('v6-subnet-id')]"
},
"loadBalancerBackendAddressPools": [
{
"id": "
[concat(resourceId('Microsoft.Network/loadBalancers','loadBalancer'),'/backendAddressPools/LBBAP-v6')]"
}
Next steps
You can find details about pricing for public IP addresses, network bandwidth, or Load Balancer.
Deploy an IPv6 dual stack application in Azure -
PowerShell
11/11/2020 • 9 minutes to read • Edit Online
This article shows you how to deploy a dual stack (IPv4 + IPv6) application using Standard Load Balancer in Azure
that includes a dual stack virtual network and subnet, a Standard Load Balancer with dual (IPv4 + IPv6) front-end
configurations, VMs with NICs that have a dual IP configuration, network security group, and public IPs.
O P T IO N EXA M P L E/ L IN K
Select the Cloud Shell button on the menu bar at the upper
right in the Azure portal.
$PublicIP_v4 = New-AzPublicIpAddress `
-Name "dsPublicIP_v4" `
-ResourceGroupName $rg.ResourceGroupName `
-Location $rg.Location `
-AllocationMethod Static `
-IpAddressVersion IPv4 `
-Sku Standard
$PublicIP_v6 = New-AzPublicIpAddress `
-Name "dsPublicIP_v6" `
-ResourceGroupName $rg.ResourceGroupName `
-Location $rg.Location `
-AllocationMethod Static `
-IpAddressVersion IPv6 `
-Sku Standard
To access your virtual machines using a RDP connection, create a IPV4 public IP addresses for the virtual machines
with New-AzPublicIpAddress.
$RdpPublicIP_1 = New-AzPublicIpAddress `
-Name "RdpPublicIP_1" `
-ResourceGroupName $rg.ResourceGroupName `
-Location $rg.Location `
-AllocationMethod Static `
-Sku Standard `
-IpAddressVersion IPv4
$RdpPublicIP_2 = New-AzPublicIpAddress `
-Name "RdpPublicIP_2" `
-ResourceGroupName $rg.ResourceGroupName `
-Location $rg.Location `
-AllocationMethod Static `
-Sku Standard `
-IpAddressVersion IPv4
$frontendIPv6 = New-AzLoadBalancerFrontendIpConfig `
-Name "dsLbFrontEnd_v6" `
-PublicIpAddress $PublicIP_v6
$backendPoolv4 = New-AzLoadBalancerBackendAddressPoolConfig `
-Name "dsLbBackEndPool_v4"
$backendPoolv6 = New-AzLoadBalancerBackendAddressPoolConfig `
-Name "dsLbBackEndPool_v6"
$lbrule_v4 = New-AzLoadBalancerRuleConfig `
-Name "dsLBrule_v4" `
-FrontendIpConfiguration $frontendIPv4 `
-BackendAddressPool $backendPoolv4 `
-Protocol Tcp `
-FrontendPort 80 `
-BackendPort 80 `
-probe $probe
$lbrule_v6 = New-AzLoadBalancerRuleConfig `
-Name "dsLBrule_v6" `
-FrontendIpConfiguration $frontendIPv6 `
-BackendAddressPool $backendPoolv6 `
-Protocol Tcp `
-FrontendPort 80 `
-BackendPort 80 `
-probe $probe
$lb = New-AzLoadBalancer `
-ResourceGroupName $rg.ResourceGroupName `
-Location $rg.Location `
-Name "MyLoadBalancer" `
-Sku "Standard" `
-FrontendIpConfiguration $frontendIPv4,$frontendIPv6 `
-BackendAddressPool $backendPoolv4,$backendPoolv6 `
-LoadBalancingRule $lbrule_v4,$lbrule_v6 `
-probe $probe
$avset = New-AzAvailabilitySet `
-ResourceGroupName $rg.ResourceGroupName `
-Location $rg.Location `
-Name "dsAVset" `
-PlatformFaultDomainCount 2 `
-PlatformUpdateDomainCount 2 `
-Sku aligned
$rule1 = New-AzNetworkSecurityRuleConfig `
-Name 'myNetworkSecurityGroupRuleRDP' `
-Description 'Allow RDP' `
-Access Allow `
-Protocol Tcp `
-Direction Inbound `
-Priority 100 `
-SourceAddressPrefix * `
-SourcePortRange * `
-DestinationAddressPrefix * `
-DestinationPortRange 3389
$nsg = New-AzNetworkSecurityGroup `
-ResourceGroupName $rg.ResourceGroupName `
-Location $rg.Location `
-Name "dsNSG1" `
-SecurityRules $rule1,$rule2
Create NICs
Create virtual NICs with New-AzNetworkInterface. The following example creates two virtual NICs both with IPv4
and IPv6 configurations. (One virtual NIC for each VM you create for your app in the following steps).
$Ip4Config=New-AzNetworkInterfaceIpConfig `
-Name dsIp4Config `
-Subnet $vnet.subnets[0] `
-PrivateIpAddressVersion IPv4 `
-LoadBalancerBackendAddressPool $backendPoolv4 `
-PublicIpAddress $RdpPublicIP_1
$Ip6Config=New-AzNetworkInterfaceIpConfig `
-Name dsIp6Config `
-Subnet $vnet.subnets[0] `
-PrivateIpAddressVersion IPv6 `
-LoadBalancerBackendAddressPool $backendPoolv6
$NIC_1 = New-AzNetworkInterface `
-Name "dsNIC1" `
-ResourceGroupName $rg.ResourceGroupName `
-Location $rg.Location `
-NetworkSecurityGroupId $nsg.Id `
-IpConfiguration $Ip4Config,$Ip6Config
$Ip4Config=New-AzNetworkInterfaceIpConfig `
-Name dsIp4Config `
-Subnet $vnet.subnets[0] `
-PrivateIpAddressVersion IPv4 `
-LoadBalancerBackendAddressPool $backendPoolv4 `
-PublicIpAddress $RdpPublicIP_2
$NIC_2 = New-AzNetworkInterface `
-Name "dsNIC2" `
-ResourceGroupName $rg.ResourceGroupName `
-Location $rg.Location `
-NetworkSecurityGroupId $nsg.Id `
-IpConfiguration $Ip4Config,$Ip6Config
$cred = get-credential -Message "DUAL STACK VNET SAMPLE: Please enter the Administrator credential to log
into the VMs."
Now you can create the VMs with New-AzVM. The following example creates two VMs and the required virtual
network components if they do not already exist.
$vmsize = "Standard_A2"
$ImagePublisher = "MicrosoftWindowsServer"
$imageOffer = "WindowsServer"
$imageSKU = "2019-Datacenter"
$vmName= "dsVM1"
$VMconfig1 = New-AzVMConfig -VMName $vmName -VMSize $vmsize -AvailabilitySetId $avset.Id 3> $null | Set-
AzVMOperatingSystem -Windows -ComputerName $vmName -Credential $cred -ProvisionVMAgent 3> $null | Set-
AzVMSourceImage -PublisherName $ImagePublisher -Offer $imageOffer -Skus $imageSKU -Version "latest" 3> $null |
Set-AzVMOSDisk -Name "$vmName.vhd" -CreateOption fromImage 3> $null | Add-AzVMNetworkInterface -Id $NIC_1.Id
3> $null
$VM1 = New-AzVM -ResourceGroupName $rg.ResourceGroupName -Location $rg.Location -VM $VMconfig1
$vmName= "dsVM2"
$VMconfig2 = New-AzVMConfig -VMName $vmName -VMSize $vmsize -AvailabilitySetId $avset.Id 3> $null | Set-
AzVMOperatingSystem -Windows -ComputerName $vmName -Credential $cred -ProvisionVMAgent 3> $null | Set-
AzVMSourceImage -PublisherName $ImagePublisher -Offer $imageOffer -Skus $imageSKU -Version "latest" 3> $null |
Set-AzVMOSDisk -Name "$vmName.vhd" -CreateOption fromImage 3> $null | Add-AzVMNetworkInterface -Id $NIC_2.Id
3> $null
$VM2 = New-AzVM -ResourceGroupName $rg.ResourceGroupName -Location $rg.Location -VM $VMconfig2
$rgName= "dsRG1"
$NICsInRG= get-AzNetworkInterface -resourceGroupName $rgName
write-host `nSummary of IPs in this Deployment:
write-host ******************************************
foreach ($NIC in $NICsInRG) {
$VMid= $NIC.virtualmachine.id
$VMnamebits= $VMid.split("/")
$VMname= $VMnamebits[($VMnamebits.count-1)]
write-host `nPrivate IP addresses for $VMname
$IPconfigsInNIC= $NIC.IPconfigurations
foreach ($IPconfig in $IPconfigsInNIC) {
$IPaddress= $IPconfig.privateipaddress
write-host " "$IPaddress
IF ($IPconfig.PublicIpAddress.ID) {
$IDbits= ($IPconfig.PublicIpAddress.ID).split("/")
$PipName= $IDbits[($IDbits.count-1)]
$PipObject= get-azPublicIpAddress -name $PipName -resourceGroup $rgName
write-host " "RDP address: $PipObject.IpAddress
}
}
}
The following figure shows a sample output that lists the private IPv4 and IPv6 addresses of the two VMs, and the
frontend IPv4 and IPv6 IP addresses of the Load Balancer.
View IPv6 dual stack virtual network in Azure portal
You can view the IPv6 dual stack virtual network in Azure portal as follows:
1. In the portal's search bar, enter dsVnet.
2. When dsVnet appears in the search results, select it. This launches the Over view page of the dual stack virtual
network named dsVnet. The dual stack virtual network shows the two NICs with both IPv4 and IPv6
configurations located in the dual stack subnet named dsSubnet.
Clean up resources
When no longer needed, you can use the Remove-AzResourceGroup command to remove the resource group, VM,
and all related resources.
Next steps
In this article, you created a Standard Load Balancer with a dual frontend IP configuration (IPv4 and IPv6). You also
created a two virtual machines that included NICs with dual IP configurations (IPV4 + IPv6) that were added to the
back-end pool of the load balancer. To learn more about IPv6 support in Azure virtual networks, see What is IPv6
for Azure Virtual Network?
Deploy an IPv6 dual stack application in Azure virtual
network - CLI
11/2/2020 • 8 minutes to read • Edit Online
This article shows you how to deploy a dual stack (IPv4 + IPv6) application using Standard Load Balancer in Azure
that includes a dual stack virtual network with a dual stack subnet, a Standard Load Balancer with dual (IPv4 +
IPv6) front-end configurations, VMs with NICs that have a dual IP configuration, dual network security group rules,
and dual public IPs.
If you don't have an Azure subscription, create a free account now.
O P T IO N EXA M P L E/ L IN K
Select the Cloud Shell button on the menu bar at the upper
right in the Azure portal.
az network lb create \
--name dsLB \
--resource-group DsResourceGroup01 \
--sku Standard \
--location eastus \
--frontend-ip-name dsLbFrontEnd_v4 \
--public-ip-address dsPublicIP_v4 \
--backend-pool-name dsLbBackEndPool_v4
az network lb probe create -g DsResourceGroup01 --lb-name dsLB -n dsProbe --protocol tcp --port 3389
az vm availability-set create \
--name dsAVset \
--resource-group DsResourceGroup01 \
--location eastus \
--platform-fault-domain-count 2 \
--platform-update-domain-count 2
Create a network security group rule for inbound and outbound connections
Create a network security group rule to allow RDP connections through port 3389, internet connection through
port 80, and for outbound connections with az network nsg rule create.
# Create inbound rule for port 3389
az network nsg rule create \
--name allowRdpIn \
--nsg-name dsNSG1 \
--resource-group DsResourceGroup01 \
--priority 100 \
--description "Allow Remote Desktop In" \
--access Allow \
--protocol "*" \
--direction Inbound \
--source-address-prefixes "*" \
--source-port-ranges "*" \
--destination-address-prefixes "*" \
--destination-port-ranges 3389
Create NICs
Create virtual NICs for each VM with az network nic create. The following example creates a virtual NIC for each
VM. Each NIC has two IP configurations (1 IPv4 config, 1 IPv6 config). You create the IPV6 configuration with az
network nic ip-config create.
# Create NICs
az network nic create \
--name dsNIC0 \
--resource-group DsResourceGroup01 \
--network-security-group dsNSG1 \
--vnet-name dsVNET \
--subnet dsSubNet \
--private-ip-address-version IPv4 \
--lb-address-pools dsLbBackEndPool_v4 \
--lb-name dsLB \
--public-ip-address dsVM0_remote_access
az vm create \
--name dsVM0 \
--resource-group DsResourceGroup01 \
--nics dsNIC0 \
--size Standard_A2 \
--availability-set dsAVset \
--image MicrosoftWindowsServer:WindowsServer:2019-Datacenter:latest
Clean up resources
When no longer needed, you can use the az group delete command to remove the resource group, VM, and all
related resources.
Next steps
In this article, you created a Standard Load Balancer with a dual frontend IP configuration (IPv4 and IPv6). You also
created a two virtual machines that included NICs with dual IP configurations (IPV4 + IPv6) that were added to the
back-end pool of the load balancer. To learn more about IPv6 support in Azure virtual networks, see What is IPv6
for Azure Virtual Network?
Deploy an IPv6 dual stack application in Azure virtual
network - Template
11/2/2020 • 2 minutes to read • Edit Online
This article provides a list of IPv6 configuration tasks with the portion of the Azure Resource Manager VM
template that applies to. Use the template described in this article to deploy a dual stack (IPv4 + IPv6) application
using Standard Load Balancer in Azure that includes a dual stack virtual network with IPv4 and IPv6 subnets, a
Standard Load Balancer with dual (IPv4 + IPv6) front-end configurations, VMs with NICs that have a dual IP
configuration, network security group, and public IPs.
Required configurations
Search for the template sections in the template to see where they should occur.
IPv6 addressSpace for the virtual network
Template section to add:
"addressSpace": {
"addressPrefixes": [
"[variables('vnetv4AddressRange')]",
"[variables('vnetv6AddressRange')]"
{
"name": "V6Subnet",
"properties": {
"addressPrefix": "[variables('subnetv6AddressRange')]"
}
{
"name": "ipconfig-v6",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"privateIPAddressVersion":"IPv6",
"subnet": {
"id": "[variables('v6-subnet-id')]"
},
"loadBalancerBackendAddressPools": [
{
"id": "
[concat(resourceId('Microsoft.Network/loadBalancers','loadBalancer'),'/backendAddressPools/LBBAP-v6')]"
}
Conditional configuration
If you're using a network virtual appliance, add IPv6 routes in the Route Table. Otherwise, this configuration is
optional.
{
"type": "Microsoft.Network/routeTables",
"name": "v6route",
"apiVersion": "[variables('ApiVersion')]",
"location": "[resourceGroup().location]",
"properties": {
"routes": [
{
"name": "v6route",
"properties": {
"addressPrefix": "ace:cab:deca:deed::/64",
"nextHopType": "VirtualAppliance",
"nextHopIpAddress": "deca:cab:ace:f00d::1"
}
Optional configuration
IPv6 Internet access for the virtual network
{
"name": "LBFE-v6",
"properties": {
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses','lbpublicip-v6')]"
}
{
"apiVersion": "[variables('ApiVersion')]",
"type": "Microsoft.Network/publicIPAddresses",
"name": "lbpublicip-v6",
"location": "[resourceGroup().location]",
"sku": {
"name": "Standard"
},
"properties": {
"publicIPAllocationMethod": "Static",
"publicIPAddressVersion": "IPv6"
}
IPv6 Front end for Load Balancer
{
"name": "LBFE-v6",
"properties": {
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses','lbpublicip-v6')]"
}
"backendAddressPool": {
"id": "[concat(resourceId('Microsoft.Network/loadBalancers', 'loadBalancer'),
'/backendAddressPools/LBBAP-v6')]"
},
"protocol": "Tcp",
"frontendPort": 8080,
"backendPort": 8080
},
"name": "lbrule-v6"
{
"name": "ipconfig-v6",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"privateIPAddressVersion":"IPv6",
"subnet": {
"id": "[variables('v6-subnet-id')]"
},
"loadBalancerBackendAddressPools": [
{
"id": "
[concat(resourceId('Microsoft.Network/loadBalancers','loadBalancer'),'/backendAddressPools/LBBAP-v6')]"
}
Next steps
You can find details about pricing for public IP addresses, network bandwidth, or Load Balancer.
Deploy an IPv6 dual stack application using Standard
Internal Load Balancer in Azure - PowerShell
(Preview)
11/2/2020 • 9 minutes to read • Edit Online
This article shows you how to deploy a dual stack (IPv4 + IPv6) application in Azure that includes a dual stack
virtual network and subnet, a Standard Internal Load Balancer with dual (IPv4 + IPv6) front-end configurations,
VMs with NICs that have a dual IP configuration, network security group, and public IPs.
The procedure to create an IPv6-capable Internal Load Balancer is nearly identical to the process for creating an
Internet-facing IPv6 Load Balancer described here. The only differences for creating an internal load balancer are in
the front-end configuration as illustrated in the PowerShell example below:
$frontendIPv6 = New-AzLoadBalancerFrontendIpConfig `
-Name "dsLbFrontEnd_v6" `
-PrivateIpAddress "ace:cab:deca:deed::100" `
-PrivateIpAddressVersion "IPv6" `
-Subnet $DsSubnet
The changes that make the above an internal load balancer front-end configuration are:
The PrivateIpAddressVersion is specified as “IPv6”
The -PublicIpAddress argument has been either omitted or replaced with -PrivateIpAddress . Note that the
private address must be in the range of the Subnet IP space in which the internal load balancer will be deployed.
If a static -PrivateIpAddress is omitted, the next free IPv6 address will be selected from the subnet in which the
internal load Balancer is deployed.
The dual stack subnet in which the internal load balancer will be deployed is specified with either a -Subnet or
-SubnetId argument.
O P T IO N EXA M P L E/ L IN K
Select the Cloud Shell button on the menu bar at the upper
right in the Azure portal.
To run the code in this article in Azure Cloud Shell:
1. Start Cloud Shell.
2. Select the Copy button on a code block to copy the code.
3. Paste the code into the Cloud Shell session by selecting Ctrl +Shift +V on Windows and Linux or by
selecting Cmd +Shift +V on macOS.
4. Select Enter to run the code.
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.
Prerequisites
Before you deploy a dual stack application in Azure, you must configure your subscription for this preview feature
using the following Azure PowerShell:
Register as follows:
It takes up to 30 minutes for feature registration to complete. You can check your registration status by running the
following Azure PowerShell command: Check on the registration as follows:
$rg = New-AzResourceGroup `
-ResourceGroupName "dsStd_ILB_RG" `
-Location "east us"
$RdpPublicIP_2 = New-AzPublicIpAddress `
-Name "RdpPublicIP_2" `
-ResourceGroupName $rg.ResourceGroupName `
-Location $rg.Location `
-AllocationMethod Static `
-IpAddressVersion IPv4 `
-sku Standard
#Refresh the fully populated subnet for use in load balancer frontend configuration
$DsSubnet = get-AzVirtualNetworkSubnetconfig -name dsSubnet -VirtualNetwork $vnet
$frontendIPv4 = New-AzLoadBalancerFrontendIpConfig `
-Name "dsLbFrontEnd_v4" `
-PrivateIpAddress "10.0.0.100" `
-PrivateIpAddressVersion "IPv4" `
-Subnet $DsSubnet
$frontendIPv6 = New-AzLoadBalancerFrontendIpConfig `
-Name "dsLbFrontEnd_v6" `
-PrivateIpAddress "ace:cab:deca:deed::100" `
-PrivateIpAddressVersion "IPv6" `
-Subnet $DsSubnet
Configure back-end address pool
Create a back-end address pool with New-AzLoadBalancerBackendAddressPoolConfig. The VMs attach to this back-
end pool in the remaining steps. The following example creates back-end address pools named
dsLbBackEndPool_v4 and dsLbBackEndPool_v6 to include VMs with both IPV4 and IPv6 NIC configurations:
$lbrule_v4 = New-AzLoadBalancerRuleConfig `
-Name "dsLBrule_v4" `
-FrontendIpConfiguration $frontendIPv4 `
-BackendAddressPool $backendPoolv4 `
-Protocol Tcp `
-FrontendPort 80 `
-BackendPort 80
$lbrule_v6 = New-AzLoadBalancerRuleConfig `
-Name "dsLBrule_v6" `
-FrontendIpConfiguration $frontendIPv6 `
-BackendAddressPool $backendPoolv6 `
-Protocol Tcp `
-FrontendPort 80 `
-BackendPort 80
$lb = New-AzLoadBalancer `
-ResourceGroupName $rg.ResourceGroupName `
-Location $rg.Location `
-Name "MyInternalLoadBalancer" `
-Sku "Standard" `
-FrontendIpConfiguration $frontendIPv4,$frontendIPv6 `
-BackendAddressPool $backendPoolv4,$backendPoolv6 `
-LoadBalancingRule $lbrule_v4,$lbrule_v6
$avset = New-AzAvailabilitySet `
-ResourceGroupName $rg.ResourceGroupName `
-Location $rg.Location `
-Name "dsAVset" `
-PlatformFaultDomainCount 2 `
-PlatformUpdateDomainCount 2 `
-Sku aligned
$rule1 = New-AzNetworkSecurityRuleConfig `
-Name 'myNetworkSecurityGroupRuleRDP' `
-Description 'Allow RDP' `
-Access Allow `
-Protocol Tcp `
-Direction Inbound `
-Priority 100 `
-SourceAddressPrefix * `
-SourcePortRange * `
-DestinationAddressPrefix * `
-DestinationPortRange 3389
$rule2 = New-AzNetworkSecurityRuleConfig `
-Name 'myNetworkSecurityGroupRuleHTTP' `
-Description 'Allow HTTP' `
-Access Allow `
-Protocol Tcp `
-Direction Inbound `
-Priority 200 `
-SourceAddressPrefix * `
-SourcePortRange 80 `
-DestinationAddressPrefix * `
-DestinationPortRange 80
$nsg = New-AzNetworkSecurityGroup `
-ResourceGroupName $rg.ResourceGroupName `
-Location $rg.Location `
-Name "dsNSG1" `
-SecurityRules $rule1,$rule2
Create NICs
Create virtual NICs with New-AzNetworkInterface. The following example creates two virtual NICs both with IPv4
and IPv6 configurations. (One virtual NIC for each VM you create for your app in the following steps).
# Create NIC 1
$NIC_1 = New-AzNetworkInterface `
-Name "dsNIC1" `
-ResourceGroupName $rg.ResourceGroupName `
-Location $rg.Location `
-NetworkSecurityGroupId $nsg.Id `
-IpConfiguration $Ip4Config,$Ip6Config
$cred = get-credential -Message "DUAL STACK VNET SAMPLE: Please enter the Administrator credential to log
into the VM's"
Now you can create the VMs with New-AzVM. The following example creates two VMs and the required virtual
network components if they do not already exist.
$vmsize = "Standard_A2"
$ImagePublisher = "MicrosoftWindowsServer"
$imageOffer = "WindowsServer"
$imageSKU = "2019-Datacenter"
$vmName= "dsVM1"
$VMconfig1 = New-AzVMConfig -VMName $vmName -VMSize $vmsize -AvailabilitySetId $avset.Id 3> $null | Set-
AzVMOperatingSystem -Windows -ComputerName $vmName -Credential $cred -ProvisionVMAgent 3> $null | Set-
AzVMSourceImage -PublisherName $ImagePublisher -Offer $imageOffer -Skus $imageSKU -Version "latest" 3> $null |
Set-AzVMOSDisk -Name "$vmName.vhd" -CreateOption fromImage 3> $null | Add-AzVMNetworkInterface -Id $NIC_1.Id
3> $null
$VM1 = New-AzVM -ResourceGroupName $rg.ResourceGroupName -Location $rg.Location -VM $VMconfig1
$vmName= "dsVM2"
$VMconfig2 = New-AzVMConfig -VMName $vmName -VMSize $vmsize -AvailabilitySetId $avset.Id 3> $null | Set-
AzVMOperatingSystem -Windows -ComputerName $vmName -Credential $cred -ProvisionVMAgent 3> $null | Set-
AzVMSourceImage -PublisherName $ImagePublisher -Offer $imageOffer -Skus $imageSKU -Version "latest" 3> $null |
Set-AzVMOSDisk -Name "$vmName.vhd" -CreateOption fromImage 3> $null | Add-AzVMNetworkInterface -Id $NIC_2.Id
3> $null
$VM2 = New-AzVM -ResourceGroupName $rg.ResourceGroupName -Location $rg.Location -VM $VMconfig2
NOTE
The IPv6 for Azure virtual network is available in the Azure portal in read-only for this preview release.
Clean up resources
When no longer needed, you can use the Remove-AzResourceGroup command to remove the resource group, VM,
and all related resources.
Next steps
In this article, you created a Standard Load Balancer with a dual frontend IP configuration (IPv4 and IPv6). You also
created a two virtual machines that included NICs with dual IP configurations (IPV4 + IPv6) that were added to the
back-end pool of the load balancer. To learn more about IPv6 support in Azure virtual networks, see What is IPv6
for Azure Virtual Network?
Deploy virtual machine scale sets with IPv6 in Azure
11/2/2020 • 2 minutes to read • Edit Online
This article shows you how to deploy a dual stack (IPv4 + IPv6) Virtual Machine Scale Set with a dual stack external
load balancer in an Azure virtual network. The process to create an IPv6-capable virtual machine scale set is nearly
identical to the process for creating individual VMs described here. You'll start with the steps that are similar to
ones described for individual VMs:
1. Create IPv4 and IPv6 Public IPs.
2. Create a dual stack load balancer.
3. Create network security group (NSG) rules.
The only step that is different from individual VMs is creating the network interface (NIC) configuration that uses
the virtual machine scale set resource: networkProfile/networkInterfaceConfigurations. The JSON structure is
similar to that of the Microsoft.Network/networkInterfaces object used for individual VMs with the addition of
setting the NIC and the IPv4 IpConfiguration as the primary interface using the "primar y": true attribute as seen
in the following example:
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "[variables('nicName')]",
"properties": {
"primary": true,
"networkSecurityGroup": {
"id": "[resourceId('Microsoft.Network/networkSecurityGroups','VmssNsg')]"
},
"ipConfigurations": [
{
"name": "[variables('ipConfigName')]",
"properties": {
"primary": true,
"subnet": {
"id": "[resourceId('Microsoft.Network/virtualNetworks/subnets',
'MyvirtualNetwork','Mysubnet')]"
},
"privateIPAddressVersion":"IPv4",
"publicipaddressconfiguration": {
"name": "pub1",
"properties": {
"idleTimeoutInMinutes": 15
}
},
"loadBalancerBackendAddressPools": [
{
"id": "[resourceId('Microsoft.Network/loadBalancers/backendAddressPools',
'loadBalancer', 'bePool'))]"
}
],
"loadBalancerInboundNatPools": [
{
"id": "[resourceId('Microsoft.Network/loadBalancers/inboundNatPools',
'loadBalancer', 'natPool')]"
}
]
}
},
{
"name": "[variables('ipConfigNameV6')]",
"properties": {
"subnet": {
"id": "
[resourceId('Microsoft.Network/virtualNetworks/subnets','MyvirtualNetwork','Mysubnet')]"
},
"privateIPAddressVersion":"IPv6",
"loadBalancerBackendAddressPools": [
{
"id": "[resourceId('Microsoft.Network/loadBalancers/backendAddressPools',
'loadBalancer','bePoolv6')]"
}
],
}
}
]
}
}
]
}
Next steps
To learn more about IPv6 support in Azure virtual networks, see What is IPv6 for Azure Virtual Network?.
Reserve public IPv6 address prefix
11/2/2020 • 2 minutes to read • Edit Online
IPv6 for Azure Virtual Network (VNet) enables you to host applications in Azure with IPv6 and IPv4 connectivity
both within a virtual network and to and from the Internet. In addition to reserving individual IPv6 addresses, you
can reserve contiguous ranges of Azure IPv6 addresses (known as IP Prefix) for your use. This articles describes
how to create IPv6 public IP addresses and address ranges using Azure PowerShell and CLI.
$myOwnIPv6Address = New-AzPublicIpAddress `
-name PIPv6_WestUS `
-ResourceGroup MyRG `
-Location "West US" `
-Sku Standard `
-allocationMethod static `
-IpAddressVersion IPv6
$myOwnIPv6Prefix = New-AzPublicIpPrefix `
-name IPv6PrefixWestUS `
-ResourceGroupName MyRG `
-Location "West US" `
-Sku Standard `
-IpAddressVersion IPv6 `
-PrefixLength 125
$MyIPv6PublicIPFromMyReservedPrefix = New-AzPublicIpAddress \
-name PIPv6_fromPrefix `
-ResourceGroup DsStdLb04 `
-Location "West Central US" `
-Sku Standard `
-allocationMethod static `
-IpAddressVersion IPv6 `
-PublicIpPrefix $myOwnIPv6Prefix
Next steps
Learn more about IPv6 address prefix.
Learn more about IPv6 addresses.
Quickstart: Create a public IP address using the Azure
portal
11/2/2020 • 2 minutes to read • Edit Online
This article shows you how to create a public IP address resource using the Azure portal. For more information on
which resources this can be associated to, the difference between Basic and Standard SKU, and other related
information, please see Public IP addresses. For this example, we will focus on IPv4 addresses only; for more
information on IPv6 addresses, see IPv6 for Azure VNet.
Standard SKU - Using zones
Standard SKU - No zones
Basic SKU
Use the following steps to create a standard zone-redundant public IP address named myStandardZRPublicIP .
1. Sign in to the Azure portal.
2. Select Create a resource .
3. In the search box, type Public IP address.
4. In the search results, select Public IP address . Next, in the Public IP address page, select Create .
5. On the Create public IP address page, enter or select the following information:
SET T IN G VA L UE
Note that these are only valid selections in regions with Availability Zones. (You can also select a specific zone in
these regions, though it will not be resilient to zonal failure.)
Additional information
For more details on the individual fields listed above, please see Manage public IP addresses.
Next steps
Associate a public IP address to a Virtual Machine
Learn more about public IP addresses in Azure.
Learn more about all public IP address settings.
Quickstart: Create a public IP address using Azure
PowerShell
11/2/2020 • 4 minutes to read • Edit Online
This article shows you how to create a public IP address resource using Azure PowerShell. For more information on
which resources this can be associated to, the difference between Basic and Standard SKU, and other related
information, please see Public IP addresses. For this example, we will focus on IPv4 addresses only; for more
information on IPv6 addresses, see IPv6 for Azure VNet.
Prerequisites
Azure PowerShell installed locally or Azure Cloud Shell
NOTE
This article has been updated to use the new Azure PowerShell Az module. You can still use the AzureRM module, which will
continue to receive bug fixes until at least December 2020. To learn more about the new Az module and AzureRM
compatibility, see Introducing the new Azure PowerShell Az module. For Az module installation instructions, see Install Azure
PowerShell.
O P T IO N EXA M P L E/ L IN K
Select the Cloud Shell button on the menu bar at the upper
right in the Azure portal.
NOTE
The following command works for API version 2020-08-01 or later. For more information about the API version currently
being used, please refer to Resource Providers and Types.
New-AzPublicIpAddress -ResourceGroupName $rg -Name $pubIP -Location $loc -AllocationMethod $alloc -SKU $sku -
zone $zone
IMPORTANT
For versions of the API older than 2020-08-01, run the command above without specifying a zone parameter to create a
zone-redundant IP address.
New-AzPublicIpAddress -ResourceGroupName $rg -Name $pubIP -Location $loc -AllocationMethod $alloc -SKU $sku -
zone $zone
Note that the above options for zones are only valid selections in regions with Availability Zones.
Additional information
For more details on the individual variables listed above, please see Manage public IP addresses.
Next steps
Associate a public IP address to a Virtual Machine
Learn more about public IP addresses in Azure.
Learn more about all public IP address settings.
Quickstart: Create a public IP address using Azure CLI
11/2/2020 • 3 minutes to read • Edit Online
This article shows you how to create a public IP address resource using Azure CLI. For more information on which
resources this can be associated to, the difference between Basic and Standard SKU, and other related information,
please see Public IP addresses. For this example, we will focus on IPv4 addresses only; for more information on IPv6
addresses, see IPv6 for Azure VNet.
Prerequisites
Azure CLI installed locally or Azure Cloud Shell
O P T IO N EXA M P L E/ L IN K
Select the Cloud Shell button on the menu bar at the upper
right in the Azure portal.
NOTE
The following command works for API version 2020-08-01 or later. For more information about the API version currently
being used, please refer to Resource Providers and Types.
Use az network public-ip create to create a standard zone-redundant public IP address named
myStandardZRPublicIP in myResourceGroup .
IMPORTANT
For versions of the API older than 2020-08-01, run the command above without specifying a zone parameter to create a
zone-redundant IP address.
Note that the above options for zones are only valid selections in regions with Availability Zones.
Additional information
For more details on the individual variables listed above, please see Manage public IP addresses.
Next steps
Associate a public IP address to a Virtual Machine.
Learn more about public IP addresses in Azure.
Learn more about all public IP address settings.
Manage public IP addresses
11/2/2020 • 11 minutes to read • Edit Online
Learn about a public IP address and how to create, change, and delete one. A public IP address is a resource with
its own configurable settings. Assigning a public IP address to an Azure resource that supports public IP
addresses enables:
Inbound communication from the Internet to the resource, such as Azure Virtual Machines (VM), Azure
Application Gateways, Azure Load Balancers, Azure VPN Gateways, and others. You can still communicate with
some resources, such as VMs, from the Internet, if a VM doesn't have a public IP address assigned to it, as long
as the VM is part of a load balancer back-end pool, and the load balancer is assigned a public IP address. To
determine whether a resource for a specific Azure service can be assigned a public IP address, or whether it
can be communicated with through the public IP address of a different Azure resource, see the documentation
for the service.
Outbound connectivity to the Internet using a predictable IP address. For example, a virtual machine can
communicate outbound to the Internet without a public IP address assigned to it, but its address is network
address translated by Azure to an unpredictable public address, by default. Assigning a public IP address to a
resource enables you to know which IP address is used for the outbound connection. Though predictable, the
address can change, depending on the assignment method chosen. For more information, see Create a public
IP address. To learn more about outbound connections from Azure resources, see Understand outbound
connections.
Complete the following tasks before completing steps in any section of this article:
If you don't already have an Azure account, sign up for a free trial account.
If using the portal, open https://portal.azure.com, and log in with your Azure account.
If using PowerShell commands to complete tasks in this article, either run the commands in the Azure Cloud
Shell, or by running PowerShell from your computer. The Azure Cloud Shell is a free interactive shell that you
can use to run the steps in this article. It has common Azure tools preinstalled and configured to use with your
account. This tutorial requires the Azure PowerShell module version 1.0.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.
If using Azure Command-line interface (CLI) commands to complete tasks in this article, either run the
commands in the Azure Cloud Shell, or by running the CLI from your computer. This tutorial requires the Azure
CLI version 2.0.31 or later. Run az --version to find the installed version. If you need to install or upgrade, see
Install Azure CLI. If you are running the Azure CLI locally, you also need to run az login to create a connection
with Azure.
The account you log into, or connect to Azure with, must be assigned to the network contributor role or to a
custom role that is assigned the appropriate actions listed in Permissions.
Public IP addresses have a nominal charge. To view the pricing, read the IP address pricing page.
NOTE
Though the portal provides the option to create two public IP address resources (one IPv4 and one IPv6), the PowerShell
and CLI commands create one resource with an address for one IP version or the other. If you want two public IP address
resources, one for each IP version, you must run the command twice, specifying different names and IP versions for the
public IP address resources.
For additional detail on the specific attributes of a Public IP address during creation, see the table below.
Name (Only visible if you select IP Yes, if you select IP Version of Both The name must be different than the
Version of Both ) name you enter for the first Name in
this list. If you choose to create both an
IPv4 and an IPv6 address, the portal
creates two separate public IP address
resources, one with each IP address
version assigned to it.
IP address assignment (Only visible if Yes, if you select IP Version of Both Same restrictions as IP Address
you select IP Version of Both ) Assignment above
WARNING
To change the assignment for a Public IP address from static to dynamic, you must first dissociate the address from any
applicable IP configurations (see Delete section). Also note, when you change the assignment method from static to
dynamic, you lose the IP address that was assigned to the public IP address. While the Azure public DNS servers maintain a
mapping between static or dynamic addresses and any DNS name label (if you defined one), a dynamic IP address can
change when the virtual machine is started after being in the stopped (deallocated) state. To prevent the address from
changing, assign a static IP address.
Delete : Deletion of Public IPs requires that the Public IP object not be associated to any IP configuration or
Virtual Machine NIC. See the table below for more details.
RESO URC E A Z URE P O RTA L A Z URE P O W ERSH EL L A Z URE C L I
Permissions
To perform tasks on public IP addresses, your account must be assigned to the network contributor role or to a
custom role that is assigned the appropriate actions listed in the following table:
A C T IO N NAME
Next steps
Create a public IP address using PowerShell or Azure CLI sample scripts, or using Azure Resource Manager
templates
Create and assign Azure Policy definitions for public IP addresses
Create, change, or delete a public IP address prefix
11/2/2020 • 5 minutes to read • Edit Online
Learn about a public IP address prefix and how to create, change, and delete one. A public IP address prefix is a
contiguous range of addresses based on the number of public IP addresses you specify. The addresses are
assigned to your subscription. When you create a public IP address resource, you can assign a static public IP
address from the prefix and associate the address to virtual machines, load balancers, or other resources, to
enable internet connectivity. If you're not familiar with public IP address prefixes, see Public IP address prefix
overview
Complete the following tasks before completing steps in any section of this article:
If you don't already have an Azure account, sign up for a free trial account.
If using the portal, open https://portal.azure.com, and log in with your Azure account.
If using PowerShell commands to complete tasks in this article, either run the commands in the Azure Cloud
Shell, or by running PowerShell from your computer. The Azure Cloud Shell is a free interactive shell that you
can use to run the steps in this article. It has common Azure tools preinstalled and configured to use with
your account. This tutorial requires the Azure PowerShell module version 1.0.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.
If using Azure Command-line interface (CLI) commands to complete tasks in this article, either run the
commands in the Azure Cloud Shell, or by running the CLI from your computer. This tutorial requires the
Azure CLI version 2.0.41 or later. Run az --version to find the installed version. If you need to install or
upgrade, see Install Azure CLI 2.0. If you are running the Azure CLI locally, you also need to run az login to
create a connection with Azure.
The account you log into, or connect to Azure with, must be assigned to the network contributor role or to a
custom role that is assigned the appropriate actions listed in Permissions.
Public IP address prefixes have a charge. For details, see pricing.
Commands
TO O L C OMMAND
PowerShell New-AzPublicIpPrefix
Alternatively you may use the CLI and PS commands below with the --public-ip-prefix (CLI) and -PublicIpPrefix
(PS) parameters, to create a Public IP address resource.
TO O L C OMMAND
PowerShell New-AzPublicIpAddress
TO O L C OMMAND
Permissions
To perform tasks on public IP address prefixes, your account must be assigned to the network contributor role or
to a custom role that is assigned the appropriate actions listed in the following table:
A C T IO N NAME
Next steps
Learn about scenarios and benefits of using a public IP prefix
Upgrade public IP addresses
11/11/2020 • 5 minutes to read • Edit Online
Azure public IP addresses are created with a SKU--either Basic or Standard--which determines aspects of their
functionality (including allocation method, usage across availability zones, and which resources they can be
associated with).
The following scenarios are reviewed in this article:
How to upgrade a Basic SKU public IP to a Standard SKU public IP (using Portal, PowerShell, or CLI)
How to migrate a Classic Azure Reserved IP to an Azure Resource Manager Basic SKU public IP
In order to upgrade a public IP, it must not be associated with any resource (see this page for more information
about how to disassociate public IPs).
IMPORTANT
Public IPs upgraded from Basic to Standard SKU continue to have no availability zones. This means they cannot be associated
with an Azure resource that is either zone-redundant or tied to a pre-specified zone in regions where this is offered.
## This section is only needed if the Basic IP is not already set to Static ##
$pubIP.PublicIpAllocationMethod = 'Static'
Set-AzPublicIpAddress -PublicIpAddress $pubIP
## This section is only needed if the Reserved IP is not already disassociated from any Cloud Services ##
$serviceName = 'myService'
Remove-AzureReservedIPAssociation -ReservedIPName $name -ServiceName $service
The previous command displays any warnings and errors that block migration. If validation is successful, you can
proceed with the following steps to Prepare and Commit the migration:
A new resource group in Azure Resource Manager is created using the name of the migrated Reserved IP (in the
example above, it would be resource group myReser vedIP-Migrated ).
Limitations
This capability is currently only available in the following regions:
West Central US
North Central US
West US
West US 2
Norway East
South Africa North
East US
North Europe
Korea Central
Indian Central
East US 2
Switzerland North
India West
Germany North
Canada Central
France South
India West
In order to upgrade a Basic Public IP, it cannot be associated with any Azure resource. Please review this
page for more information on how to disassociate public IPs. Similarly, in order to migrate a Reserved IP, it
cannot be associated with any Cloud Service. Please review this page for more information on how to
disassociate reserved IPs.
Public IPs upgraded from Basic to Standard SKU will continue to have no availability zones and therefore
cannot be associated with an Azure resource that is either zone-redundant or zonal. Note this only applies to
regions that offer availability zones.
Next Steps
Learn more about public IP addresses in Azure, including the difference between the SKU types, as well as public
IP address settings.
Learn how to Upgrade Azure Public Load Balancers from Basic to Standard.
Understand Classic Azure Reserved IPs and Migration of Classic resources to Azure Resource Manager.
Add, change, or remove IP addresses for an Azure
network interface
11/2/2020 • 15 minutes to read • Edit Online
Learn how to add, change, and remove public and private IP addresses for a network interface. Private IP
addresses assigned to a network interface enable a virtual machine to communicate with other resources in an
Azure virtual network and connected networks. A private IP address also enables outbound communication to
the Internet using an unpredictable IP address. A Public IP address assigned to a network interface enables
inbound communication to a virtual machine from the Internet. The address also enables outbound
communication from the virtual machine to the Internet using a predictable IP address. For details, see
Understanding outbound connections in Azure.
If you need to create, change, or delete a network interface, read the Manage a network interface article. If you
need to add network interfaces to or remove network interfaces from a virtual machine, read the Add or remove
network interfaces article.
Complete the following tasks before completing steps in any section of this article:
If you don't already have an Azure account, sign up for a free trial account.
If using the portal, open https://portal.azure.com, and log in with your Azure account.
If using PowerShell commands to complete tasks in this article, either run the commands in the Azure Cloud
Shell, or by running PowerShell from your computer. The Azure Cloud Shell is a free interactive shell that you
can use to run the steps in this article. It has common Azure tools preinstalled and configured to use with
your account. This tutorial requires the Azure PowerShell module version 1.0.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.
If using Azure Command-line interface (CLI) commands to complete tasks in this article, either run the
commands in the Azure Cloud Shell, or by running the CLI from your computer. This tutorial requires the
Azure CLI version 2.0.31 or later. Run az --version to find the installed version. If you need to install or
upgrade, see Install Azure CLI. If you are running the Azure CLI locally, you also need to run az login to
create a connection with Azure.
The account you log into, or connect to Azure with, must be assigned to the network contributor role or to a
custom role that is assigned the appropriate actions listed in Network interface permissions.
Add IP addresses
You can add as many private and public IPv4 addresses as necessary to a network interface, within the limits
listed in the Azure limits article. You can add a private IPv6 address to one secondary IP configuration (as long as
there are no existing secondary IP configurations) for an existing network interface. Each network interface may
have at most one IPv6 private address. You can optionally add a public IPv6 address to an IPv6 network interface
configuration. See IPv6 for details about using IPv6 addresses.
1. In the box that contains the text Search resources at the top of the Azure portal, type network interfaces.
When network interfaces appear in the search results, select it.
2. Select the network interface you want to add an IPv4 address for from the list.
3. Under SETTINGS , select IP configurations .
4. Under IP configurations , select + Add .
5. Specify the following, then select OK :
6. Manually add secondary private IP addresses to the virtual machine operating system by completing the
instructions in the Assign multiple IP addresses to virtual machine operating systems article. See private
IP addresses for special considerations before manually adding IP addresses to a virtual machine
operating system. Do not add any public IP addresses to the virtual machine operating system.
Commands
TO O L C OMMAND
PowerShell Add-AzNetworkInterfaceIpConfig
Change IP address settings
You may need to change the assignment method of an IPv4 address, change the static IPv4 address, or change
the public IP address assigned to a network interface. If you're changing the private IPv4 address of a secondary
IP configuration associated with a secondary network interface in a virtual machine (learn more about primary
and secondary network interfaces), place the virtual machine into the stopped (deallocated) state before
completing the following steps:
1. In the box that contains the text Search resources at the top of the Azure portal, type network interfaces.
When network interfaces appear in the search results, select it.
2. Select the network interface that you want to view or change IP address settings for from the list.
3. Under SETTINGS , select IP configurations .
4. Select the IP configuration you want to modify from the list.
5. Change the settings, as desired, using the information about the settings in step 5 of Add an IP configuration.
6. Select Save .
NOTE
If the primary network interface has multiple IP configurations and you change the private IP address of the primary IP
configuration, you must manually reassign the primary and secondary IP addresses to the network interface within
Windows (not required for Linux). To manually assign IP addresses to a network interface within an operating system, see
Assign multiple IP addresses to virtual machines. For special considerations before manually adding IP addresses to a
virtual machine operating system, see private IP addresses. Do not add any public IP addresses to the virtual machine
operating system.
Commands
TO O L C OMMAND
PowerShell Set-AzNetworkInterfaceIpConfig
Remove IP addresses
You can remove private and public IP addresses from a network interface, but a network interface must always
have at least one private IPv4 address assigned to it.
1. In the box that contains the text Search resources at the top of the Azure portal, type network interfaces.
When network interfaces appear in the search results, select it.
2. Select the network interface that you want to remove IP addresses from the list.
3. Under SETTINGS , select IP configurations .
4. Right-select a secondary IP configuration (you cannot delete the primary configuration) that you want to
delete, select Delete , then select Yes , to confirm the deletion. If the configuration had a public IP address
resource associated to it, the resource is dissociated from the IP configuration, but the resource is not deleted.
Commands
TO O L C OMMAND
PowerShell Remove-AzNetworkInterfaceIpConfig
IP configurations
Private and (optionally) public IP addresses are assigned to one or more IP configurations assigned to a network
interface. There are two types of IP configurations:
Primary
Each network interface is assigned one primary IP configuration. A primary IP configuration:
Has a private IPv4 address assigned to it. You cannot assign a private IPv6 address to a primary IP
configuration.
May also have a public IPv4 address assigned to it. You cannot assign a public IPv6 address to a primary
(IPv4) IP configuration.
Secondary
In addition to a primary IP configuration, a network interface may have zero or more secondary IP
configurations assigned to it. A secondary IP configuration:
Must have a private IPv4 or IPv6 address assigned to it. If the address is IPv6, the network interface can only
have one secondary IP configuration. If the address is IPv4, the network interface may have multiple
secondary IP configurations assigned to it. To learn more about how many private and public IPv4 addresses
can be assigned to a network interface, see the Azure limits article.
May also have a public IPv4 or IPv6 address assigned to it. Assigning multiple IPv4 addresses to a network
interface is helpful in scenarios such as:
Hosting multiple websites or services with different IP addresses and TLS/SSL certificates on a single
server.
A virtual machine serving as a network virtual appliance, such as a firewall or load balancer.
The ability to add any of the private IPv4 addresses for any of the network interfaces to an Azure Load
Balancer back-end pool. In the past, only the primary IPv4 address for the primary network interface
could be added to a back-end pool. To learn more about how to load balance multiple IPv4
configurations, see the Load balancing multiple IP configurations article.
The ability to load balance one IPv6 address assigned to a network interface. To learn more about how
to load balance to a private IPv6 address, see the Load balance IPv6 addresses article.
Address types
You can assign the following types of IP addresses to an IP configuration:
Private
Private IPv4 or IPv6 addresses enable a virtual machine to communicate with other resources in a virtual
network or other connected networks.
By default, the Azure DHCP servers assign the private IPv4 address for the primary IP configuration of the Azure
network interface to the network interface within the virtual machine operating system. Unless necessary, you
should never manually set the IP address of a network interface within the virtual machine's operating system.
WARNING
If the IPv4 address set as the primary IP address of a network interface within a virtual machine's operating system is ever
different than the private IPv4 address assigned to the primary IP configuration of the primary network interface attached
to a virtual machine within Azure, you lose connectivity to the virtual machine.
There are scenarios where it's necessary to manually set the IP address of a network interface within the virtual
machine's operating system. For example, you must manually set the primary and secondary IP addresses of a
Windows operating system when adding multiple IP addresses to an Azure virtual machine. For a Linux virtual
machine, you may only need to manually set the secondary IP addresses. See Add IP addresses to a VM
operating system for details. If you ever need to change the address assigned to an IP configuration, it's
recommended that you:
1. Ensure that the virtual machine is receiving an address from the Azure DHCP servers. Once you have, change
the assignment of the IP address back to DHCP within the operating system and restart the virtual machine.
2. Stop (deallocate) the virtual machine.
3. Change the IP address for the IP configuration within Azure.
4. Start the virtual machine.
5. Manually configure the secondary IP addresses within the operating system (and also the primary IP address
within Windows) to match what you set within Azure.
By following the previous steps, the private IP address assigned to the network interface within Azure, and within
a virtual machine's operating system, remain the same. To keep track of which virtual machines within your
subscription that you've manually set IP addresses within an operating system for, consider adding an Azure tag
to the virtual machines. You might use "IP address assignment: Static", for example. This way, you can easily find
the virtual machines within your subscription that you've manually set the IP address for within the operating
system.
In addition to enabling a virtual machine to communicate with other resources within the same, or connected
virtual networks, a private IP address also enables a virtual machine to communicate outbound to the Internet.
Outbound connections are source network address translated by Azure to an unpredictable public IP address. To
learn more about Azure outbound Internet connectivity, read the Azure outbound Internet connectivity article.
You cannot communicate inbound to a virtual machine's private IP address from the Internet. If your outbound
connections require a predictable public IP address, associate a public IP address resource to a network interface.
Public
Public IP addresses assigned through a public IP address resource enable inbound connectivity to a virtual
machine from the Internet. Outbound connections to the Internet use a predictable IP address. See
Understanding outbound connections in Azure for details. You may assign a public IP address to an IP
configuration, but aren't required to. If you don't assign a public IP address to a virtual machine by associating a
public IP address resource, the virtual machine can still communicate outbound to the Internet. In this case, the
private IP address is source network address translated by Azure to an unpredictable public IP address. To learn
more about public IP address resources, see Public IP address resource.
There are limits to the number of private and public IP addresses that you can assign to a network interface. For
details, read the Azure limits article.
NOTE
Azure translates a virtual machine's private IP address to a public IP address. As a result, a virtual machine's operating
system is unaware of any public IP address assigned to it, so there is no need to ever manually assign a public IP address
within the operating system.
Assignment methods
Public and private IP addresses are assigned using one of the following assignment methods:
Dynamic
Dynamic private IPv4 and IPv6 (optionally) addresses are assigned by default.
Public only : Azure assigns the address from a range unique to each Azure region. To learn which ranges are
assigned to each region, see Microsoft Azure Datacenter IP Ranges. The address can change when a virtual
machine is stopped (deallocated), then started again. You cannot assign a public IPv6 address to an IP
configuration using either assignment method.
Private only : Azure reserves the first four addresses in each subnet address range, and doesn't assign the
addresses. Azure assigns the next available address to a resource from the subnet address range. For
example, if the subnet's address range is 10.0.0.0/16, and addresses 10.0.0.4-10.0.0.14 are already assigned
(.0-.3 are reserved), Azure assigns 10.0.0.15 to the resource. Dynamic is the default allocation method. Once
assigned, dynamic IP addresses are only released if a network interface is deleted, assigned to a different
subnet within the same virtual network, or the allocation method is changed to static, and a different IP
address is specified. By default, Azure assigns the previous dynamically assigned address as the static address
when you change the allocation method from dynamic to static.
Static
You can (optionally) assign a public or private static IPv4 or IPv6 address to an IP configuration. To learn more
about how Azure assigns static public IPv4 addresses, see Public IP addresses.
Public only : Azure assigns the address from a range unique to each Azure region. You can download the list
of ranges (prefixes) for the Azure Public, US government, China, and Germany clouds. The address doesn't
change until the public IP address resource it's assigned to is deleted, or the assignment method is changed
to dynamic. If the public IP address resource is associated to an IP configuration, it must be dissociated from
the IP configuration before changing its assignment method.
Private only : You select and assign an address from the subnet's address range. The address you assign can
be any address within the subnet address range that is not one of the first four addresses in the subnet's
address range and is not currently assigned to any other resource in the subnet. Static addresses are only
released if a network interface is deleted. If you change the allocation method to static, Azure dynamically
assigns the previously assigned dynamic IP address as the static address, even if the address isn't the next
available address in the subnet's address range. The address also changes if the network interface is assigned
to a different subnet within the same virtual network, but to assign the network interface to a different
subnet, you must first change the allocation method from static to dynamic. Once you've assigned the
network interface to a different subnet, you can change the allocation method back to static, and assign an IP
address from the new subnet's address range.
IP address versions
You can specify the following versions when assigning addresses:
IPv4
Each network interface must have one primary IP configuration with an assigned private IPv4 address. You can
add one or more secondary IP configurations that each have an IPv4 private and (optionally) an IPv4 public IP
address.
IPv6
You can assign zero or one private IPv6 address to one secondary IP configuration of a network interface. The
network interface cannot have any existing secondary IP configurations. Each network interface may have at
most one IPv6 private address. You can optionally add a public IPv6 address to an IPv6 network interface
configuration.
NOTE
Though you can create a network interface with an IPv6 address using the portal, you can't add an existing network
interface to a new, or existing virtual machine, using the portal. Use PowerShell or the Azure CLI to create a network
interface with a private IPv6 address, then attach the network interface when creating a virtual machine. You cannot
attach a network interface with a private IPv6 address assigned to it to an existing virtual machine. You cannot add a
private IPv6 address to an IP configuration for any network interface attached to a virtual machine using any tools (portal,
CLI, or PowerShell).
SKUs
A public IP address is created with the basic or standard SKU. For more information about SKU differences, see
Manage public IP addresses.
NOTE
When you assign a standard SKU public IP address to a virtual machine’s network interface, you must explicitly allow the
intended traffic with a network security group. Communication with the resource fails until you create and associate a
network security group and explicitly allow the desired traffic.
Next steps
To create a virtual machine with different IP configurations, read the following articles:
TA SK TO O L
Create a single NIC VM with a private IPv6 address (behind CLI, PowerShell, Azure Resource Manager template
an Azure Load Balancer)
Configure routing preference for a public IP address
using the Azure portal
11/2/2020 • 2 minutes to read • Edit Online
This article shows you how to configure routing preference via ISP network (Internet option) for a public IP
address. 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.
IMPORTANT
Routing preference is currently in public preview. This preview version is provided without a service level agreement, and it's
not recommended for production workloads. Certain features might not be supported or might have constrained capabilities.
For more information, see Supplemental Terms of Use for Microsoft Azure Previews.
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
Learn more about public IP with routing preference.
Configure routing preference for a VM.
Configure routing preference for a public IP address using the PowerShell.
Learn more about public IP addresses in Azure.
Learn more about all public IP address settings.
Configure routing preference for a public IP address
using Azure PowerShell
11/2/2020 • 3 minutes to read • Edit Online
This article shows you how to configure routing preference via ISP network (Internet option) for a public IP
address using Azure PowerShell. 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.
IMPORTANT
Routing preference is currently in public preview. This preview version is provided without a service level agreement, and it's
not recommended for production workloads. Certain features might not be supported or might have constrained
capabilities. For more information, see Supplemental Terms of Use for Microsoft Azure Previews.
O P T IO N EXA M P L E/ L IN K
Select the Cloud Shell button on the menu bar at the upper
right in the Azure portal.
$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 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).
Clean up resources
If no longer needed, you can use the Remove-AzResourceGroup command to remove the resource group, VM, and
all related resources.
Remove-AzResourceGroup -Name myResourceGroup
Next steps
Learn more about routing preference in public IP addresses.
Configure routing preference for a VM using the Azure PowerShell.
Configure routing preference for a public IP address
using Azure CLI
11/2/2020 • 3 minutes to read • Edit Online
This article shows you how to configure routing preference via ISP network (Internet option) for a public IP
address using 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.
IMPORTANT
Routing preference is currently in public preview. This preview version is provided without a service level agreement, and it's
not recommended for production workloads. Certain features might not be supported or might have constrained capabilities.
For more information, see Supplemental Terms of Use for Microsoft Azure Previews.
O P T IO N EXA M P L E/ L IN K
Select the Cloud Shell button on the menu bar at the upper
right in the Azure portal.
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 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
Learn more about routing preference in public IP addresses.
Configure routing preference for a VM using the Azure CLI.
Configure routing preference for a VM using the
Azure portal
11/2/2020 • 2 minutes to read • Edit Online
This article shows you how to configure routing preference for a virtual machine. Internet bound traffic from the
VM will be routed via the ISP network when you choose Internet as your routing preference option . The default
routing is via the Microsoft global network.
This article shows you how to create a virtual machine with a public IP that is set to route traffic via the public
internet using the Azure portal.
IMPORTANT
Routing preference is currently in public preview. This preview version is provided without a service level agreement, and it's
not recommended for production workloads. Certain features might not be supported or might have constrained
capabilities. For more information, see Supplemental Terms of Use for Microsoft Azure Previews.
Sign in to Azure
Sign in to the Azure portal.
SET T IN G VA L UE
Name myVM
7. Select a port, or no ports under Select public inbound por ts . Portal 3389 is selected, to enable remote
access to the Windows Server virtual machine from the internet. Opening port 3389 from the internet is not
recommended for production workloads.
Clean up resources
When no longer needed, delete the resource group and all of the resources it contains:
1. Enter myResourceGroup in the Search box at the top of the portal. When you see myResourceGroup in the
search results, select it.
2. Select Delete resource group .
3. Enter myResourceGroup for TYPE THE RESOURCE GROUP NAME: and select Delete .
Next steps
Learn more about public IP with routing preference.
Learn more about public IP addresses in Azure.
Learn more about all public IP address settings.
Configure routing preference for a VM using Azure
PowerShell
11/2/2020 • 3 minutes to read • Edit Online
This article shows you how to configure routing preference for a virtual machine. Internet bound traffic from the
VM will be routed via the ISP network when you choose Internet as your routing preference option . The default
routing is via the Microsoft global network.
This article shows you how to create a virtual machine with a public IP that is set to route traffic via the ISP
network using Azure PowerShell.
IMPORTANT
Routing preference is currently in public preview. This preview version is provided without a service level agreement, and it's
not recommended for production workloads. Certain features might not be supported or might have constrained
capabilities. For more information, see Supplemental Terms of Use for Microsoft Azure Previews.
2. Create a resource group with the New-AzResourceGroup command. The following example creates a
resource group in the East US Azure region:
$nsg = New-AzNetworkSecurityGroup `
-ResourceGroupName $rg.ResourceGroupName `
-Location $rg.Location `
-Name "myNSG"
$subnet = New-AzVirtualNetworkSubnetConfig `
-Name "mySubnet" `
-AddressPrefix "10.0.0.0/24"
Create a NIC
Create virtual NICs with [New-AzNetworkInterface](/powershell/module/az.network/new-aznetworkinterface. The
following example creates a virtual NIC.
# Create an IP Config
$ipconfig=New-AzNetworkInterfaceIpConfig `
-Name myIpConfig `
-Subnet $vnet.subnets[0] `
-PrivateIpAddressVersion IPv4 `
-PublicIpAddress $publicIp
# Create a NIC
$nic = New-AzNetworkInterface `
-Name "mynic" `
-ResourceGroupName $rg.ResourceGroupName `
-Location $rg.Location `
-NetworkSecurityGroupId $nsg.Id `
-IpConfiguration $ipconfig
$cred = get-credential -Message "Routing Preference SAMPLE: Please enter the Administrator credential to log
into the VM."
Now you can create the VM with New-AzVM. The following example creates two VMs and the required virtual
network components if they do not already exist.
$vmsize = "Standard_A2"
$ImagePublisher = "MicrosoftWindowsServer"
$imageOffer = "WindowsServer"
$imageSKU = "2019-Datacenter"
$vmName= "myVM"
$vmconfig = New-AzVMConfig -VMName $vmName -VMSize $vmsize | Set-AzVMOperatingSystem -Windows -ComputerName
$vmName -Credential $cred -ProvisionVMAgent -EnableAutoUpdate | Set-AzVMSourceImage -PublisherName
$ImagePublisher -Offer $imageOffer -Skus $imageSKU -Version "latest" | Set-AzVMOSDisk -Name "$vmName.vhd" -
CreateOption "FromImage" | Add-AzVMNetworkInterface -Id $nic.Id
$VM1 = New-AzVM -ResourceGroupName $rg.ResourceGroupName -Location $rg.Location -VM $vmconfig
Clean up resources
When no longer needed, you can use the Remove-AzResourceGroup command to remove the resource group, VM,
and all related resources.
Next steps
Learn more about routing preference in public IP addresses.
Learn more about public IP addresses in Azure.
Learn more about public IP address settings.
Configure routing preference for a VM using Azure
CLI
11/2/2020 • 2 minutes to read • Edit Online
This article shows you how to configure routing preference for a virtual machine. Internet bound traffic from the
VM will be routed via the ISP network when you choose Internet as your routing preference option . The default
routing is via the Microsoft global network.
This article shows you how to create a virtual machine with a public IP that is set to route traffic via the public
internet using Azure CLI.
IMPORTANT
Routing preference is currently in public preview. This preview version is provided without a service level agreement, and it's
not recommended for production workloads. Certain features might not be supported or might have constrained
capabilities. For more information, see Supplemental Terms of Use for Microsoft Azure Previews.
# Create a subnet
az network vnet subnet create \
--name mySubNet \
--resource-group MyResourceGroup \
--vnet-name myVNET \
--address-prefixes "10.0.0.0/24" \
--network-security-group myNSG
Create a NIC
Create a virtual NIC for the VM with az network nic create. The following example creates a virtual NIC, which will
be attached to the VM.
# Create a NIC
az network nic create \
--name mynic \
--resource-group MyResourceGroup \
--network-security-group myNSG \
--vnet-name myVNET \
--subnet mySubNet \
--private-ip-address-version IPv4 \
--public-ip-address MyRoutingPrefIP
Clean up resources
When no longer needed, you can use az group delete to remove the resource group and all of the resources it
contains:
Next steps
Learn more about routing preference in public IP addresses.
Learn more about public IP addresses in Azure.
Learn more about public IP address settings.
Tutorial: Filter network traffic with a network
security group using the Azure portal
12/20/2019 • 7 minutes to read • Edit Online
You can filter network traffic inbound to and outbound from a virtual network subnet with a network security
group. Network security groups contain security rules that filter network traffic by IP address, port, and
protocol. Security rules are applied to resources deployed in a subnet. In this tutorial, you learn how to:
Create a network security group and security rules
Create a virtual network and associate a network security group to a subnet
Deploy virtual machines (VM) into a subnet
Test traffic filters
If you prefer, you can complete this tutorial using the Azure CLI or PowerShell.
If you don't have an Azure subscription, create a free account before you begin.
Sign in to Azure
Sign in to the Azure portal at https://portal.azure.com.
SET T IN G VA L UE
Name myVirtualNetwork
SET T IN G VA L UE
Name myAsgWebServers
Location East US
SET T IN G VA L UE
Name myAsgMgmtServers
Location East US
SET T IN G VA L UE
Name myNsg
Location East US
3. Under Associate subnet , select Vir tual network and then select myVir tualNetwork . Select Subnet ,
select mySubnet , and then select OK .
2. Create a security rule that allows ports 80 and 443 to the myAsgWebSer vers application security
group. Under Add inbound security rule , enter, or select the following values, accept the remaining
defaults, and then select Add :
SET T IN G VA L UE
Name Allow-Web-All
SET T IN G VA L UE
Name Allow-RDP-All
In this tutorial, RDP (port 3389) is exposed to the internet for the VM that is assigned to the
myAsgMgmtServers application security group. For production environments, instead of exposing port
3389 to the internet, it's recommended that you connect to Azure resources that you want to manage
using a VPN or private network connection.
Once you've completed steps 1-3, review the rules you created. Your list should look like the list in the following
picture:
Name myVmWeb
SET T IN G VA L UE
6. Select Review + Create at the bottom, left corner, select Create to start VM deployment.
Create the second VM
Complete steps 1-6 again, but in step 3, name the VM myVmMgmt. The VM takes a few minutes to deploy. Do
not continue to the next step until the VM is deployed.
mstsc /v:myVmWeb
You are able to connect to the myVmWeb VM from the myVmMgmt VM because VMs in the same virtual
network can communicate with each other over any port, by default. You can't however, create a remote
desktop connection to the myVmWeb VM from the internet, because the security rule for the
myAsgWebServers doesn't allow port 3389 inbound from the internet and inbound traffic from the
Internet is denied to all resources, by default.
7. To install Microsoft IIS on the myVmWeb VM, enter the following command from a PowerShell session
on the myVmWeb VM:
8. After the IIS installation is complete, disconnect from the myVmWeb VM, which leaves you in the
myVmMgmt VM remote desktop connection.
9. Disconnect from the myVmMgmt VM.
10. In the Search resources, services, and docs box at the top of the Azure portal, begin typing myVmWeb
from your computer. When myVmWeb appears in the search results, select it. Note the Public IP
address for your VM. The address shown in the following picture is 137.135.84.74, but your address is
different:
11. To confirm that you can access the myVmWeb web server from the internet, open an internet browser on
your computer and browse to http://<public-ip-address-from-previous-step> . You see the IIS welcome
screen, because port 80 is allowed inbound from the internet to the myAsgWebServers application
security group that the network interface attached to the myVmWeb VM is in.
Clean up resources
When no longer needed, delete the resource group and all of the resources it contains:
1. Enter myResourceGroup in the Search box at the top of the portal. When you see myResourceGroup in
the search results, select it.
2. Select Delete resource group .
3. Enter myResourceGroup for TYPE THE RESOURCE GROUP NAME: and select Delete .
Next steps
In this tutorial, you created a network security group and associated it to a virtual network subnet. To learn
more about network security groups, see Network security group overview and Manage a network security
group.
Azure routes traffic between subnets by default. You may instead, choose to route traffic between subnets
through a VM, serving as a firewall, for example. To learn how to create a route table, advance to the next
tutorial.
Create a route table
Filter network traffic with a network security group
using PowerShell
11/2/2020 • 8 minutes to read • Edit Online
NOTE
This article has been updated to use the new Azure PowerShell Az module. You can still use the AzureRM module, which will
continue to receive bug fixes until at least December 2020. To learn more about the new Az module and AzureRM
compatibility, see Introducing the new Azure PowerShell Az module. For Az module installation instructions, see Install Azure
PowerShell.
You can filter network traffic inbound to and outbound from a virtual network subnet with a network security
group. Network security groups contain security rules that filter network traffic by IP address, port, and protocol.
Security rules are applied to resources deployed in a subnet. In this article, you learn how to:
Create a network security group and security rules
Create a virtual network and associate a network security group to a subnet
Deploy virtual machines (VM) into a subnet
Test traffic filters
If you don't have an Azure subscription, create a free account before you begin.
O P T IO N EXA M P L E/ L IN K
Select the Cloud Shell button on the menu bar at the upper
right in the Azure portal.
Create an application security group with New-AzApplicationSecurityGroup. An application security group enables
you to group servers with similar port filtering requirements. The following example creates two application
security groups.
$webAsg = New-AzApplicationSecurityGroup `
-ResourceGroupName myResourceGroup `
-Name myAsgWebServers `
-Location eastus
$mgmtAsg = New-AzApplicationSecurityGroup `
-ResourceGroupName myResourceGroup `
-Name myAsgMgmtServers `
-Location eastus
The following example creates a rule that allows traffic inbound from the internet to the *myMgmtServers*
application security group over port 3389:
$mgmtRule = New-AzNetworkSecurityRuleConfig `
-Name "Allow-RDP-All" `
-Access Allow `
-Protocol Tcp `
-Direction Inbound `
-Priority 110 `
-SourceAddressPrefix Internet `
-SourcePortRange * `
-DestinationApplicationSecurityGroupId $mgmtAsg.id `
-DestinationPortRange 3389
In this article, RDP (port 3389) is exposed to the internet for the myAsgMgmtServers VM. For production
environments, instead of exposing port 3389 to the internet, it's recommended that you connect to Azure
resources that you want to manage using a VPN or private network connection.
Create a network security group
Create a network security group with New-AzNetworkSecurityGroup. The following example creates a network
security group named myNsg:
$nsg = New-AzNetworkSecurityGroup `
-ResourceGroupName myResourceGroup `
-Location eastus `
-Name myNsg `
-SecurityRules $webRule,$mgmtRule
$virtualNetwork = New-AzVirtualNetwork `
-ResourceGroupName myResourceGroup `
-Location EastUS `
-Name myVirtualNetwork `
-AddressPrefix 10.0.0.0/16
Create a subnet configuration with New-AzVirtualNetworkSubnetConfig, and then write the subnet configuration
to the virtual network with Set-AzVirtualNetwork. The following example adds a subnet named mySubnet to the
virtual network and associates the myNsg network security group to it:
Add-AzVirtualNetworkSubnetConfig `
-Name mySubnet `
-VirtualNetwork $virtualNetwork `
-AddressPrefix "10.0.2.0/24" `
-NetworkSecurityGroup $nsg
$virtualNetwork | Set-AzVirtualNetwork
$virtualNetwork = Get-AzVirtualNetwork `
-Name myVirtualNetwork `
-Resourcegroupname myResourceGroup
$publicIpWeb = New-AzPublicIpAddress `
-AllocationMethod Dynamic `
-ResourceGroupName myResourceGroup `
-Location eastus `
-Name myVmWeb
$publicIpMgmt = New-AzPublicIpAddress `
-AllocationMethod Dynamic `
-ResourceGroupName myResourceGroup `
-Location eastus `
-Name myVmMgmt
Create two network interfaces with New-AzNetworkInterface, and assign a public IP address to the network
interface. The following example creates a network interface, associates the myVmWeb public IP address to it, and
makes it a member of the myAsgWebServers application security group:
$webNic = New-AzNetworkInterface `
-Location eastus `
-Name myVmWeb `
-ResourceGroupName myResourceGroup `
-SubnetId $virtualNetwork.Subnets[0].Id `
-ApplicationSecurityGroupId $webAsg.Id `
-PublicIpAddressId $publicIpWeb.Id
The following example creates a network interface, associates the myVmMgmt public IP address to it, and makes it
a member of the myAsgMgmtServers application security group:
$mgmtNic = New-AzNetworkInterface `
-Location eastus `
-Name myVmMgmt `
-ResourceGroupName myResourceGroup `
-SubnetId $virtualNetwork.Subnets[0].Id `
-ApplicationSecurityGroupId $mgmtAsg.Id `
-PublicIpAddressId $publicIpMgmt.Id
Create two VMs in the virtual network so you can validate traffic filtering in a later step.
Create a VM configuration with New-AzVMConfig, then create the VM with New-AzVM. The following example
creates a VM that will serve as a web server. The -AsJob option creates the VM in the background, so you can
continue to the next step:
# Create user object
$cred = Get-Credential -Message "Enter a username and password for the virtual machine."
$webVmConfig = New-AzVMConfig `
-VMName myVmWeb `
-VMSize Standard_DS1_V2 | `
Set-AzVMOperatingSystem -Windows `
-ComputerName myVmWeb `
-Credential $cred | `
Set-AzVMSourceImage `
-PublisherName MicrosoftWindowsServer `
-Offer WindowsServer `
-Skus 2016-Datacenter `
-Version latest | `
Add-AzVMNetworkInterface `
-Id $webNic.Id
New-AzVM `
-ResourceGroupName myResourceGroup `
-Location eastus `
-VM $webVmConfig `
-AsJob
# Create the web server virtual machine configuration and virtual machine.
$mgmtVmConfig = New-AzVMConfig `
-VMName myVmMgmt `
-VMSize Standard_DS1_V2 | `
Set-AzVMOperatingSystem -Windows `
-ComputerName myVmMgmt `
-Credential $cred | `
Set-AzVMSourceImage `
-PublisherName MicrosoftWindowsServer `
-Offer WindowsServer `
-Skus 2016-Datacenter `
-Version latest | `
Add-AzVMNetworkInterface `
-Id $mgmtNic.Id
New-AzVM `
-ResourceGroupName myResourceGroup `
-Location eastus `
-VM $mgmtVmConfig
The virtual machine takes a few minutes to create. Don't continue with the next step until Azure finishes creating
the VM.
Get-AzPublicIpAddress `
-Name myVmMgmt `
-ResourceGroupName myResourceGroup `
| Select IpAddress
Use the following command to create a remote desktop session with the myVmMgmt VM from your local
computer. Replace <publicIpAddress> with the IP address returned from the previous command.
mstsc /v:<publicIpAddress>
mstsc /v:myvmWeb
The connection succeeds because a default security rule within each network security group allows traffic over all
ports between all IP addresses within a virtual network. You can't create a remote desktop connection to the
myVmWeb VM from the internet because the security rule for the myAsgWebServers doesn't allow port 3389
inbound from the internet.
Use the following command to install Microsoft IIS on the myVmWeb VM from PowerShell:
After the IIS installation is complete, disconnect from the myVmWeb VM, which leaves you in the myVmMgmt VM
remote desktop connection. To view the IIS welcome screen, open an internet browser and browse to
http://myVmWeb.
Disconnect from the myVmMgmt VM.
On your computer, enter the following command from PowerShell to retrieve the public IP address of the
myVmWeb server:
Get-AzPublicIpAddress `
-Name myVmWeb `
-ResourceGroupName myResourceGroup `
| Select IpAddress
To confirm that you can access the myVmWeb web server from outside of Azure, open an internet browser on your
computer and browse to http://<public-ip-address-from-previous-step> . The connection succeeds, because port
80 is allowed inbound from the internet to the myAsgWebServers application security group that the network
interface attached to the myVmWeb VM is in.
Clean up resources
When no longer needed, you can use Remove-AzResourceGroup to remove the resource group and all of the
resources it contains:
You can filter network traffic inbound to and outbound from a virtual network subnet with a network security
group. Network security groups contain security rules that filter network traffic by IP address, port, and protocol.
Security rules are applied to resources deployed in a subnet. In this article, you learn how to:
Create a network security group and security rules
Create a virtual network and associate a network security group to a subnet
Deploy virtual machines (VM) into a subnet
Test traffic filters
If you don't have an Azure subscription, create a free account before you begin.
O P T IO N EXA M P L E/ L IN K
Select the Cloud Shell button on the menu bar at the upper
right in the Azure portal.
az group create \
--name myResourceGroup \
--location eastus
Create an application security group with az network asg create. An application security group enables you to
group servers with similar port filtering requirements. The following example creates two application security
groups.
The following example creates a rule that allows traffic inbound from the Internet to the myMgmtServers
application security group over port 22:
az network nsg rule create \
--resource-group myResourceGroup \
--nsg-name myNsg \
--name Allow-SSH-All \
--access Allow \
--protocol Tcp \
--direction Inbound \
--priority 110 \
--source-address-prefix Internet \
--source-port-range "*" \
--destination-asgs "myAsgMgmtServers" \
--destination-port-range 22
In this article, SSH (port 22) is exposed to the internet for the myAsgMgmtServers VM. For production
environments, instead of exposing port 22 to the internet, it's recommended that you connect to Azure resources
that you want to manage using a VPN or private network connection.
Add a subnet to a virtual network with az network vnet subnet create. The following example adds a subnet named
mySubnet to the virtual network and associates the myNsg network security group to it:
az vm create \
--resource-group myResourceGroup \
--name myVmWeb \
--image UbuntuLTS \
--vnet-name myVirtualNetwork \
--subnet mySubnet \
--nsg "" \
--asgs myAsgWebServers \
--admin-username azureuser \
--admin-password $adminPassword
The VM takes a few minutes to create. After the VM is created, output similar to the following example is returned:
{
"fqdns": "",
"id": "/subscriptions/00000000-0000-0000-0000-
000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVmWeb",
"location": "eastus",
"macAddress": "00-0D-3A-23-9A-49",
"powerState": "VM running",
"privateIpAddress": "10.0.0.4",
"publicIpAddress": "13.90.242.231",
"resourceGroup": "myResourceGroup"
}
Take note of the publicIpAddress . This address is used to access the VM from the internet in a later step. Create a
VM to serve as a management server:
az vm create \
--resource-group myResourceGroup \
--name myVmMgmt \
--image UbuntuLTS \
--vnet-name myVirtualNetwork \
--subnet mySubnet \
--nsg "" \
--asgs myAsgMgmtServers \
--admin-username azureuser \
--admin-password $adminPassword
The VM takes a few minutes to create. After the VM is created, note the publicIpAddress in the returned output.
This address is used to access the VM in the next step. Don't continue with the next step until Azure finishes
creating the VM.
ssh azureuser@<publicIpAddress>
When prompted for a password, enter the password you entered in Create VMs.
The connection succeeds, because port 22 is allowed inbound from the Internet to the myAsgMgmtServers
application security group that the network interface attached to the myVmMgmt VM is in.
Use the following command to SSH to the myVmWeb VM from the myVmMgmt VM:
ssh azureuser@myVmWeb
The connection succeeds because a default security rule within each network security group allows traffic over all
ports between all IP addresses within a virtual network. You can't SSH to the myVmWeb VM from the Internet
because the security rule for the myAsgWebServers doesn't allow port 22 inbound from the Internet.
Use the following commands to install the nginx web server on the myVmWeb VM:
# Install NGINX
sudo apt-get -y install nginx
The myVmWeb VM is allowed outbound to the Internet to retrieve nginx because a default security rule allows all
outbound traffic to the Internet. Exit the myVmWeb SSH session, which leaves you at the username@myVmMgmt:~$
prompt of the myVmMgmt VM. To retrieve the nginx welcome screen from the myVmWeb VM, enter the following
command:
curl myVmWeb
Logout of the myVmMgmt VM. To confirm that you can access the myVmWeb web server from outside of Azure,
enter curl <publicIpAddress> from your own computer. The connection succeeds, because port 80 is allowed
inbound from the Internet to the myAsgWebServers application security group that the network interface attached
to the myVmWeb VM is in.
Clean up resources
When no longer needed, use az group delete to remove the resource group and all of the resources it contains.
Next steps
In this article, you created a network security group and associated it to a virtual network subnet. To learn more
about network security groups, see Network security group overview and Manage a network security group.
Azure routes traffic between subnets by default. You may instead, choose to route traffic between subnets through
a VM, serving as a firewall, for example. To learn how, see Create a route table.
Quickstart: Create a Private Endpoint using the Azure
portal
11/2/2020 • 5 minutes to read • Edit Online
Get started with Azure Private Link by using a Private Endpoint to connect securely to an Azure web app.
In this quickstart, you'll create a private endpoint for an Azure web app and deploy a virtual machine to test the
private connection.
Private endpoints can be created for different kinds of Azure services, such as Azure SQL and Azure Storage.
Prerequisites
An Azure account with an active subscription. Create an account for free.
An Azure Web App with a PremiumV2-tier or higher app service plan deployed in your Azure subscription.
For more information and an example, see Quickstart: Create an ASP.NET Core web app in Azure.
For a detailed tutorial on creating a web app and an endpoint, see Tutorial: Connect to a web app using an
Azure Private Endpoint.
Sign in to Azure
Sign in to the Azure portal at https://portal.azure.com.
SET T IN G VA L UE
Project Details
Instance details
3. Select the IP Addresses tab or select the Next: IP Addresses button at the bottom of the page.
4. In the IP Addresses tab, enter this information:
SET T IN G VA L UE
SET T IN G VA L UE
7. Select Save .
8. Select the Security tab.
9. Under BastionHost , select Enable . Enter this information:
SET T IN G VA L UE
10. Select the Review + create tab or select the Review + create button.
11. Select Create .
SET T IN G VA L UE
Project Details
Instance details
Administrator account
3. Select the Networking tab, or select Next: Disks , then Next: Networking .
4. In the Networking tab, select or enter:
SET T IN G VA L UE
Network interface
Subnet mySubnet
Project details
Instance details
6. Select the Resource tab or the Next: Resource button at the bottom of the page.
7. In Resource , enter or select this information:
SET T IN G VA L UE
8. Select the Configuration tab or the Next: Configuration button at the bottom of the screen.
9. In Configuration , enter or select this information:
SET T IN G VA L UE
Networking
Server: UnKnown
Address: 168.63.129.16
Non-authoritative answer:
Name: mywebapp8675.privatelink.azurewebsites.net
Address: 10.1.0.5
Aliases: mywebapp8675.azurewebsites.net
A private IP address of 10.1.0.5 is returned for the web app name. This address is in the subnet of the
virtual network you created previously.
9. In the bastion connection to myVM , open Internet Explorer.
10. Enter the url of your web app, https://<your-webapp-name>.azurewebsites.net .
11. You'll receive the default web app page if your application hasn't been deployed:
12. Close the connection to myVM .
Clean up resources
If you're not going to continue to use this application, delete the virtual network, virtual machine, and web app with
the following steps:
1. From the left-hand menu, select Resource groups .
2. Select CreatePrivateEndpointQS-rg .
3. Select Delete resource group .
4. Enter CreatePrivateEndpointQS-rg in TYPE THE RESOURCE GROUP NAME .
5. Select Delete .
Next steps
In this quickstart, you created a:
Virtual network and bastion host.
Virtual machine.
Private endpoint for an Azure Web App.
You used the virtual machine to test connectivity securely to the web app across the private endpoint.
For more information on the services that support a private endpoint, see:
Private Link availability
Quickstart: Create a Private Endpoint using Azure
PowerShell
11/11/2020 • 5 minutes to read • Edit Online
Get started with Azure Private Link by using a Private Endpoint to connect securely to an Azure web app.
In this quickstart, you'll create a private endpoint for an Azure web app and deploy a virtual machine to test the
private connection.
Private endpoints can be created for different kinds of Azure services, such as Azure SQL and Azure Storage.
Prerequisites
An Azure account with an active subscription. Create an account for free.
An Azure Web App with a PremiumV2-tier or higher app service plan deployed in your Azure subscription.
For more information and an example, see Quickstart: Create an ASP.NET Core web app in Azure.
For a detailed tutorial on creating a web app and an endpoint, see Tutorial: Connect to a web app using an
Azure Private Endpoint.
If you choose to install and use PowerShell locally, this article requires the Azure PowerShell module version 5.4.1
or later. Run Get-Module -ListAvailable Az to find the installed version. If you need to upgrade, see Install Azure
PowerShell module. If you're running PowerShell locally, you also need to run Connect-AzAccount to create a
connection with Azure.
It can take a few minutes for the Azure Bastion host to deploy.
Non-authoritative answer:
Name: mywebapp8675.privatelink.azurewebsites.net
Address: 10.0.0.5
Aliases: mywebapp8675.azurewebsites.net
A private IP address of 10.0.0.5 is returned for the web app name. This address is in the subnet of the
virtual network you created previously.
10. In the bastion connection to myVM , open Internet Explorer.
11. Enter the url of your web app, https://<your-webapp-name>.azurewebsites.net .
12. You'll receive the default web app page if your application hasn't been deployed:
Clean up resources
When you're done using the private endpoint and the VM, use Remove-AzResourceGroup to remove the resource
group and all the resources it has:
Next steps
In this quickstart, you created a:
Virtual network and bastion host.
Virtual machine.
Private endpoint for an Azure Web App.
You used the virtual machine to test connectivity securely to the web app across the private endpoint.
For more information on the services that support a private endpoint, see:
Private Link availability
Quickstart: Create a Private Endpoint using Azure CLI
11/11/2020 • 5 minutes to read • Edit Online
Get started with Azure Private Link by using a Private Endpoint to connect securely to an Azure web app.
In this quickstart, you'll create a private endpoint for an Azure web app and deploy a virtual machine to test the
private connection.
Private endpoints can be created for different kinds of Azure services, such as Azure SQL and Azure Storage.
Prerequisites
An Azure account with an active subscription. Create an account for free.
An Azure Web App with a PremiumV2-tier or higher app service plan deployed in your Azure subscription.
For more information and an example, see Quickstart: Create an ASP.NET Core web app in Azure.
For a detailed tutorial on creating a web app and an endpoint, see Tutorial: Connect to a web app using an
Azure Private Endpoint.
Sign in to the Azure portal and check that your subscription is active by running az login .
Check your version of the Azure CLI in a terminal or command window by running az --version . For the latest
version, see the latest release notes.
If you don't have the latest version, update your installation by following the installation guide for your
operating system or platform.
az group create \
--name CreatePrivateEndpointQS-rg \
--location eastus
Update the subnet to disable private endpoint network policies for the private endpoint with az network vnet
subnet update:
Use az network public-ip create to create a public ip address for the bastion host:
Create a standard zone redundant public IP address named myBastionIP .
In CreatePrivateEndpointQS-rg .
az vm create \
--resource-group CreatePrivateEndpointQS-rg \
--name myVM \
--image Win2019Datacenter \
--public-ip-address "" \
--vnet-name myVNet \
--subnet myBackendSubnet \
--admin-username azureuser
Server: UnKnown
Address: 168.63.129.16
Non-authoritative answer:
Name: mywebapp8675.privatelink.azurewebsites.net
Address: 10.0.0.5
Aliases: mywebapp8675.azurewebsites.net
A private IP address of 10.0.0.5 is returned for the web app name. This address is in the subnet of the
virtual network you created previously.
10. In the bastion connection to myVM , open Internet Explorer.
11. Enter the url of your web app, https://<your-webapp-name>.azurewebsites.net .
12. You'll receive the default web app page if your application hasn't been deployed:
Clean up resources
When you're done using the private endpoint and the VM, use az group delete to remove the resource group and
all the resources it has:
az group delete \
--name CreatePrivateEndpointQS-rg
Next steps
In this quickstart, you created a:
Virtual network and bastion host.
Virtual machine.
Private endpoint for an Azure Web App.
You used the virtual machine to test connectivity securely to the web app across the private endpoint.
For more information on the services that support a private endpoint, see:
Private Link availability
Tutorial: Restrict network access to PaaS resources
with virtual network service endpoints using the
Azure portal
11/2/2020 • 9 minutes to read • Edit Online
Virtual network service endpoints enable you to limit network access to some Azure service resources to a virtual
network subnet. You can also remove internet access to the resources. Service endpoints provide direct
connection from your virtual network to supported Azure services, allowing you to use your virtual network's
private address space to access the Azure services. Traffic destined to Azure resources through service endpoints
always stays on the Microsoft Azure backbone network. In this tutorial, you learn how to:
Create a virtual network with one subnet
Add a subnet and enable a service endpoint
Create an Azure resource and allow network access to it from only a subnet
Deploy a virtual machine (VM) to each subnet
Confirm access to a resource from a subnet
Confirm access is denied to a resource from a subnet and the internet
If you prefer, you can complete this tutorial using the Azure CLI or Azure PowerShell.
If you don't have an Azure subscription, create a free account before you begin.
Log in to Azure
Log in to the Azure portal at https://portal.azure.com.
SET T IN G VA L UE
Name myVirtualNetwork
Firewall Disabled
SET T IN G VA L UE
Name Private
Cau t i on
Before enabling a service endpoint for an existing subnet that has resources in it, see Change subnet settings.
SET T IN G VA L UE
Name myNsgPrivate
SET T IN G VA L UE
Protocol Any
Action Allow
Priority 100
Name Allow-Storage-All
8. Create another outbound security rule that denies communication to the internet. This rule overrides a
default rule in all network security groups that allows outbound internet communication. Complete steps
5-7 again, using the following values:
SET T IN G VA L UE
Protocol Any
Action Deny
Priority 110
Name Deny-Internet-All
9. Under SETTINGS , select Inbound security rules .
10. Select + Add .
11. Create an inbound security rule that allows Remote Desktop Protocol (RDP) traffic to the subnet from
anywhere. The rule overrides a default security rule that denies all inbound traffic from the internet. Remote
desktop connections are allowed to the subnet so that connectivity can be tested in a later step. Under
SETTINGS , select Inbound security rules , select +Add , enter the following values, and then select Add :
SET T IN G VA L UE
Source Any
Protocol Any
Action Allow
Priority 120
Name Allow-RDP-All
SET T IN G VA L UE
5. Select Save .
6. Close the Firewalls and vir tual networks box.
7. Under SETTINGS for the storage account, select Access keys , as shown in the following picture:
8. Note the Key value, as you'll have to manually enter it in a later step when mapping the file share to a drive
letter in a VM.
SET T IN G VA L UE
Name myVmPublic
4. Select a size for the virtual machine and then select Select .
5. Under Settings , select Network and then select myVir tualNetwork . Then select Subnet , and select
Public , as shown in the following picture:
6. Under Network Security Group , select Advanced . The portal automatically creates a network security
group for you that allows port 3389, which you'll need open to connect to the virtual machine in a later
step. Select OK on the Settings page.
7. On the Summar y page, select Create to start the virtual machine deployment. The VM takes a few
minutes to deploy, but you can continue to the next step while the VM is creating.
Create the second virtual machine
Complete steps 1-7 again, but in step 3, name the virtual machine myVmPrivate and in step 5, select the Private
subnet.
The VM takes a few minutes to deploy. Do not continue to the next step until it finishes creating and its settings
open in the portal.
2. After selecting the Connect button, a Remote Desktop Protocol (.rdp) file is created and downloaded to
your computer.
3. Open the downloaded rdp file. If prompted, select Connect . Enter the user name and password you
specified when creating the VM. You may need to select More choices , then Use a different account , to
specify the credentials you entered when you created the VM.
4. Select OK .
5. You may receive a certificate warning during the sign-in process. If you receive the warning, select Yes or
Continue , to proceed with the connection.
6. On the myVmPrivate VM, map the Azure file share to drive Z using PowerShell. Before running the
commands that follow, replace <storage-account-key> and <storage-account-name> with values you
supplied and retrieved in Create a storage account.
ping bing.com
You receive no replies, because the network security group associated to the Private subnet does not allow
outbound access to the internet.
8. Close the remote desktop session to the myVmPrivate VM.
Access is denied, because your computer is not in the Private subnet of the MyVirtualNetwork virtual
network.
Clean up resources
When no longer needed, delete the resource group and all resources it contains:
1. Enter myResourceGroup in the Search box at the top of the portal. When you see myResourceGroup in the
search results, select it.
2. Select Delete resource group .
3. Enter myResourceGroup for TYPE THE RESOURCE GROUP NAME: and select Delete .
Next steps
In this tutorial, you enabled a service endpoint for a virtual network subnet. You learned that you can enable
service endpoints for resources deployed from multiple Azure services. You created an Azure Storage account and
restricted network access to the storage account to only resources within a virtual network subnet. To learn more
about service endpoints, see Service endpoints overview and Manage subnets.
If you have multiple virtual networks in your account, you may want to connect two virtual networks together so
the resources within each virtual network can communicate with each other. To learn how to connect virtual
networks, advance to the next tutorial.
Connect virtual networks
Restrict network access to PaaS resources with virtual
network service endpoints using PowerShell
11/2/2020 • 10 minutes to read • Edit Online
NOTE
This article has been updated to use the new Azure PowerShell Az module. You can still use the AzureRM module, which will
continue to receive bug fixes until at least December 2020. To learn more about the new Az module and AzureRM
compatibility, see Introducing the new Azure PowerShell Az module. For Az module installation instructions, see Install Azure
PowerShell.
Virtual network service endpoints enable you to limit network access to some Azure service resources to a virtual
network subnet. You can also remove internet access to the resources. Service endpoints provide direct connection
from your virtual network to supported Azure services, allowing you to use your virtual network's private address
space to access the Azure services. Traffic destined to Azure resources through service endpoints always stays on
the Microsoft Azure backbone network. In this article, you learn how to:
Create a virtual network with one subnet
Add a subnet and enable a service endpoint
Create an Azure resource and allow network access to it from only a subnet
Deploy a virtual machine (VM) to each subnet
Confirm access to a resource from a subnet
Confirm access is denied to a resource from a subnet and the internet
If you don't have an Azure subscription, create a free account before you begin.
O P T IO N EXA M P L E/ L IN K
Select the Cloud Shell button on the menu bar at the upper
right in the Azure portal.
Create a virtual network with New-AzVirtualNetwork. The following example creates a virtual network named
myVirtualNetwork with the address prefix 10.0.0.0/16.
$virtualNetwork = New-AzVirtualNetwork `
-ResourceGroupName myResourceGroup `
-Location EastUS `
-Name myVirtualNetwork `
-AddressPrefix 10.0.0.0/16
Create a subnet configuration with New-AzVirtualNetworkSubnetConfig. The following example creates a subnet
configuration for a subnet named Public:
$subnetConfigPublic = Add-AzVirtualNetworkSubnetConfig `
-Name Public `
-AddressPrefix 10.0.0.0/24 `
-VirtualNetwork $virtualNetwork
Create the subnet in the virtual network by writing the subnet configuration to the virtual network with Set-
AzVirtualNetwork:
$virtualNetwork | Set-AzVirtualNetwork
Create an additional subnet in the virtual network. In this example, a subnet named Private is created with a
service endpoint for Microsoft.Storage:
$subnetConfigPrivate = Add-AzVirtualNetworkSubnetConfig `
-Name Private `
-AddressPrefix 10.0.1.0/24 `
-VirtualNetwork $virtualNetwork `
-ServiceEndpoint Microsoft.Storage
$virtualNetwork | Set-AzVirtualNetwork
$rule1 = New-AzNetworkSecurityRuleConfig `
-Name Allow-Storage-All `
-Access Allow `
-DestinationAddressPrefix Storage `
-DestinationPortRange * `
-Direction Outbound `
-Priority 100 `
-Protocol * `
-SourceAddressPrefix VirtualNetwork `
-SourcePortRange *
The following rule denies access to all public IP addresses. The previous rule overrides this rule, due to its higher
priority, which allows access to the public IP addresses of Azure Storage.
$rule2 = New-AzNetworkSecurityRuleConfig `
-Name Deny-Internet-All `
-Access Deny `
-DestinationAddressPrefix Internet `
-DestinationPortRange * `
-Direction Outbound `
-Priority 110 `
-Protocol * `
-SourceAddressPrefix VirtualNetwork `
-SourcePortRange *
The following rule allows Remote Desktop Protocol (RDP) traffic inbound to the subnet from anywhere. Remote
desktop connections are allowed to the subnet, so that you can confirm network access to a resource in a later
step.
$rule3 = New-AzNetworkSecurityRuleConfig `
-Name Allow-RDP-All `
-Access Allow `
-DestinationAddressPrefix VirtualNetwork `
-DestinationPortRange 3389 `
-Direction Inbound `
-Priority 120 `
-Protocol * `
-SourceAddressPrefix * `
-SourcePortRange *
Create a network security group with New-AzNetworkSecurityGroup. The following example creates a network
security group named myNsgPrivate.
$nsg = New-AzNetworkSecurityGroup `
-ResourceGroupName myResourceGroup `
-Location EastUS `
-Name myNsgPrivate `
-SecurityRules $rule1,$rule2,$rule3
Associate the network security group to the Private subnet with Set-AzVirtualNetworkSubnetConfig and then write
the subnet configuration to the virtual network. The following example associates the myNsgPrivate network
security group to the Private subnet:
Set-AzVirtualNetworkSubnetConfig `
-VirtualNetwork $VirtualNetwork `
-Name Private `
-AddressPrefix 10.0.1.0/24 `
-ServiceEndpoint Microsoft.Storage `
-NetworkSecurityGroup $nsg
$virtualNetwork | Set-AzVirtualNetwork
$storageAcctName = '<replace-with-your-unique-storage-account-name>'
New-AzStorageAccount `
-Location EastUS `
-Name $storageAcctName `
-ResourceGroupName myResourceGroup `
-SkuName Standard_LRS `
-Kind StorageV2
After the storage account is created, retrieve the key for the storage account into a variable with Get-
AzStorageAccountKey:
$storageAcctKey = (Get-AzStorageAccountKey `
-ResourceGroupName myResourceGroup `
-AccountName $storageAcctName).Value[0]
The key is used to create a file share in a later step. Enter $storageAcctKey and note the value, as you'll also need
to manually enter it in a later step when you map the file share to a drive in a VM.
Create a file share in the storage account
Create a context for your storage account and key with New-AzStorageContext. The context encapsulates the
storage account name and account key:
Update-AzStorageAccountNetworkRuleSet `
-ResourceGroupName "myresourcegroup" `
-Name $storageAcctName `
-DefaultAction Deny
$privateSubnet = Get-AzVirtualNetwork `
-ResourceGroupName "myResourceGroup" `
-Name "myVirtualNetwork" `
| Get-AzVirtualNetworkSubnetConfig `
-Name "Private"
Allow network access to the storage account from the Private subnet with Add-AzStorageAccountNetworkRule.
Add-AzStorageAccountNetworkRule `
-ResourceGroupName "myresourcegroup" `
-Name $storageAcctName `
-VirtualNetworkResourceId $privateSubnet.Id
New-AzVm `
-ResourceGroupName "myResourceGroup" `
-Location "East US" `
-VirtualNetworkName "myVirtualNetwork" `
-SubnetName "Public" `
-Name "myVmPublic" `
-AsJob
New-AzVm `
-ResourceGroupName "myResourceGroup" `
-Location "East US" `
-VirtualNetworkName "myVirtualNetwork" `
-SubnetName "Private" `
-Name "myVmPrivate"
It takes a few minutes for Azure to create the VM. Do not continue to the next step until Azure finishes creating the
VM and returns output to PowerShell.
Get-AzPublicIpAddress `
-Name myVmPrivate `
-ResourceGroupName myResourceGroup `
| Select IpAddress
Replace <publicIpAddress> in the following command, with the public IP address returned from the previous
command, and then enter the following command:
mstsc /v:<publicIpAddress>
A Remote Desktop Protocol (.rdp) file is created and downloaded to your computer. Open the downloaded rdp file.
If prompted, select Connect . Enter the user name and password you specified when creating the VM. You may
need to select More choices , then Use a different account , to specify the credentials you entered when you
created the VM. Select OK . You may receive a certificate warning during the sign-in process. If you receive the
warning, select Yes or Continue , to proceed with the connection.
On the myVmPrivate VM, map the Azure file share to drive Z using PowerShell. Before running the commands that
follow, replace <storage-account-key> and <storage-account-name> with values from you supplied or retrieved in
Create a storage account.
You receive no replies, because the network security group associated to the Private subnet does not allow
outbound access to public IP addresses other than the addresses assigned to the Azure Storage service.
Close the remote desktop session to the myVmPrivate VM.
Get-AzPublicIpAddress `
-Name myVmPublic `
-ResourceGroupName myResourceGroup `
| Select IpAddress
Replace <publicIpAddress> in the following command, with the public IP address returned from the previous
command, and then enter the following command:
mstsc /v:<publicIpAddress>
On the myVmPublic VM, attempt to map the Azure file share to drive Z. Before running the commands that follow,
replace <storage-account-key> and <storage-account-name> with values from you supplied or retrieved in Create a
storage account.
Access to the share is denied, and you receive a New-PSDrive : Access is denied error. Access is denied because
the myVmPublic VM is deployed in the Public subnet. The Public subnet does not have a service endpoint enabled
for Azure Storage, and the storage account only allows network access from the Private subnet, not the Public
subnet.
Close the remote desktop session to the myVmPublic VM.
From your computer, attempt to view the file shares in the storage account with the following command:
Get-AzStorageFile `
-ShareName my-file-share `
-Context $storageContext
Access is denied, and you receive a Get-AzStorageFile : The remote server returned an error: (403) Forbidden.
HTTP Status Code: 403 - HTTP Error Message: This request is not authorized to perform this operation error,
because your computer is not in the Private subnet of the MyVirtualNetwork virtual network.
Clean up resources
When no longer needed, you can use Remove-AzResourceGroup to remove the resource group and all of the
resources it contains:
Remove-AzResourceGroup -Name myResourceGroup -Force
Next steps
In this article, you enabled a service endpoint for a virtual network subnet. You learned that service endpoints can
be enabled for resources deployed with multiple Azure services. You created an Azure Storage account and limited
network access to the storage account to only resources within a virtual network subnet. To learn more about
service endpoints, see Service endpoints overview and Manage subnets.
If you have multiple virtual networks in your account, you may want to connect two virtual networks together so
the resources within each virtual network can communicate with each other. To learn how, see Connect virtual
networks.
Restrict network access to PaaS resources with virtual
network service endpoints using the Azure CLI
11/2/2020 • 9 minutes to read • Edit Online
Virtual network service endpoints enable you to limit network access to some Azure service resources to a virtual
network subnet. You can also remove internet access to the resources. Service endpoints provide direct connection
from your virtual network to supported Azure services, allowing you to use your virtual network's private address
space to access the Azure services. Traffic destined to Azure resources through service endpoints always stays on
the Microsoft Azure backbone network. In this article, you learn how to:
Create a virtual network with one subnet
Add a subnet and enable a service endpoint
Create an Azure resource and allow network access to it from only a subnet
Deploy a virtual machine (VM) to each subnet
Confirm access to a resource from a subnet
Confirm access is denied to a resource from a subnet and the internet
If you don't have an Azure subscription, create a free account before you begin.
O P T IO N EXA M P L E/ L IN K
Select the Cloud Shell button on the menu bar at the upper
right in the Azure portal.
az group create \
--name myResourceGroup \
--location eastus
Create a virtual network with one subnet with az network vnet create.
Create an additional subnet in the virtual network with az network vnet subnet create. In this example, a service
endpoint for Microsoft.Storage is created for the subnet:
Associate the network security group to the Private subnet with az network vnet subnet update. The following
example associates the myNsgPrivate network security group to the Private subnet:
az network vnet subnet update \
--vnet-name myVirtualNetwork \
--name Private \
--resource-group myResourceGroup \
--network-security-group myNsgPrivate
Create security rules with az network nsg rule create. The rule that follows allows outbound access to the public IP
addresses assigned to the Azure Storage service:
Each network security group contains several default security rules. The rule that follows overrides a default
security rule that allows outbound access to all public IP addresses. The destination-address-prefix "Internet"
option denies outbound access to all public IP addresses. The previous rule overrides this rule, due to its higher
priority, which allows access to the public IP addresses of Azure Storage.
The following rule allows SSH traffic inbound to the subnet from anywhere. The rule overrides a default security
rule that denies all inbound traffic from the internet. SSH is allowed to the subnet so that connectivity can be
tested in a later step.
storageAcctName="<replace-with-your-unique-storage-account-name>"
After the storage account is created, retrieve the connection string for the storage account into a variable with az
storage account show-connection-string. The connection string is used to create a file share in a later step.
View the contents of the variable and note the value for AccountKey returned in the output, because it's used in a
later step.
echo $saConnectionString
az vm create \
--resource-group myResourceGroup \
--name myVmPublic \
--image UbuntuLTS \
--vnet-name myVirtualNetwork \
--subnet Public \
--generate-ssh-keys
The VM takes a few minutes to create. After the VM is created, the Azure CLI shows information similar to the
following example:
{
"fqdns": "",
"id": "/subscriptions/00000000-0000-0000-0000-
000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVmPublic",
"location": "eastus",
"macAddress": "00-0D-3A-23-9A-49",
"powerState": "VM running",
"privateIpAddress": "10.0.0.4",
"publicIpAddress": "13.90.242.231",
"resourceGroup": "myResourceGroup"
}
Take note of the publicIpAddress in the returned output. This address is used to access the VM from the internet
in a later step.
Create the second virtual machine
az vm create \
--resource-group myResourceGroup \
--name myVmPrivate \
--image UbuntuLTS \
--vnet-name myVirtualNetwork \
--subnet Private \
--generate-ssh-keys
The VM takes a few minutes to create. After creation, take note of the publicIpAddress in the output returned.
This address is used to access the VM from the internet in a later step.
Mount the Azure file share to the directory you created. Before running the following command, replace
<storage-account-name> with the account name and <storage-account-key> with the key you retrieved in Create a
storage account.
You receive the user@myVmPrivate:~$ prompt. The Azure file share successfully mounted to
/mnt/MyAzureFileShare.
Confirm that the VM has no outbound connectivity to any other public IP addresses:
ping bing.com -c 4
You receive no replies, because the network security group associated to the Private subnet does not allow
outbound access to public IP addresses other than the addresses assigned to the Azure Storage service.
Exit the SSH session to the myVmPrivate VM.
ssh <publicIpAddress>
Attempt to mount the Azure file share to the directory you created. This article assumes you deployed the latest
version of Ubuntu. If you are using earlier versions of Ubuntu, see Mount on Linux for additional instructions
about mounting file shares. Before running the following command, replace <storage-account-name> with the
account name and <storage-account-key> with the key you retrieved in Create a storage account:
Access is denied, and you receive a mount error(13): Permission denied error, because the myVmPublic VM is
deployed within the Public subnet. The Public subnet does not have a service endpoint enabled for Azure Storage,
and the storage account only allows network access from the Private subnet, not the Public subnet.
Exit the SSH session to the myVmPublic VM.
From your computer, attempt to view the shares in your storage account with az storage share list. Replace
<account-name> and <account-key> with the storage account name and key from Create a storage account:
Access is denied and you receive a This request is not authorized to perform this operation error, because your
computer is not in the Private subnet of the MyVirtualNetwork virtual network.
Clean up resources
When no longer needed, use az group delete to remove the resource group and all of the resources it contains.
Next steps
In this article, you enabled a service endpoint for a virtual network subnet. You learned that service endpoints can
be enabled for resources deployed with multiple Azure services. You created an Azure Storage account and limited
network access to the storage account to only resources within a virtual network subnet. To learn more about
service endpoints, see Service endpoints overview and Manage subnets.
If you have multiple virtual networks in your account, you may want to connect two virtual networks together so
the resources within each virtual network can communicate with each other. To learn how, see Connect virtual
networks.
Create, change, or delete service endpoint policy
using the Azure portal
11/2/2020 • 3 minutes to read • Edit Online
Service endpoint policies enable you to filter virtual network traffic to specific Azure resources, over service
endpoints. If you're not familiar with service endpoint policies, see service endpoint policies overview to learn
more.
In this tutorial, you learn how to:
Create a service endpoint policy
Create a service endpoint policy definition
Create a virtual network with a subnet
Associate a service endpoint policy to a subnet
If you don't have an Azure subscription, create a free account before you begin.
Sign in to Azure
Sign in to the Azure portal at https://portal.azure.com.
3. Select the policy and click on Policy Definitions to view or add more policy definitions.
4. Select Associated subnets to view the subnets the policy is associated. If no subnet is associated yet,
follow the instructions in the next step.
Before you can associate a policy to a subnet, you have to create a virtual network and subnet. Please refer
to the Create a Virtual Network article for help with this.
Once you have the virtual network and subnet are setup, you need to configure Virtual Network Service
Endpoints for Azure Storage. On the Virtual Network blade, select Ser vice endpoints , and in the next pane
select Microsoft.Storage and under Subnets select the desired VNet or Subnet
Now, you can either choose to select the Service Endpoint Policy from the drop-down in the above pane if
you have already created Service Endpoint policies before configuring Service Endpoint for the Subnet as
shown below
OR if you are associating Service Endpoint policies after Service Endpoints are already configured, you can
choose to associate the subnet from within the Service Endpoint Policy blade by navigating to the
Associated Subnets pane as shown below
WARNING
Access to Azure Storage resources in all regions will be restricted as per Service Endpoint Policy from this subnet.
Next steps
In this tutorial, you created a service endpoint policy and associated it to a subnet. To learn more about service
endpoint policies, see service endpoint policies overview.
Manage data exfiltration to Azure Storage accounts
with Virtual network service endpoint policies using
Azure PowerShell
11/2/2020 • 9 minutes to read • Edit Online
NOTE
This article has been updated to use the new Azure PowerShell Az module. You can still use the AzureRM module, which will
continue to receive bug fixes until at least December 2020. To learn more about the new Az module and AzureRM
compatibility, see Introducing the new Azure PowerShell Az module. For Az module installation instructions, see Install Azure
PowerShell.
Virtual network service endpoint policies enable you to apply access control on Azure Storage accounts from within
a virtual network over service endpoints. This is a key to securing your workloads, managing what storage
accounts are allowed and where data exfiltration is allowed. In this article, you learn how to:
Create a virtual network.
Add a subnet and enable service endpoint for Azure Storage.
Create two Azure Storage accounts and allow network access to it from the subnet created above.
Create a service endpoint policy to allow access only to one of the storage accounts.
Deploy a virtual machine (VM) to the subnet.
Confirm access to the allowed storage account from the subnet.
Confirm access is denied to the non-allowed storage account from the subnet.
If you don't have an Azure subscription, create a free account before you begin.
O P T IO N EXA M P L E/ L IN K
Select the Cloud Shell button on the menu bar at the upper
right in the Azure portal.
New-AzResourceGroup `
-ResourceGroupName myResourceGroup `
-Location EastUS
Create a virtual network with New-AzVirtualNetwork. The following example creates a virtual network named
myVirtualNetwork with the address prefix 10.0.0.0/16.
$virtualNetwork = New-AzVirtualNetwork `
-ResourceGroupName myResourceGroup `
-Location EastUS `
-Name myVirtualNetwork `
-AddressPrefix 10.0.0.0/16
$subnetConfigPrivate = Add-AzVirtualNetworkSubnetConfig `
-Name Private `
-AddressPrefix 10.0.0.0/24 `
-VirtualNetwork $virtualNetwork `
-ServiceEndpoint Microsoft.Storage
$virtualNetwork | Set-AzVirtualNetwork
The following rule denies access to all public IP addresses. The previous rule overrides this rule, due to its higher
priority, which allows access to the public IP addresses of Azure Storage.
$rule2 = New-AzNetworkSecurityRuleConfig `
-Name Deny-Internet-All `
-Access Deny `
-DestinationAddressPrefix Internet `
-DestinationPortRange * `
-Direction Outbound `
-Priority 110 -Protocol * `
-SourceAddressPrefix VirtualNetwork `
-SourcePortRange *
The following rule allows Remote Desktop Protocol (RDP) traffic inbound to the subnet from anywhere. Remote
desktop connections are allowed to the subnet, so that you can confirm network access to a resource in a later step.
$rule3 = New-AzNetworkSecurityRuleConfig `
-Name Allow-RDP-All `
-Access Allow `
-DestinationAddressPrefix VirtualNetwork `
-DestinationPortRange 3389 `
-Direction Inbound `
-Priority 120 `
-Protocol * `
-SourceAddressPrefix * `
-SourcePortRange *
Create a network security group with New-AzNetworkSecurityGroup. The following example creates a network
security group named myNsgPrivate.
$nsg = New-AzNetworkSecurityGroup `
-ResourceGroupName myResourceGroup `
-Location EastUS `
-Name myNsgPrivate `
-SecurityRules $rule1,$rule2,$rule3
Associate the network security group to the Private subnet with Set-AzVirtualNetworkSubnetConfig and then write
the subnet configuration to the virtual network. The following example associates the myNsgPrivate network
security group to the Private subnet:
Set-AzVirtualNetworkSubnetConfig `
-VirtualNetwork $VirtualNetwork `
-Name Private `
-AddressPrefix 10.0.0.0/24 `
-ServiceEndpoint Microsoft.Storage `
-NetworkSecurityGroup $nsg
$virtualNetwork | Set-AzVirtualNetwork
Restrict network access to Azure Storage accounts
The steps necessary to restrict network access to resources created through Azure services enabled for service
endpoints varies across services. See the documentation for individual services for specific steps for each service.
The remainder of this article includes steps to restrict network access for an Azure Storage account, as an example.
Create two storage accounts
Create an Azure storage account with New-AzStorageAccount.
$storageAcctName1 = 'allowedaccount'
New-AzStorageAccount `
-Location EastUS `
-Name $storageAcctName1 `
-ResourceGroupName myResourceGroup `
-SkuName Standard_LRS `
-Kind StorageV2
After the storage account is created, retrieve the key for the storage account into a variable with Get-
AzStorageAccountKey:
The key is used to create a file share in a later step. Enter $storageAcctKey and note the value, as you'll also need to
manually enter it in a later step when you map the file share to a drive in a VM.
Now repeat the above steps to create a second storage account.
$storageAcctName2 = 'notallowedaccount'
New-AzStorageAccount `
-Location EastUS `
-Name $storageAcctName2 `
-ResourceGroupName myResourceGroup `
-SkuName Standard_LRS `
-Kind StorageV2
Also retrieve the storage account key from this account for using later to create a file share.
Update-AzStorageAccountNetworkRuleSet `
-ResourceGroupName myresourcegroup `
-Name $storageAcctName1 `
-DefaultAction Deny
Update-AzStorageAccountNetworkRuleSet `
-ResourceGroupName myresourcegroup `
-Name $storageAcctName2 `
-DefaultAction Deny
$privateSubnet = Get-AzVirtualNetwork `
-ResourceGroupName myResourceGroup `
-Name myVirtualNetwork `
| Get-AzVirtualNetworkSubnetConfig -Name Private
Allow network access to the storage account from the Private subnet with Add-AzStorageAccountNetworkRule.
Add-AzStorageAccountNetworkRule `
-ResourceGroupName myresourcegroup `
-Name $storageAcctName1 `
-VirtualNetworkResourceId $privateSubnet.Id
Add-AzStorageAccountNetworkRule `
-ResourceGroupName myresourcegroup `
-Name $storageAcctName2 `
-VirtualNetworkResourceId $privateSubnet.Id
Create the service endpoint policy using the policy definition created above
$virtualNetwork | Set-AzVirtualNetwork
Get-AzPublicIpAddress `
-Name myVmPrivate `
-ResourceGroupName myResourceGroup `
| Select IpAddress
Replace <publicIpAddress> in the following command, with the public IP address returned from the previous
command, and then enter the following command:
mstsc /v:<publicIpAddress>
A Remote Desktop Protocol (.rdp) file is created and downloaded to your computer. Open the downloaded rdp file.
If prompted, select Connect . Enter the user name and password you specified when creating the VM. You may
need to select More choices , then Use a different account , to specify the credentials you entered when you
created the VM. Select OK . You may receive a certificate warning during the sign-in process. If you receive the
warning, select Yes or Continue , to proceed with the connection.
On the myVmPrivate VM, map the Azure file share from allowed storage account to drive Z using PowerShell.
Access to the share is denied, and you receive a New-PSDrive : Access is denied error. Access is denied because the
storage account notallowedaccount is not in the allowed resources list in the service endpoint policy.
Close the remote desktop session to the myVmPublic VM.
Clean up resources
When no longer needed, you can use Remove-AzResourceGroup to remove the resource group and all of the
resources it contains:
Next steps
In this article, you applied a service endpoint policy over an Azure virtual network service endpoint to Azure
Storage. You created Azure Storage accounts and limited network access to only certain storage accounts (and thus
denied others) from a virtual network subnet. To learn more about service endpoint policies, see Service endpoints
policies overview.
Manage data exfiltration to Azure Storage accounts
with virtual network service endpoint policies using
the Azure CLI
11/2/2020 • 8 minutes to read • Edit Online
Virtual network service endpoint policies enable you to apply access control on Azure Storage accounts from within
a virtual network over service endpoints. This is a key to securing your workloads, managing what storage
accounts are allowed and where data exfiltration is allowed. In this article, you learn how to:
Create a virtual network and add a subnet.
Enable service endpoint for Azure Storage.
Create two Azure Storage accounts and allow network access to it from the subnet created above.
Create a service endpoint policy to allow access only to one of the storage accounts.
Deploy a virtual machine (VM) to the subnet.
Confirm access to the allowed storage account from the subnet.
Confirm access is denied to the non-allowed storage account from the subnet.
If you don't have an Azure subscription, create a free account before you begin.
O P T IO N EXA M P L E/ L IN K
Select the Cloud Shell button on the menu bar at the upper
right in the Azure portal.
az group create \
--name myResourceGroup \
--location eastus
Create a virtual network with one subnet with az network vnet create.
Associate the network security group to the Private subnet with az network vnet subnet update. The following
example associates the myNsgPrivate network security group to the Private subnet:
Create security rules with az network nsg rule create. The rule that follows allows outbound access to the public IP
addresses assigned to the Azure Storage service:
az network nsg rule create \
--resource-group myResourceGroup \
--nsg-name myNsgPrivate \
--name Allow-Storage-All \
--access Allow \
--protocol "*" \
--direction Outbound \
--priority 100 \
--source-address-prefix "VirtualNetwork" \
--source-port-range "*" \
--destination-address-prefix "Storage" \
--destination-port-range "*"
Each network security group contains several default security rules. The rule that follows overrides a default
security rule that allows outbound access to all public IP addresses. The destination-address-prefix "Internet"
option denies outbound access to all public IP addresses. The previous rule overrides this rule, due to its higher
priority, which allows access to the public IP addresses of Azure Storage.
The following rule allows SSH traffic inbound to the subnet from anywhere. The rule overrides a default security
rule that denies all inbound traffic from the internet. SSH is allowed to the subnet so that connectivity can be tested
in a later step.
storageAcctName2="notallowedstorageacc"
After the storage accounts are created, retrieve the connection string for the storage accounts into a variable with
az storage account show-connection-string. The connection string is used to create a file share in a later step.
View the contents of the variable and note the value for AccountKey returned in the output, because it's used in a
later step.
echo $saConnectionString1
echo $saConnectionString2
Save the resource URI for the allowed storage account in a variable. Before executing the command below, replace
<your-subscription-id> with actual value of your subscription ID.
$serviceResourceId="/subscriptions/<your-subscription-
id>/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/allowedstorageacc"
Create & add a policy definition for allowing the above Azure Storage account to the service endpoint policy
And update the virtual network subnet to associate with it the service endpoint policy created in the previous step
az network vnet subnet update \
--vnet-name myVirtualNetwork \
--resource-group myResourceGroup \
--name Private \
--service-endpoints Microsoft.Storage \
--service-endpoint-policy mysepolicy
az vm create \
--resource-group myResourceGroup \
--name myVmPrivate \
--image UbuntuLTS \
--vnet-name myVirtualNetwork \
--subnet Private \
--generate-ssh-keys
The VM takes a few minutes to create. After creation, take note of the publicIpAddress in the output returned. This
address is used to access the VM from the internet in a later step.
Confirm access to storage account
SSH into the myVmPrivate VM. Replace <publicIpAddress> with the public IP address of your myVmPrivate VM.
ssh <publicIpAddress>
Mount the Azure file share to the directory you created. Before executing the command below, replace <storage-
account-key> with value of AccountKey from $saConnectionString1 .
You receive the user@myVmPrivate:~$ prompt. The Azure file share successfully mounted to /mnt/MyAzureFileShare.
Confirm access is denied to storage account
From the same VM myVmPrivate, create a directory for a mount point:
Attempt to mount the Azure file share from storage account notallowedstorageacc to the directory you created.
This article assumes you deployed the latest version of Ubuntu. If you are using earlier versions of Ubuntu, see
Mount on Linux for additional instructions about mounting file shares.
Before executing the command below, replace <storage-account-key> with value of AccountKey from
$saConnectionString2 .
Access is denied, and you receive a mount error(13): Permission denied error, because this storage account is not in
the allow list of the service endpoint policy we applied to the subnet.
Exit the SSH session to the myVmPublic VM.
Clean up resources
When no longer needed, use az group delete to remove the resource group and all of the resources it contains.
Next steps
In this article, you applied a service endpoint policy over an Azure virtual network service endpoint to Azure
Storage. You created Azure Storage accounts and limited network access to only certain storage accounts (and thus
denied others) from a virtual network subnet. To learn more about service endpoint policies, see Service endpoints
policies overview.
Create, change, or delete a network security group
11/2/2020 • 15 minutes to read • Edit Online
Security rules in network security groups enable you to filter the type of network traffic that can flow in and out
of virtual network subnets and network interfaces. To learn more about network security groups, see Network
security group overview. Next, complete the Filter network traffic tutorial to gain some experience with network
security groups.
If you don't have one, set up an Azure account with an active subscription. Create an account for free. Complete
one of these tasks before starting the remainder of this article:
Por tal users : Sign in to the Azure portal with your Azure account.
PowerShell users : Either run the commands in the Azure Cloud Shell, or run PowerShell from your
computer. The Azure Cloud Shell is a free interactive shell that you can use to run the steps in this article. It
has common Azure tools preinstalled and configured to use with your account. In the Azure Cloud Shell
browser tab, find the Select environment dropdown list, then pick PowerShell if it isn't already
selected.
If you're running PowerShell locally, use Azure PowerShell module version 1.0.0 or later. Run
Get-Module -ListAvailable Az.Network to find the installed version. If you need to upgrade, see Install
Azure PowerShell module. Run Connect-AzAccount to create a connection with Azure.
Azure Command-line interface (CLI) users : Either run the commands in the Azure Cloud Shell, or run
the CLI from your computer. Use Azure CLI version 2.0.28 or later if you're running the Azure CLI locally.
Run az --version to find the installed version. If you need to install or upgrade, see Install Azure CLI. Run
az login to create a connection with Azure.
The account you log into, or connect to Azure with must be assigned to the Network contributor role or to a
Custom role that's assigned the appropriate actions listed in Permissions.
SET T IN G A C T IO N
TO O L C OMMAND
PowerShell New-AzNetworkSecurityGroup
TO O L C OMMAND
PowerShell Get-AzNetworkSecurityGroup
TO O L C OMMAND
PowerShell Get-AzNetworkSecurityGroup
TO O L C OMMAND
PowerShell Set-AzNetworkSecurityGroup
TO O L C OMMAND
PowerShell Remove-AzNetworkSecurityGroup
SET T IN G VA L UE DETA IL S
Source ser vice tag A service tag from the dropdown list This optional setting appears if you
set Source to Ser vice Tag for an
inbound security rule. A service tag
is a predefined identifier for a
category of IP addresses. To learn
more about available service tags,
and what each tag represents, see
Service tags.
Source application security An existing application security This setting appears if you set
group group Source to Application security
group . Select an application security
group that exists in the same region
as the network interface. Learn how
to create an application security
group.
Source por t ranges One of: This setting specifies the ports on
A single port, such as 80 which the rule allows or denies
A range of ports, such as traffic. There are limits to the
1024-65535 number of ports you can specify. For
more details, see Azure limits.
A comma-separated list of
single ports and/or port
ranges, such as
80, 1024-65535
An asterisk ( * ) to allow
traffic on any port
SET T IN G VA L UE DETA IL S
Destination ser vice tag A service tag from the dropdown list This optional setting appears if you
change Destination to Ser vice
Tag for an outbound security rule. A
service tag is a predefined identifier
for a category of IP addresses. To
learn more about available service
tags, and what each tag represents,
see Service tags.
Destination application security An existing application security This setting appears if you set
group group Destination to Application
security group . Select an
application security group that exists
in the same region as the network
interface. Learn how to create an
application security group.
SET T IN G VA L UE DETA IL S
Destination por t ranges One of: As with Source por t ranges , you
A single port, such as 80 can specify single or multiple ports
A range of ports, such as and ranges. There are limits to the
1024-65535 number you can specify. For more
details, see Azure limits.
A comma-separated list of
single ports and/or port
ranges, such as
80, 1024-65535
An asterisk ( * ) to allow
traffic on any port
Protocol Any , TCP , UDP , or ICMP You may restrict the rule to the
Transmission Control Protocol (TCP),
User Datagram Protocol (UDP), or
Internet Control Message Protocol
(ICMP). The default is for the rule to
apply to all protocols.
Priority A value between 100 and 4096 Azure processes security rules in
that's unique for all security rules priority order. The lower the number,
within the network security group the higher the priority. We
recommend that you leave a gap
between priority numbers when you
create rules, such as 100, 200, and
300. Leaving gaps makes it easier to
add rules in the future, so that you
can give them higher or lower
priority than existing rules.
Name A unique name for the rule within The name can be up to 80
the network security group characters. It must begin with a
letter or number, and it must end
with a letter, number, or underscore.
The name may contain only letters,
numbers, underscores, periods, or
hyphens.
Commands
TO O L C OMMAND
PowerShell New-AzNetworkSecurityRuleConfig
TO O L C OMMAND
PowerShell Get-AzNetworkSecurityRuleConfig
NOTE
This procedure only applies to a custom security rule. It doesn't work if you choose a default security rule.
Commands
TO O L C OMMAND
PowerShell Get-AzNetworkSecurityRuleConfig
Commands
TO O L C OMMAND
PowerShell Set-AzNetworkSecurityRuleConfig
NOTE
This procedure only applies to a custom security rule. You aren't allowed to delete a default security rule.
Commands
TO O L C OMMAND
PowerShell Remove-AzNetworkSecurityRuleConfig
SET T IN G A C T IO N
TO O L C OMMAND
PowerShell New-AzApplicationSecurityGroup
TO O L C OMMAND
PowerShell Get-AzApplicationSecurityGroup
TO O L C OMMAND
PowerShell Get-AzApplicationSecurityGroup
NOTE
You can't change the location.
In the menu bar, you can also select Access control (IAM) . In the Access control (IAM) page, you can
assign or remove permissions to the application security group.
Commands
TO O L C OMMAND
TO O L C OMMAND
PowerShell Remove-AzApplicationSecurityGroup
Permissions
To do tasks on network security groups, security rules, and application security groups, your account must be
assigned to the Network contributor role or to a Custom role that's assigned the appropriate permissions as
listed in the following tables:
Network security group
A C T IO N NAME
Next steps
Create a network or application security group using PowerShell or Azure CLI sample scripts, or Azure
Resource Manager templates
Create and assign Azure Policy definitions for virtual networks
Virtual appliance scenario
11/2/2020 • 8 minutes to read • Edit Online
A common scenario among larger Azure customer is the need to provide a two-tiered application exposed to the
Internet, while allowing access to the back tier from an on-premises datacenter. This document will walk you
through a scenario using User Defined Routes (UDR), a VPN Gateway, and network virtual appliances to deploy a
two-tier environment that meets the following requirements:
Web application must be accessible from the public Internet only.
Web server hosting the application must be able to access a backend application server.
All traffic from the Internet to the web application must go through a firewall virtual appliance. This virtual
appliance will be used for Internet traffic only.
All traffic going to the application server must go through a firewall virtual appliance. This virtual appliance will
be used for access to the backend end server, and access coming in from the on-premises network via a VPN
Gateway.
Administrators must be able to manage the firewall virtual appliances from their on-premises computers, by
using a third firewall virtual appliance used exclusively for management purposes.
This is a standard perimeter network (also knowns as DMZ) scenario with a DMZ and a protected network. Such
scenario can be constructed in Azure by using NSGs,firewall virtual appliances, or a combination of both. The table
below shows some of the pros and cons between NSGs and firewall virtual appliances.
P RO S C ONS
The solution below uses firewall virtual appliances to implement a perimeter network (DMZ)/protected network
scenario.
Considerations
You can deploy the environment explained above in Azure using different features available today, as follows.
Vir tual network (VNet) . An Azure VNet acts in similar fashion to an on-premises network, and can be
segmented into one or more subnets to provide traffic isolation, and separation of concerns.
Vir tual appliance . Several partners provide virtual appliances in the Azure Marketplace that can be used for
the three firewalls described above.
User Defined Routes (UDR) . Route tables can contain UDRs used by Azure networking to control the flow of
packets within a VNet. These route tables can be applied to subnets. One of the newest features in Azure is the
ability to apply a route table to the GatewaySubnet, providing the ability to forward all traffic coming into the
Azure VNet from a hybrid connection to a virtual appliance.
IP For warding . By default, the Azure networking engine forward packets to virtual network interface cards
(NICs) only if the packet destination IP address matches the NIC IP address. Therefore, if a UDR defines that a
packet must be sent to a given virtual appliance, the Azure networking engine would drop that packet. To ensure
the packet is delivered to a VM (in this case a virtual appliance) that is not the actual destination for the packet,
you need to enable IP Forwarding for the virtual appliance.
Network Security Groups (NSGs) . The example below does not make use of NSGs, but you could use NSGs
applied to the subnets and/or NICs in this solution to further filter the traffic in and out of those subnets and
NICs.
azsn2udr
DEST IN AT IO N N EXT H O P EXP L A N AT IO N
azsn3udr
DEST IN AT IO N N EXT H O P EXP L A N AT IO N
You also need to create route tables for the subnets in onpremvnet to mimic the on-premises datacenter.
onpremsn1udr
DEST IN AT IO N N EXT H O P EXP L A N AT IO N
onpremsn2udr
DEST IN AT IO N N EXT H O P EXP L A N AT IO N
IP Forwarding
UDR and IP Forwarding are features that you can use in combination to allow virtual appliances to be used to
control traffic flow in an Azure VNet. A virtual appliance is nothing more than a VM that runs an application used to
handle network traffic in some way, such as a firewall or a NAT device.
This virtual appliance VM must be able to receive incoming traffic that is not addressed to itself. To allow a VM to
receive traffic addressed to other destinations, you must enable IP Forwarding for the VM. This is an Azure setting,
not a setting in the guest operating system. Your virtual appliance still needs to run some type of application to
handle the incoming traffic, and route it appropriately.
To learn more about IP Forwarding, visit What are User Defined Routes and IP Forwarding.
As an example, imagine you have the following setup in an Azure vnet:
Subnet onpremsn1 contains a VM named onpremvm1 .
Subnet onpremsn2 contains a VM named onpremvm2 .
A virtual appliance named OPFW is connected to onpremsn1 and onpremsn2 .
A user defined route linked to onpremsn1 specifies that all traffic to onpremsn2 must be sent to OPFW .
At this point, if onpremvm1 tries to establish a connection with onpremvm2 , the UDR will be used and traffic will
be sent to OPFW as the next hop. Keep in mind that the actual packet destination is not being changed, it still says
onpremvm2 is the destination.
Without IP Forwarding enabled for OPFW , the Azure virtual networking logic will drop the packets, since it only
allows packets to be sent to a VM if the VM’s IP address is the destination for the packet.
With IP Forwarding, the Azure virtual network logic will forward the packets to OPFW, without changing its original
destination address. OPFW must handle the packets and determine what to do with them.
For the scenario above to work, you must enable IP Forwarding on the NICs for OPFW , AZF1 , AZF2 , and AZF3
that are used for routing (all NICs except the ones linked to the management subnet).
Firewall Rules
As described above, IP Forwarding only ensures packets are sent to the virtual appliances. Your appliance still needs
to decide what to do with those packets. In the scenario above, you will need to create the following rules in your
appliances:
OPFW
OPFW represents an on-premises device containing the following rules:
Route : All traffic to 10.0.0.0/16 (azurevnet ) must be sent through tunnel ONPREMAZURE .
Policy : Allow all bidirectional traffic between por t2 and ONPREMAZURE .
AZF1
AZF1 represents an Azure virtual appliance containing the following rules:
Policy : Allow all bidirectional traffic between por t1 and por t2 .
AZF2
AZF2 represents an Azure virtual appliance containing the following rules:
Route : All traffic to 10.0.0.0/16 (onpremvnet ) must be sent to the Azure gateway IP address (i.e. 10.0.0.1)
through por t1 .
Policy : Allow all bidirectional traffic between por t1 and por t2 .
A public IP address enables you to communicate to a virtual machine from the internet.
Assign a static public IP address, rather than a dynamic address, to ensure that the address never changes.
Sign in to Azure
Sign in to the Azure portal.
SET T IN G VA L UE
Project Details
Instance details
Administrator account
3. Select the Networking tab, or select Next: Disks , then Next: Networking .
4. In the Networking tab, select or enter:
SET T IN G VA L UE
Network interface
WARNING
Portal 3389 is selected, to enable remote access to the Windows Server virtual machine from the internet. Opening
port 3389 to the internet is not recommended to manage production workloads.
For secure access to Azure virtual machines, see What is Azure Bastion?
Clean up resources
When no longer needed, delete the resource group and all of the resources it contains:
1. Enter myResourceGroup in the Search box at the top of the portal. When you see myResourceGroup in the
search results, select it.
2. Select Delete resource group .
3. Enter myResourceGroup for TYPE THE RESOURCE GROUP NAME: and select Delete .
Next steps
See Add, change, or remove IP addresses:
To change a public IP address from dynamic to static.
Work with private IP addresses.
Public IP addresses have a nominal charge. There's a limit to the number of public IP addresses that you can use
per subscription.
The SKU of the virtual machine's public IP address must match the public IP SKU of Azure Load Balancer when
added to a backend pool. For details, see Azure Load Balancer.
You can download the list of ranges (prefixes) for the Azure Public, US government, China, and Germany clouds.
Learn more about static public IP addresses.
Learn more about public IP addresses in Azure.
Learn more about all public IP address settings.
Learn more about private IP addresses and assigning a static private IP address to an Azure virtual machine.
Create a virtual machine with a static public IP
address using PowerShell
11/2/2020 • 3 minutes to read • Edit Online
NOTE
This article has been updated to use the new Azure PowerShell Az module. You can still use the AzureRM module, which will
continue to receive bug fixes until at least December 2020. To learn more about the new Az module and AzureRM
compatibility, see Introducing the new Azure PowerShell Az module. For Az module installation instructions, see Install Azure
PowerShell.
You can create a virtual machine with a static public IP address. A public IP address enables you to communicate to
a virtual machine from the internet. Assign a static public IP address, rather than a dynamic address, to ensure that
the address never changes. Learn more about static public IP addresses. To change a public IP address assigned to
an existing virtual machine from dynamic to static, or to work with private IP addresses, see Add, change, or
remove IP addresses. Public IP addresses have a nominal charge, and there is a limit to the number of public IP
addresses that you can use per subscription.
2. Create a resource group with the New-AzResourceGroup command. The following example creates a
resource group in the East US Azure region:
3. Create a virtual machine with the New-AzVM command. The -AllocationMethod "Static" option assigns a
static public IP address to the virtual machine. The following example creates a Windows Server virtual
machine with a static, basic SKU public IP address named myPublicIpAddress. When prompted, provide a
username and password to be used as the sign in credentials for the virtual machine:
New-AzVm `
-ResourceGroupName "myResourceGroup" `
-Name "myVM" `
-Location "East US" `
-PublicIpAddressName "myPublicIpAddress" `
-AllocationMethod "Static"
If the public IP address must be a standard SKU, you have to create a public IP address, create a network
interface, assign the public IP address to the network interface, and then create a virtual machine with the
network interface, in separate steps. Learn more about Public IP address SKUs. If the virtual machine will be
added to the back-end pool of a public Azure Load Balancer, the SKU of the virtual machine's public IP
address must match the SKU of the load balancer's public IP address. For details, see Azure Load Balancer.
4. View the public IP address assigned and confirm that it was created as a static address, with Get-
AzPublicIpAddress:
Get-AzPublicIpAddress `
-ResourceGroupName "myResourceGroup" `
-Name "myPublicIpAddress" `
| Select "IpAddress", "PublicIpAllocationMethod" `
| Format-Table
Azure assigned a public IP address from addresses used in the region you created the virtual machine in.
You can download the list of ranges (prefixes) for the Azure Public, US government, China, and Germany
clouds.
WARNING
Do not modify the IP address settings within the virtual machine's operating system. The operating system is unaware of
Azure public IP addresses. Though you can add private IP address settings to the operating system, we recommend not
doing so unless necessary, and not until after reading Add a private IP address to an operating system.
Clean up resources
When no longer needed, you can use Remove-AzResourceGroup to remove the resource group and all of the
resources it contains:
Next steps
Learn more about public IP addresses in Azure
Learn more about all public IP address settings
Learn more about private IP addresses and assigning a static private IP address to an Azure virtual machine
Learn more about creating Linux and Windows virtual machines
Create a virtual machine with a static public IP
address using the Azure CLI
11/2/2020 • 2 minutes to read • Edit Online
You can create a virtual machine with a static public IP address. A public IP address enables you to communicate to
a virtual machine from the internet. Assign a static public IP address, rather than a dynamic address, to ensure that
the address never changes. Learn more about static public IP addresses. To change a public IP address assigned to
an existing virtual machine from dynamic to static, or to work with private IP addresses, see Add, change, or
remove IP addresses. Public IP addresses have a nominal charge, and there is a limit to the number of public IP
addresses that you can use per subscription.
az vm create \
--resource-group myResourceGroup \
--name myVM \
--image UbuntuLTS \
--admin-username azureuser \
--generate-ssh-keys \
--public-ip-address myPublicIpAddress \
--public-ip-address-allocation static
If the public IP address must be a standard SKU, add --public-ip-sku Standard to the previous command.
Learn more about Public IP address SKUs. If the virtual machine will be added to the back-end pool of a
public Azure Load Balancer, the SKU of the virtual machine's public IP address must match the SKU of the
load balancer's public IP address. For details, see Azure Load Balancer.
4. View the public IP address assigned and confirm that it was created as a static, basic SKU address, with az
network public-ip show:
WARNING
Do not modify the IP address settings within the virtual machine's operating system. The operating system is unaware of
Azure public IP addresses. Though you can add private IP address settings to the operating system, we recommend not
doing so unless necessary, and not until after reading Add a private IP address to an operating system.
Clean up resources
When no longer needed, you can use az group delete to remove the resource group and all of the resources it
contains:
Next steps
Learn more about public IP addresses in Azure
Learn more about all public IP address settings
Learn more about private IP addresses and assigning a static private IP address to an Azure virtual machine
Learn more about creating Linux and Windows virtual machines
Associate a public IP address to a virtual machine
11/2/2020 • 10 minutes to read • Edit Online
In this article, you learn how to associate a public IP address to an existing virtual machine (VM). If you want to
connect to a VM from the internet, the VM must have a public IP address associated to it. If you want to create a
new VM with a public IP address, you can do so using the Azure portal, the Azure command-line interface (CLI), or
PowerShell. Public IP addresses have a nominal fee. For details, see pricing. There is a limit to the number of public
IP addresses that you can use per subscription. For details, see limits.
You can use the Azure portal, the Azure command-line interface (CLI), or PowerShell to associate a public IP address
to a VM.
Azure portal
1. Sign in to the Azure portal.
2. Browse to, or search for the virtual machine that you want to add the public IP address to and then select it.
3. Under Settings , select Networking , and then select the network interface you want to add the public IP
address to, as shown in the following picture:
NOTE
Public IP addresses are associated to network interfaces attached to a VM. In the previous picture, the VM only has
one network interface. If the VM had multiple network interfaces, they would all appear, and you'd select the network
interface you want to associate the public IP address to.
4. Select IP configurations and then select an IP configuration, as shown in the following picture:
NOTE
Public IP addresses are associated to IP configurations for a network interface. In the previous picture, the network
interface has one IP configuration. If the network interface had multiple IP configurations, they would all appear in the
list, and you'd select the IP configuration that you want to associate the public IP address to.
5. Select Enabled , then select IP address ( Configure required settings ) . Choose an existing public IP
address, which automatically closes the Choose public IP address box. If you don't have any available
public IP addresses listed, you need to create one. To learn how, see Create a public IP address. Select Save ,
as shown in the picture that follows, and then close the box for the IP configuration.
NOTE
The public IP addresses that appear are those that exist in the same region as the VM. If you have multiple public IP
addresses created in the region, all will appear here. If any are grayed out, it's because the address is already
associated to a different resource.
6. View the public IP address assigned to the IP configuration, as shown in the picture that follows. It may take
a few seconds for an IP address to appear.
NOTE
The address is assigned from a pool of addresses used in each Azure region. To see a list of address pools used in
each region, see Microsoft Azure Datacenter IP Ranges. The address assigned can be any address in the pools used
for the region. If you need the address to be assigned from a specific pool in the region, use a Public IP address prefix.
7. Allow network traffic to the VM with security rules in a network security group.
Azure CLI
Install the Azure CLI, or use the Azure Cloud Shell. The Azure Cloud Shell is a free Bash shell that you can run
directly within the Azure portal. It has the Azure CLI preinstalled and configured to use with your account. Select the
Tr y it button in the CLI commands that follow. Selecting Tr y it invokes a Cloud Shell that you can sign in to your
Azure account with.
1. If using the CLI locally in Bash, sign in to Azure with az login .
2. A public IP address is associated to an IP configuration of a network interface attached to a VM. Use the az
network nic-ip-config update command to associate a public IP address to an IP configuration. The following
example associates an existing public IP address named myVMPublicIP to the IP configuration named
ipconfigmyVM of an existing network interface named myVMVMNic that exists in a resource group named
myResourceGroup.
If you don't have an existing public IP address, use the az network public-ip create command to create
one. For example, the following command creates a public IP address named myVMPublicIP in a
resource group named myResourceGroup.
If you don't know the name of a network interface attached to your VM, use the az vm nic list
command to view them. For example, the following command lists the names of the network
interfaces attached to a VM named myVM in a resource group named myResourceGroup:
The output includes one or more lines that are similar to the following example:
"id": "/subscriptions/00000000-0000-0000-0000-
000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/myVMVMN
ic",
az network nic ip-config list --nic-name myVMVMNic --resource-group myResourceGroup --out table
3. View the public IP address assigned to the IP configuration with the az vm list-ip-addresses command. The
following example shows the IP addresses assigned to an existing VM named myVM in a resource group
named myResourceGroup.
NOTE
The address is assigned from a pool of addresses used in each Azure region. To see a list of address pools used in
each region, see Microsoft Azure Datacenter IP Ranges. The address assigned can be any address in the pools used
for the region. If you need the address to be assigned from a specific pool in the region, use a Public IP address prefix.
4. Allow network traffic to the VM with security rules in a network security group.
PowerShell
Install PowerShell, or use the Azure Cloud Shell. The Azure Cloud Shell is a free shell that you can run directly
within the Azure portal. It has PowerShell preinstalled and configured to use with your account. Select the Tr y it
button in the PowerShell commands that follow. Selecting Tr y it invokes a Cloud Shell that you can sign in to your
Azure account with.
1. If using PowerShell locally, sign in to Azure with Connect-AzAccount .
2. A public IP address is associated to an IP configuration of a network interface attached to a VM. Use the Get-
AzVirtualNetwork and Get-AzVirtualNetworkSubnetConfig commands to get the virtual network and subnet
that the network interface is in. Next, use the Get-AzNetworkInterface command to get a network interface
and the Get-AzPublicIpAddress command to get an existing public IP address. Then use the Set-
AzNetworkInterfaceIpConfig command to associate the public IP address to the IP configuration and the Set-
AzNetworkInterface command to write the new IP configuration to the network interface.
The following example associates an existing public IP address named myVMPublicIP to the IP configuration
named ipconfigmyVM of an existing network interface named myVMVMNic that exists in a subnet named
myVMSubnet in a virtual network named myVMVNet. All resources are in a resource group named
myResourceGroup.
If you don't have an existing public IP address, use the New-AzPublicIpAddress command to create
one. For example, the following command creates a dynamic public IP address named myVMPublicIP
in a resource group named myResourceGroup in the eastus region.
NOTE
The previous command creates a public IP address with default values for several settings that you may want
to customize. To learn more about all public IP address settings, see Create a public IP address. The address is
assigned from a pool of public IP addresses used for each Azure region. To see a list of address pools used in
each region, see Microsoft Azure Datacenter IP Ranges.
If you don't know the name of a network interface attached to your VM, use the Get-AzVM command
to view them. For example, the following command lists the names of the network interfaces attached
to a VM named myVM in a resource group named myResourceGroup:
The output includes one or more lines that are similar to the example that follows. In the example
output, myVMVMNic is the name of the network interface.
"id": "/subscriptions/00000000-0000-0000-0000-
000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/myVMVMN
ic",
If you don't know the name of the virtual network or subnet that the network interface is in, use the
Get-AzNetworkInterface command to view the information. For example, the following command
gets the virtual network and subnet information for a network interface named myVMVMNic in a
resource group named myResourceGroup:
$nic = Get-AzNetworkInterface -Name myVMVMNic -ResourceGroupName myResourceGroup
$ipConfigs = $nic.IpConfigurations
$ipConfigs.Subnet | Select Id
The output includes one or more lines that are similar to the example that follows. In the example
output, myVMVNET is the name of the virtual network and myVMSubnet is the name of the subnet.
"/subscriptions/00000000-0000-0000-0000-
000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVMVNET/
subnets/myVMSubnet",
If you don't know the name of an IP configuration for a network interface, use the Get-
AzNetworkInterface command to retrieve them. For example, the following command lists the names
of the IP configurations for a network interface named myVMVMNic in a resource group named
myResourceGroup:
The output includes one or more lines that are similar to the example that follows. In the example
output, ipconfigmyVM is the name of an IP configuration.
Id : /subscriptions/00000000-0000-0000-0000-
000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/myVMVMN
ic/ipConfigurations/ipconfigmyVM
3. View the public IP address assigned to the IP configuration with the Get-AzPublicIpAddress command. The
following example shows the address assigned to a public IP address named myVMPublicIP in a resource
group named myResourceGroup.
If you don't know the name of the public IP address assigned to an IP configuration, run the following
commands to get it:
The output includes one or more lines that are similar to the example that follows. In the example output,
myVMPublicIP is the name of the public IP address assigned to the IP configuration.
"/subscriptions/00000000-0000-0000-0000-
000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/publicIPAddresses/myVMPublicIP"
NOTE
The address is assigned from a pool of addresses used in each Azure region. To see a list of address pools used in
each region, see Microsoft Azure Datacenter IP Ranges. The address assigned can be any address in the pools used
for the region. If you need the address to be assigned from a specific pool in the region, use a Public IP address prefix.
4. Allow network traffic to the VM with security rules in a network security group.
Next steps
Allow inbound internet traffic to your VM with a network security group. To learn how to create a network security
group, see Work with network security groups. To learn more about network security groups, see Security groups.
Dissociate a public IP address from an Azure VM
11/2/2020 • 4 minutes to read • Edit Online
In this article, you learn how to dissociate a public IP address from an Azure virtual machine (VM).
You can use the Azure portal, the Azure command-line interface (CLI), or PowerShell to dissociate a public IP
address from a VM.
Azure portal
1. Sign in to the Azure portal.
2. Browse to, or search for the virtual machine that you want to disassociate the public IP address from and
then select it.
3. In the VM page, select Over view , select the public IP address as shown in the following picture:
4. In the public IP address page, select Over view , and then select Dissociate , as shown in the following
picture:
Azure CLI
Install the Azure CLI, or use the Azure Cloud Shell. The Azure Cloud Shell is a free Bash shell that you can run
directly within the Azure portal. It has the Azure CLI preinstalled and configured to use with your account. Select the
Tr y it button in the CLI commands that follow. Selecting Tr y it invokes a Cloud Shell that you can sign in to your
Azure account with.
1. If using the CLI locally in Bash, sign in to Azure with az login .
2. A public IP address is associated to an IP configuration of a network interface attached to a VM. Use the az
network nic-ip-config update command to dissociate a public IP address from an IP configuration. The
following example dissociates a public IP address named myVMPublicIP from the IP configuration named
ipconfigmyVM of an existing network interface named myVMVMNic that is attached to a VM named myVM
in a resource group named myResourceGroup.
If you don't know the name of a network interface attached to your VM, use the az vm nic list command to
view them. For example, the following command lists the names of the network interfaces attached to a VM
named myVM in a resource group named myResourceGroup:
The output includes one or more lines that are similar to the following example:
"id": "/subscriptions/00000000-0000-0000-0000-
000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/myVMVMNic",
az network nic ip-config list --nic-name myVMVMNic --resource-group myResourceGroup --out table
If you don't know the name of a public IP configuration for a network interface, use the az network nic
ip-config show command to retrieve them. For example, the following command lists the names of
the public IP configurations for a network interface named myVMVMNic in a resource group named
myResourceGroup:
PowerShell
Install PowerShell, or use the Azure Cloud Shell. The Azure Cloud Shell is a free shell that you can run directly within
the Azure portal. It has PowerShell preinstalled and configured to use with your account. Select the Tr y it button in
the PowerShell commands that follow. Selecting Tr y it invokes a Cloud Shell that you can sign in to your Azure
account with.
1. If using PowerShell locally, sign in to Azure with Connect-AzAccount .
2. A public IP address is associated to an IP configuration of a network interface attached to a VM. Use the Get-
AzNetworkInterface command to get a network interface. Set the Public IP address value to null and then use
the Set-AzNetworkInterface command to write the new IP configuration to the network interface.
The following example dissociates a public IP address named myVMPublicIP from a network interface
named myVMVMNic that is attached to a VM named myVM. All resources are in a resource group named
myResourceGroup.
If you don't know the name of a network interface attached to your VM, use the Get-AzVM command to view
them. For example, the following command lists the names of the network interfaces attached to a VM
named myVM in a resource group named myResourceGroup:
The output includes one or more lines that are similar to the example that follows. In the example output,
myVMVMNic is the name of the network interface.
"id": "/subscriptions/00000000-0000-0000-0000-
000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/myVMVMNic",
If you don't know the name of an IP configuration for a network interface, use the Get-AzNetworkInterface
command to retrieve them. For example, the following command lists the names of the IP configurations for
a network interface named myVMVMNic in a resource group named myResourceGroup:
The output includes one or more lines that are similar to the example that follows. In the example output,
ipconfigmyVM is the name of an IP configuration.
"id": "/subscriptions/00000000-0000-0000-0000-
000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/myVMVMNic/ipCo
nfigurations/ipconfigmyVM"
Next steps
Learn how to associate a public IP address to a VM.
Configure a private IP address for a VM using the
Azure portal
11/2/2020 • 3 minutes to read • Edit Online
A virtual machine (VM) is automatically assigned a private IP address from a range that you specify, based on the
subnet in which the VM is deployed. The VM retains the address until the VM is deleted. Azure dynamically assigns
the next available private IP address from the subnet you create a VM in. If you want a specific IP address from the
subnet assigned to the VM, assign a static IP address.
Scenario
To better illustrate how to configure a static IP address for a VM, this document uses this scenario:
In this scenario, you create a VM named DNS01 in the FrontEnd subnet, and then set it to use a static IP address of
192.168.1.101.
The following sample steps expect a simple environment to already be created. If you want to run the steps as
they're displayed in this document, first create a virtual network. However, in step 3, use these values instead:
SET T IN G VA L UE
Name TestVNet
Resource group TestRG (if necessary, select Create new to create it)
IT EM VA L UE
IT EM VA L UE
Subnet FrontEnd
5. In Management , under Diagnostics storage account , choose vnetstorage . If that storage account
doesn't appear in the list, select Create new , specify a Name of vnetstorage, and select OK . Finally, select
Review + create .
6. In Review + create , review the overview information, and then select Create .
The following message appears once the VM is created.
Retrieve private IP address information for a VM
To view the private IP address information for your new VM:
1. Go to the Azure portal to find your VM. Search for and select Vir tual machines .
5. In Private IP address settings , under the TestVNet/FrontEnd virtual network/subnet, note the
Assignment value (Dynamic or Static ) and the IP address .
Add a static private IP address to an existing VM
To add a static private IP address to your new VM:
1. In the IP configuration page, set the assignment for your private IP address to Static .
2. Change your private IP address to 192.168.1.101, and then select Save .
NOTE
If you notice after selecting Save that the assignment is still set to Dynamic, the IP address you typed is already in use. Try
another IP address.
Next steps
Learn about managing IP address settings.
Create a virtual machine with a static private IP
address using PowerShell
11/2/2020 • 3 minutes to read • Edit Online
NOTE
This article has been updated to use the new Azure PowerShell Az module. You can still use the AzureRM module, which will
continue to receive bug fixes until at least December 2020. To learn more about the new Az module and AzureRM
compatibility, see Introducing the new Azure PowerShell Az module. For Az module installation instructions, see Install Azure
PowerShell.
You can create a virtual machine (VM) with a static private IP address. Assign a static private IP address, rather than
a dynamic address, if you want to select which address from a subnet is assigned to a VM. Learn more about static
private IP addresses. To change a private IP address assigned to an existing VM from dynamic to static, or to work
with public IP addresses, see Add, change, or remove IP addresses.
2. Create a resource group with the New-AzResourceGroup command. The following example creates a
resource group in the East US Azure region:
$RgName = "myResourceGroup"
$Location = "eastus"
New-AzResourceGroup -Name $RgName -Location $Location
3. Create a subnet configuration and virtual network with the New-AzVirtualNetworkSubnetConfig and New-
AzVirtualNetwork commands:
$IpConfigName1 = "IPConfig-1"
$IpConfig1 = New-AzNetworkInterfaceIpConfig `
-Name $IpConfigName1 `
-Subnet $Subnet `
-PrivateIpAddress 10.0.0.4 `
-Primary
$NIC = New-AzNetworkInterface `
-Name MyNIC `
-ResourceGroupName $RgName `
-Location $Location `
-IpConfiguration $IpConfig1
5. Create a VM configuration with New-AzVMConfig, and then create the VM with New-AzVM. When
prompted, provide a username and password to be used as the sign in credentials for the VM:
WARNING
Though you can add private IP address settings to the operating system, we recommend not doing so until after reading
Add a private IP address to an operating system.
IMPORTANT
To access the VM from the internet, you must assign a public IP address to the VM. You can also change a dynamic private IP
address assignment to a static assignment. For details, see Add or change IP addresses. Additionally, it's recommended that
you limit the network traffic to your VM by associating a network security group to the network interface, the subnet you
created the network interface in, or both. For details, see Manage network security groups.
Clean up resources
When no longer needed, you can use Remove-AzResourceGroup to remove the resource group and all of the
resources it contains:
Next steps
Learn more about private IP addresses and assigning a static private IP address to an Azure virtual machine.
Learn more about creating Linux and Windows virtual machines.
Configure private IP addresses for a virtual machine
using the Azure CLI
11/2/2020 • 4 minutes to read • Edit Online
A virtual machine (VM) is automatically assigned a private IP address from a range that you specify, based on the
subnet in which the VM is deployed. The VM retains the address until the VM is deleted. Azure dynamically assigns
the next available private IP address from the subnet you create a VM in. If you want a specific IP address from the
subnet assigned to the VM, assign a static IP address.
Scenario
To better illustrate how to configure a static IP address for a VM, this document uses this scenario:
In this scenario, you create a VM named DNS01 in the FrontEnd subnet, and then set it to use a static IP address of
192.168.1.101.
NOTE
The following sample Azure CLI commands expect an existing simple environment. If you want to run the commands as they
are displayed in this document, first build the test environment described in create a vnet.
Expected output:
{
"newNIC": {
"dnsSettings": {
"appliedDnsServers": [],
"dnsServers": []
},
"enableIPForwarding": false,
"ipConfigurations": [
{
"etag": "W/\"<guid>\"",
"id":
"/subscriptions/<guid>/resourceGroups/TestRG/providers/Microsoft.Network/networkInterfaces/TestNIC/ipCon
figurations/ipconfig1",
"name": "ipconfig1",
"properties": {
"primary": true,
"privateIPAddress": "192.168.1.101",
"privateIPAllocationMethod": "Static",
"provisioningState": "Succeeded",
"subnet": {
"id":
"/subscriptions/<guid>/resourceGroups/TestRG/providers/Microsoft.Network/virtualNetworks/TestVNet/subnet
s/FrontEnd",
"resourceGroup": "TestRG"
}
},
"resourceGroup": "TestRG"
}
],
"provisioningState": "Succeeded",
"resourceGuid": "<guid>"
}
}
Parameters:
--private-ip-address : Static private IP address for the NIC.
--vnet-name : Name of the VNet in which to create the NIC.
--subnet : Name of the subnet in which to create the NIC.
3. Run the azure vm create command to create the VM using the public IP and NIC created previously. The list
shown after the output explains the parameters used.
az vm create \
--resource-group TestRG \
--name DNS01 \
--location centralus \
--image Debian \
--admin-username adminuser \
--ssh-key-value ~/.ssh/id_rsa.pub \
--nics TestNIC
Expected output:
{
"fqdns": "",
"id":
"/subscriptions/<guid>/resourceGroups/TestRG/providers/Microsoft.Compute/virtualMachines/DNS01",
"location": "centralus",
"macAddress": "00-0D-3A-92-C1-66",
"powerState": "VM running",
"privateIpAddress": "192.168.1.101",
"publicIpAddress": "",
"resourceGroup": "TestRG"
}
It’s recommended that you do not statically assign the private IP assigned to the Azure virtual machine within the
operating system of a VM, unless necessary, such as when assigning multiple IP addresses to a Windows VM. If you
do manually set the private IP address within the operating system, ensure that it is the same address as the private
IP address assigned to the Azure network interface, or you can lose connectivity to the virtual machine. Learn more
about private IP address settings.
Expected output:
"192.168.1.101"
To display the specific IP information of the NIC for that VM, query the NIC specifically:
{
"IPVer": "IPv4",
"IpAllocMethod": "Static",
"PrivateAddress": "192.168.1.101",
"PublicAddress": null
}
Expected output:
{
"newNIC": {
"dnsSettings": {
"appliedDnsServers": [],
"dnsServers": []
},
"enableIPForwarding": false,
"ipConfigurations": [
{
"etag": "W/\"<guid>\"",
"id":
"/subscriptions/<guid>/resourceGroups/TestRG/providers/Microsoft.Network/networkInterfaces/TestNIC2/ipCo
nfigurations/ipconfig1",
"name": "ipconfig1",
"properties": {
"primary": true,
"privateIPAddress": "192.168.1.4",
"privateIPAllocationMethod": "Dynamic",
"provisioningState": "Succeeded",
"subnet": {
"id":
"/subscriptions/<guid>/resourceGroups/TestRG/providers/Microsoft.Network/virtualNetworks/TestVNet/subnet
s/FrontEnd",
"resourceGroup": "TestRG"
}
},
"resourceGroup": "TestRG"
}
],
"provisioningState": "Succeeded",
"resourceGuid": "0808a61c-476f-4d08-98ee-0fa83671b010"
}
}
2. Run the azure vm set command to change the NIC used by the VM.
Expected output:
[
{
"id": "/subscriptions/0e220bf6-5caa-4e9f-8383-
51f16b6c109f/resourceGroups/TestRG/providers/Microsoft.Network/networkInterfaces/TestNIC3",
"primary": true,
"resourceGroup": "TestRG"
}
]
NOTE
If the VM is large enough to have more than one NIC, run the azure network nic delete command to delete the
old NIC.
Next steps
Learn about managing IP address settings.
Configure private IP addresses for a virtual machine
(Classic) using the Azure portal
11/2/2020 • 3 minutes to read • Edit Online
A virtual machine (VM) is automatically assigned a private IP address from a range that you specify, based on the
subnet in which the VM is deployed. The VM retains the address until the VM is deleted. Azure dynamically assigns
the next available private IP address from the subnet you create a VM in. If you want a specific IP address from the
subnet assigned to the VM, assign a static IP address.
IMPORTANT
Azure currently has two deployment models: Azure Resource Manager and classic. Make sure you understand deployment
models and tools before you work with any Azure resource. To view the documentation for different tools, select the tabs at
the beginning of this article.
This article covers the classic deployment model. You can also manage a static private IP address in the Resource
Manager deployment model.
Scenario
To better illustrate how to configure a static IP address for a VM, this document uses this scenario:
In this scenario, you create a VM named DNS01 in the FrontEnd subnet, and then set it to use a static IP address of
192.168.1.101.
The sample steps that follow expect a simple environment already created. If you want to run the steps as they are
displayed in this document, first build the test environment described in create a vnet.
3. Under Create VM , enter the name of the VM to be created (DNS01 in the scenario), the local administrator
account, and password.
4. Select Optional Configuration > Network > Vir tual Network , and then select TestVNet . If TestVNet is
not available, make sure you are using the Central US location and have created the test environment
described at the beginning of this article.
5. Under Network , make sure the subnet currently selected is FrontEnd, then select IP addresses , under IP
address assignment select Static , and then enter 192.168.1.101 for IP Address as seen below.
6. Select OK under IP addresses , select OK under Network , and then select OK under Optional config .
7. Under Create VM , select Create . Notice the tile below displayed in your dashboard:
Next steps
Learn about reserved public IP addresses.
Learn about instance-level public IP (ILPIP) addresses.
Consult the Reserved IP REST APIs.
Configure private IP addresses for a virtual machine
(Classic) using PowerShell
11/2/2020 • 3 minutes to read • Edit Online
A virtual machine (VM) is automatically assigned a private IP address from a range that you specify, based on the
subnet in which the VM is deployed. The VM retains the address until the VM is deleted. Azure dynamically assigns
the next available private IP address from the subnet you create a VM in. If you want a specific IP address from the
subnet assigned to the VM, assign a static IP address.
IMPORTANT
Azure currently has two deployment models: Azure Resource Manager and classic. Make sure you understand deployment
models and tools before you work with any Azure resource. To view the documentation for different tools, select the tabs at
the beginning of this article.
This article covers the classic deployment model. You can also manage a static private IP address in the Resource
Manager deployment model.
Scenario
To better illustrate how to configure a static IP address for a VM, this document uses this scenario:
In this scenario, you create a VM named DNS01 in the FrontEnd subnet, and then set it to use a static IP address of
192.168.1.101.
The sample PowerShell commands below expect a simple environment already created. If you want to run the
commands as they are displayed in this document, first build the test environment described in Create a VNet.
IsAvailable : True
AvailableAddresses : {}
OperationDescription : Test-AzureStaticVNetIP
OperationId : fd3097e1-5f4b-9cac-8afa-bba1e3492609
OperationStatus : Succeeded
Expected output:
Expected output:
DeploymentName : TestService
Name : DNS01
Label :
VM : Microsoft.WindowsAzure.Commands.ServiceManagement.Model.PersistentVM
InstanceStatus : Provisioning
IpAddress : 192.168.1.7
InstanceStateDetails : Windows is preparing your computer for first use...
PowerState : Started
InstanceErrorCode :
InstanceFaultDomain : 0
InstanceName : DNS01
InstanceUpgradeDomain : 0
InstanceSize : Small
HostName : rsR2-797
AvailabilitySetName :
DNSName : http://testservice000.cloudapp.net/
Status : Provisioning
GuestAgentStatus : Microsoft.WindowsAzure.Commands.ServiceManagement.Model.GuestAgentStatus
ResourceExtensionStatusList : {Microsoft.Compute.BGInfo}
PublicIPAddress :
PublicIPName :
NetworkInterfaces : {}
ServiceName : TestService
OperationDescription : Get-AzureVM
OperationId : 34c1560a62f0901ab75cde4fed8e8bd1
OperationStatus : OK
Expected output:
Expected output:
Next steps
Learn about reserved public IP addresses.
Learn about instance-level public IP (ILPIP) addresses.
Consult the Reserved IP REST APIs.
Assign multiple IP addresses to virtual machines
using the Azure portal
11/2/2020 • 16 minutes to read • Edit Online
An Azure Virtual Machine (VM) has one or more network interfaces (NIC) attached to it. Any NIC can have one
or more static or dynamic public and private IP addresses assigned to it. Assigning multiple IP addresses to a
VM enables the following capabilities:
Hosting multiple websites or services with different IP addresses and SSL certificates on a single server.
Serve as a network virtual appliance, such as a firewall or load balancer.
The ability to add any of the private IP addresses for any of the NICs to an Azure Load Balancer back-end
pool. In the past, only the primary IP address for the primary NIC could be added to a back-end pool. To
learn more about how to load balance multiple IP configurations, read the Load balancing multiple IP
configurations article.
Every NIC attached to a VM has one or more IP configurations associated to it. Each configuration is assigned
one static or dynamic private IP address. Each configuration may also have one public IP address resource
associated to it. A public IP address resource has either a dynamic or static public IP address assigned to it. To
learn more about IP addresses in Azure, read the IP addresses in Azure article.
There is a limit to how many private IP addresses can be assigned to a NIC. There is also a limit to how many
public IP addresses that can be used in an Azure subscription. See the Azure limits article for details.
This article explains how to create a virtual machine (VM) through the Azure Resource Manager deployment
model using the Azure portal. Multiple IP addresses cannot be assigned to resources created through the
classic deployment model. To learn more about Azure deployment models, read the Understand deployment
models article.
Scenario
A VM with a single NIC is created and connected to a virtual network. The VM requires three different private IP
addresses and two public IP addresses. The IP addresses are assigned to the following IP configurations:
IPConfig-1: Assigns a static private IP address and a static public IP address.
IPConfig-2: Assigns a static private IP address and a static public IP address.
IPConfig-3: Assigns a static private IP address and no public IP address.
The IP configurations are associated to the NIC when the NIC is created and the NIC is attached to the VM when
the VM is created. The types of IP addresses used for the scenario are for illustration. You can assign whatever IP
address and assignment types you require.
NOTE
Though the steps in this article assigns all IP configurations to a single NIC, you can also assign multiple IP configurations to
any NIC in a multi-NIC VM. To learn how to create a VM with multiple NICs, read the Create a VM with multiple NICs article.
Add IP addresses to a VM
You can add private and public IP addresses to an Azure network interface by completing the steps that follow. The
examples in the following sections assume that you already have a VM with the three IP configurations described
in the scenario, but it's not required.
Core steps
1. Browse to the Azure portal at https://portal.azure.com and sign into it, if necessary.
2. In the portal, click More ser vices > type virtual machines in the filter box, and then click Vir tual
machines .
3. In the Vir tual machines pane, click the VM you want to add IP addresses to. Navigate to Networking Tab.
Click Network interface on the page. As shown in the picture below:
4. In the Network interface pane, click the IP configurations .
5. In the pane that appears for the NIC you selected, click IP configurations . Click Add , complete the steps in
one of sections that follow, based on the type of IP address you want to add, and then click OK .
Add a private IP address
Complete the following steps to add a new private IP address:
1. Complete the steps in the Core steps section of this article and ensure you are on the IP configurations
section of the VM Network Interface. Review the subnet shown as default (such as 10.0.0.0/24).
2. Click Add . In the Add IP configuration pane that appears, create an IP configuration named IPConfig-4
with a new Static private IP address by picking a new number for the final octet, then click OK . (For the
10.0.0.0/24 subnet, an example IP would be 10.0.0.7.)
NOTE
When adding a static IP address, you must specify an unused, valid address on the subnet the NIC is connected to. If
the address you select is not available, the portal displays an X for the IP address and you must select a different
one.
3. Once you click OK, the pane closes and you see the new IP configuration listed. Click OK to close the Add IP
configuration pane.
4. You can click Add to add additional IP configurations, or close all open blades to finish adding IP addresses.
5. Add the private IP addresses to the VM operating system by completing the steps in the Add IP addresses to
a VM operating system section of this article.
Add a public IP address
A public IP address is added by associating a public IP address resource to either a new IP configuration or an
existing IP configuration.
NOTE
Public IP addresses have a nominal fee. To learn more about IP address pricing, read the IP address pricing page. There is a
limit to the number of public IP addresses that can be used in a subscription. To learn more about the limits, read the Azure
limits article.
4. Complete the steps in one of the sections that follow to associate the public IP address resource to an IP
configuration.
Associate the public IP address resource to a new IP configuration
1. Complete the steps in the Core steps section of this article.
2. Click Add . In the Add IP configuration pane that appears, create an IP configuration named IPConfig-4.
Enable the Public IP address and select an existing, available public IP address resource from the Choose
public IP address pane that appears.
Once you've selected the public IP address resource, click OK and the pane closes. If you don't have an
existing public IP address, you can create one by completing the steps in the Create a public IP address
resource section of this article.
3. Review the new IP configuration. Even though a private IP address wasn't explicitly assigned, one was
automatically assigned to the IP configuration, because all IP configurations must have a private IP address.
4. You can click Add to add additional IP configurations, or close all open blades to finish adding IP addresses.
5. Add the private IP address to the VM operating system by completing the steps for your operating system
in the Add IP addresses to a VM operating system section of this article. Do not add the public IP address to
the operating system.
Associate the public IP address resource to an existing IP configuration
1. Complete the steps in the Core steps section of this article.
2. Click the IP configuration you want to add the public IP address resource to.
3. In the IPConfig pane that appears, click IP address .
4. In the Choose public IP address pane that appears, select a public IP address.
5. Click Save and the panes close. If you don't have an existing public IP address, you can create one by
completing the steps in the Create a public IP address resource section of this article.
6. Review the new IP configuration.
7. You can click Add to add additional IP configurations, or close all open blades to finish adding IP addresses. Do
not add the public IP address to the operating system.
NOTE
This article has been updated to use the new Azure PowerShell Az module. You can still use the AzureRM module, which will
continue to receive bug fixes until at least December 2020. To learn more about the new Az module and AzureRM
compatibility, see Introducing the new Azure PowerShell Az module. For Az module installation instructions, see Install Azure
PowerShell.
An Azure Virtual Machine (VM) has one or more network interfaces (NIC) attached to it. Any NIC can have one or
more static or dynamic public and private IP addresses assigned to it. Assigning multiple IP addresses to a VM
enables the following capabilities:
Hosting multiple websites or services with different IP addresses and SSL certificates on a single server.
Serve as a network virtual appliance, such as a firewall or load balancer.
The ability to add any of the private IP addresses for any of the NICs to an Azure Load Balancer back-end pool.
In the past, only the primary IP address for the primary NIC could be added to a back-end pool. To learn more
about how to load balance multiple IP configurations, read the Load balancing multiple IP configurations
article.
Every NIC attached to a VM has one or more IP configurations associated to it. Each configuration is assigned one
static or dynamic private IP address. Each configuration may also have one public IP address resource associated
to it. A public IP address resource has either a dynamic or static public IP address assigned to it. To learn more
about IP addresses in Azure, read the IP addresses in Azure article.
There is a limit to how many private IP addresses can be assigned to a NIC. There is also a limit to how many
public IP addresses that can be used in an Azure subscription. See the Azure limits article for details.
This article explains how to create a virtual machine (VM) through the Azure Resource Manager deployment
model using PowerShell. Multiple IP addresses cannot be assigned to resources created through the classic
deployment model. To learn more about Azure deployment models, read the Understand deployment models
article.
Scenario
A VM with a single NIC is created and connected to a virtual network. The VM requires three different private IP
addresses and two public IP addresses. The IP addresses are assigned to the following IP configurations:
IPConfig-1: Assigns a static private IP address and a static public IP address.
IPConfig-2: Assigns a static private IP address and a static public IP address.
IPConfig-3: Assigns a static private IP address and no public IP address.
The IP configurations are associated to the NIC when the NIC is created and the NIC is attached to the VM when
the VM is created. The types of IP addresses used for the scenario are for illustration. You can assign whatever IP
address and assignment types you require.
NOTE
Though the steps in this article assigns all IP configurations to a single NIC, you can also assign multiple IP configurations to
any NIC in a multi-NIC VM. To learn how to create a VM with multiple NICs, read the Create a VM with multiple NICs
article.
$RgName = "MyResourceGroup"
$Location = "westus"
New-AzResourceGroup `
-Name $RgName `
-Location $Location
4. Create a virtual network (VNet) and subnet in the same location as the resource group:
# Create a subnet configuration
$SubnetConfig = New-AzVirtualNetworkSubnetConfig `
-Name MySubnet `
-AddressPrefix 10.0.0.0/24
5. Create a network security group (NSG) and a rule. The NSG secures the VM using inbound and outbound
rules. In this case, an inbound rule is created for port 3389, which allows incoming remote desktop
connections.
$NSGRule = New-AzNetworkSecurityRuleConfig `
-Name MyNsgRuleRDP `
-Protocol Tcp `
-Direction Inbound `
-Priority 1000 `
-SourceAddressPrefix * `
-SourcePortRange * `
-DestinationAddressPrefix * `
-DestinationPortRange 3389 -Access Allow
6. Define the primary IP configuration for the NIC. Change 10.0.0.4 to a valid address in the subnet you
created, if you didn't use the value defined previously. Before assigning a static IP address, it's
recommended that you first confirm it's not already in use. Enter the command
Test-AzPrivateIPAddressAvailability -IPAddress 10.0.0.4 -VirtualNetwork $VNet . If the address is available,
the output returns True. If it's not available, the output returns False and a list of addresses that are
available.
In the following commands, Replace <replace-with-your-unique-name> with the unique DNS
name to use. The name must be unique across all public IP addresses within an Azure region. This is an
optional parameter. It can be removed if you only want to connect to the VM using the public IP address.
# Create a public IP address
$PublicIP1 = New-AzPublicIpAddress `
-Name "MyPublicIP1" `
-ResourceGroupName $RgName `
-Location $Location `
-DomainNameLabel <replace-with-your-unique-name> `
-AllocationMethod Static
#Create an IP configuration with a static private IP address and assign the public IP address to it
$IpConfigName1 = "IPConfig-1"
$IpConfig1 = New-AzNetworkInterfaceIpConfig `
-Name $IpConfigName1 `
-Subnet $Subnet `
-PrivateIpAddress 10.0.0.4 `
-PublicIpAddress $PublicIP1 `
-Primary
When you assign multiple IP configurations to a NIC, one configuration must be assigned as the -Primary.
NOTE
Public IP addresses have a nominal fee. To learn more about IP address pricing, read the IP address pricing page.
There is a limit to the number of public IP addresses that can be used in a subscription. To learn more about the
limits, read the Azure limits article.
7. Define the secondary IP configurations for the NIC. You can add or remove configurations as necessary.
Each IP configuration must have a private IP address assigned. Each configuration can optionally have one
public IP address assigned.
#Create an IP configuration with a static private IP address and assign the public IP address to it
$IpConfigName2 = "IPConfig-2"
$IpConfig2 = New-AzNetworkInterfaceIpConfig `
-Name $IpConfigName2 `
-Subnet $Subnet `
-PrivateIpAddress 10.0.0.5 `
-PublicIpAddress $PublicIP2
$IpConfigName3 = "IpConfig-3"
$IpConfig3 = New-AzNetworkInterfaceIpConfig `
-Name $IPConfigName3 `
-Subnet $Subnet `
-PrivateIpAddress 10.0.0.6
$NIC = New-AzNetworkInterface `
-Name MyNIC `
-ResourceGroupName $RgName `
-Location $Location `
-NetworkSecurityGroupId $NSG.Id `
-IpConfiguration $IpConfig1,$IpConfig2,$IpConfig3
NOTE
Though all configurations are assigned to one NIC in this article, you can assign multiple IP configurations to every
NIC attached to the VM. To learn how to create a VM with multiple NICs, read the Create a VM with multiple NICs
article.
# Define a credential object. When you run these commands, you're prompted to enter a username and
password for the VM you're creating.
$cred = Get-Credential
# Create the VM
New-AzVM `
-ResourceGroupName $RgName `
-Location $Location `
-VM $VmConfig
10. Add the private IP addresses to the VM operating system by completing the steps for your operating
system in the Add IP addresses to a VM operating system section of this article. Do not add the public IP
addresses to the operating system.
Add IP addresses to a VM
You can add private and public IP addresses to the Azure network interface by completing the steps that follow.
The examples in the following sections assume that you already have a VM with the three IP configurations
described in the scenario in this article, but it's not required that you do.
1. Open a PowerShell command prompt and complete the remaining steps in this section within a single
PowerShell session. If you don't already have PowerShell installed and configured, complete the steps in
the How to install and configure Azure PowerShell article.
2. Change the "values" of the following $Variables to the name of the NIC you want to add IP address to and
the resource group and location the NIC exists in:
$NicName = "MyNIC"
$RgName = "MyResourceGroup"
$Location = "westus"
If you don't know the name of the NIC you want to change, enter the following commands, then change the
values of the previous variables:
Get-AzNetworkInterface | Format-Table Name, ResourceGroupName, Location
3. Create a variable and set it to the existing NIC by typing the following command:
4. In the following commands, change MyVNet and MySubnet to the names of the VNet and subnet the NIC
is connected to. Enter the commands to retrieve the VNet and subnet objects the NIC is connected to:
If you don't know the VNet or subnet name the NIC is connected to, enter the following command:
$MyNIC.IpConfigurations
In the output, look for text similar to the following example output:
"Id":
"/subscriptions/[Id]/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/MyVNet/
subnets/MySubnet"
In this output, MyVnet is the VNet and MySubnet is the subnet the NIC is connected to.
5. Complete the steps in one of the following sections, based on your requirements:
Add a private IP address
To add a private IP address to a NIC, you must create an IP configuration. The following command creates a
configuration with a static IP address of 10.0.0.7. When specifying a static IP address, it must be an unused
address for the subnet. It's recommended that you first test the address to ensure it's available by entering
the Test-AzPrivateIPAddressAvailability -IPAddress 10.0.0.7 -VirtualNetwork $myVnet command. If the IP
address is available, the output returns True. If it's not available, the output returns False, and a list of
addresses that are available.
Create as many configurations as you require, using unique configuration names and private IP addresses
(for configurations with static IP addresses).
Add the private IP address to the VM operating system by completing the steps for your operating system
in the Add IP addresses to a VM operating system section of this article.
Add a public IP address
A public IP address is added by associating a public IP address resource to either a new IP configuration or
an existing IP configuration. Complete the steps in one of the sections that follow, as you require.
NOTE
Public IP addresses have a nominal fee. To learn more about IP address pricing, read the IP address pricing page.
There is a limit to the number of public IP addresses that can be used in a subscription. To learn more about the
limits, read the Azure limits article.
$myPublicIp3 = New-AzPublicIpAddress `
-Name "myPublicIp3" `
-ResourceGroupName $RgName `
-Location $Location `
-AllocationMethod Static
To create a new IP configuration with a static private IP address and the associated myPublicIp3 public IP
address resource, enter the following command:
Add-AzNetworkInterfaceIpConfig `
-Name IPConfig-4 `
-NetworkInterface $myNIC `
-Subnet $Subnet `
-PrivateIpAddress 10.0.0.7 `
-PublicIpAddress $myPublicIp3
Since the PublicIpAddress column for IpConfig-3 is blank, no public IP address resource is currently
associated to it. You can add an existing public IP address resource to IpConfig-3, or enter the following
command to create one:
$MyPublicIp3 = New-AzPublicIpAddress `
-Name "MyPublicIp3" `
-ResourceGroupName $RgName `
-Location $Location -AllocationMethod Static
Enter the following command to associate the public IP address resource to the existing IP configuration
named IpConfig-3:
Set-AzNetworkInterfaceIpConfig `
-Name IpConfig-3 `
-NetworkInterface $mynic `
-Subnet $Subnet `
-PublicIpAddress $myPublicIp3
6. Set the NIC with the new IP configuration by entering the following command:
7. View the private IP addresses and the public IP address resources assigned to the NIC by entering the
following command:
8. Add the private IP address to the VM operating system by completing the steps for your operating system
in the Add IP addresses to a VM operating system section of this article. Do not add the public IP address to
the operating system.
An Azure Virtual Machine (VM) has one or more network interfaces (NIC) attached to it. Any NIC can have one or
more static or dynamic public and private IP addresses assigned to it. Assigning multiple IP addresses to a VM
enables the following capabilities:
Hosting multiple websites or services with different IP addresses and SSL certificates on a single server.
Serve as a network virtual appliance, such as a firewall or load balancer.
The ability to add any of the private IP addresses for any of the NICs to an Azure Load Balancer back-end pool.
In the past, only the primary IP address for the primary NIC could be added to a back-end pool. To learn more
about how to load balance multiple IP configurations, read the Load balancing multiple IP configurations
article.
Every NIC attached to a VM has one or more IP configurations associated to it. Each configuration is assigned one
static or dynamic private IP address. Each configuration may also have one public IP address resource associated
to it. A public IP address resource has either a dynamic or static public IP address assigned to it. To learn more
about IP addresses in Azure, read the IP addresses in Azure article.
There is a limit to how many private IP addresses can be assigned to a NIC. There is also a limit to how many
public IP addresses that can be used in an Azure subscription. See the Azure limits article for details.
This article explains how to create a virtual machine (VM) through the Azure Resource Manager deployment
model using the Azure CLI. Multiple IP addresses cannot be assigned to resources created through the classic
deployment model. To learn more about Azure deployment models, read the Understand deployment models
article.
Scenario
A VM with a single NIC is created and connected to a virtual network. The VM requires three different private IP
addresses and two public IP addresses. The IP addresses are assigned to the following IP configurations:
IPConfig-1: Assigns a static private IP address and a static public IP address.
IPConfig-2: Assigns a static private IP address and a static public IP address.
IPConfig-3: Assigns a static private IP address and no public IP address.
The IP configurations are associated to the NIC when the NIC is created and the NIC is attached to the VM when
the VM is created. The types of IP addresses used for the scenario are for illustration. You can assign whatever IP
address and assignment types you require.
NOTE
Though the steps in this article assigns all IP configurations to a single NIC, you can also assign multiple IP configurations
to any NIC in a multi-NIC VM. To learn how to create a VM with multiple NICs, read the Create a VM with multiple NICs
article.
#!/bin/sh
RgName="myResourceGroup"
Location="westcentralus"
az group create --name $RgName --location $Location
# Create a public IP address resource with a static IP address using the `--allocation-method Static` option.
If you
# do not specify this option, the address is allocated dynamically. The address is assigned to the resource
from a pool
# of IP addresses unique to each Azure region. Download and view the file from
# https://www.microsoft.com/en-us/download/details.aspx?id=41653 that lists the ranges for each region.
PipName="myPublicIP"
# This name must be unique within an Azure location.
DnsName="myDNSName"
VnetName="myVnet"
VnetPrefix="10.0.0.0/16"
VnetSubnetName="mySubnet"
VnetSubnetPrefix="10.0.0.0/24"
# Create a network interface connected to the subnet and associate the public IP address to it. Azure will
create the
# first IP configuration with a static private IP address and will associate the public IP address resource
to it.
NicName="MyNic1"
az network nic create \
--name $NicName \
--resource-group $RgName \
--location $Location \
--subnet $VnetSubnet1Name \
--private-ip-address 10.0.0.4
--vnet-name $VnetName \
--public-ip-address $PipName
# Create a second public IP address, a second IP configuration, and associate it to the NIC. This
configuration has a
# static public IP address and a static private IP address.
# Create a third IP configuration, and associate it to the NIC. This configuration has static private IP
address and # no public IP address.
# Note: Though this article assigns all IP configurations to a single NIC, you can also assign multiple IP
configurations
configurations
# to any NIC in a VM. To learn how to create a VM with multiple NICs, read the Create a VM with multiple NICs
# article: https://docs.microsoft.com/azure/virtual-network/virtual-network-deploy-multinic-arm-cli.
VmName="myVm"
# Replace the value for the following **VmSize** variable with a value from the
# https://docs.microsoft.com/azure/virtual-machines/sizes article. The script fails if the VM size
# is not supported in the location you select. Run the `azure vm sizes --location eastcentralus` command to
get a full list
# of VMs in US West Central, for example.
VmSize="Standard_DS1"
# Replace the value for the OsImage variable value with a value for *urn* from the output returned by
entering the
# `az vm image list` command.
OsImage="credativ:Debian:8:latest"
Username="adminuser"
# Replace the following value with the path to your public key file. If you're creating a Windows VM, remove
the following
# line and you'll be prompted for the password you want to configure for the VM.
SshKeyValue="~/.ssh/id_rsa.pub"
az vm create \
--name $VmName \
--resource-group $RgName \
--image $OsImage \
--location $Location \
--size $VmSize \
--nics $NicName \
--admin-username $Username \
--ssh-key-value $SshKeyValue
Public IP addresses have a nominal fee. To learn more about IP address pricing, read the IP address pricing page.
There is a limit to the number of public IP addresses that can be used in a subscription. To learn more about the
limits, read the Azure limits article.
After the VM is created, enter the az network nic show --name MyNic1 --resource-group myResourceGroup command
to view the NIC configuration. Enter the
az network nic ip-config list --nic-name MyNic1 --resource-group myResourceGroup --output table to view a list
of the IP configurations associated to the NIC.
Add the private IP addresses to the VM operating system by completing the steps for your operating system in
the Add IP addresses to a VM operating system section of this article.
Add IP addresses to a VM
You can add additional private and public IP addresses to an existing Azure network interface by completing the
steps that follow. The examples build upon the scenario described in this article.
1. Open a command shell and complete the remaining steps in this section within a single session. If you
don't already have Azure CLI installed and configured, complete the steps in the Azure CLI installation
article and login to your Azure account with the az-login command.
2. Complete the steps in one of the following sections, based on your requirements:
Add a private IP address
To add a private IP address to a NIC, you must create an IP configuration using the command that follows.
The static IP address must be an unused address for the subnet.
Create as many configurations as you require, using unique configuration names and private IP addresses
(for configurations with static IP addresses).
Add a public IP address
A public IP address is added by associating it to either a new IP configuration or an existing IP
configuration. Complete the steps in one of the sections that follow, as you require.
Public IP addresses have a nominal fee. To learn more about IP address pricing, read the IP address pricing
page. There is a limit to the number of public IP addresses that can be used in a subscription. To learn more
about the limits, read the Azure limits article.
Associate the resource to a new IP configuration
Whenever you add a public IP address in a new IP configuration, you must also add a private IP
address, because all IP configurations must have a private IP address. You can either add an existing
public IP address resource, or create a new one. To create a new one, enter the following command:
To create a new IP configuration with a static private IP address and the associated myPublicIP3
public IP address resource, enter the following command:
Associate the resource to an existing IP configuration A public IP address resource can only
be associated to an IP configuration that doesn't already have one associated. You can determine
whether an IP configuration has an associated public IP address by entering the following
command:
az network nic ip-config list \
--resource-group myResourceGroup \
--nic-name myNic1 \
--query "[?provisioningState=='Succeeded'].{ Name: name, PublicIpAddressId:
publicIpAddress.id }" --output table
Returned output:
Name PublicIpAddressId
ipconfig1
/subscriptions/[Id]/resourceGroups/myResourceGroup/providers/Microsoft.Network/publicIPAddresse
s/myPublicIP1
IPConfig-2
/subscriptions/[Id]/resourceGroups/myResourceGroup/providers/Microsoft.Network/publicIPAddresse
s/myPublicIP2
IPConfig-3
Since the PublicIpAddressId column for IpConfig-3 is blank in the output, no public IP address
resource is currently associated to it. You can add an existing public IP address resource to IpConfig-
3, or enter the following command to create one:
Enter the following command to associate the public IP address resource to the existing IP
configuration named IPConfig-3:
3. View the private IP addresses and the public IP address resource Ids assigned to the NIC by entering the
following command:
Returned output:
Name PrivateIpAddress PrivateIpAllocationMethod PublicIpAddressId
4. Add the private IP addresses you added to the NIC to the VM operating system by following the
instructions in the Add IP addresses to a VM operating system section of this article. Do not add the public
IP addresses to the operating system.
Learn how to add an existing network interface when you create an Azure virtual machine (VM). Also learn to add
or remove network interfaces from an existing VM in the stopped (deallocated) state. A network interface enables
an Azure VM to communicate with internet, Azure, and on-premises resources. A VM has one or more network
interfaces.
If you need to add, change, or remove IP addresses for a network interface, see Manage network interface IP
addresses. To create, change, or delete network interfaces, see Manage network interfaces.
If you don't have one, set up an Azure account with an active subscription. Create an account for free. Complete
one of these tasks before starting the remainder of this article:
Por tal users : Sign in to the Azure portal with your Azure account.
PowerShell users : Either run the commands in the Azure Cloud Shell, or run PowerShell from your
computer. The Azure Cloud Shell is a free interactive shell that you can use to run the steps in this article. It
has common Azure tools preinstalled and configured to use with your account. In the Azure Cloud Shell
browser tab, find the Select environment dropdown list, then pick PowerShell if it isn't already selected.
If you're running PowerShell locally, use Azure PowerShell module version 1.0.0 or later. Run
Get-Module -ListAvailable Az.Network to find the installed version. If you need to upgrade, see Install Azure
PowerShell module. Run Connect-AzAccount to create a connection with Azure.
Azure Command-line interface (CLI) users : Either run the commands in the Azure Cloud Shell, or run
the CLI from your computer. Use Azure CLI version 2.0.26 or later if you're running the Azure CLI locally.
Run az --version to find the installed version. If you need to install or upgrade, see Install Azure CLI. Run
az login to create a connection with Azure.
TO O L C OMMAND
PowerShell New-AzNetworkInterface
NOTE
The network interface you select can't have accelerated networking enabled, can't have an IPv6 address assigned to
it, and must exist in the same virtual network with the network interface currently attached to the VM.
If you don't have an existing network interface, you must first create one. To do so, select Create network
interface . To learn more about how to create a network interface, see Create a network interface. To learn
more about additional constraints when adding network interfaces to virtual machines, see Constraints.
5. From the VM menu bar, choose Over view > Star t to restart the virtual machine.
Now you can configure the VM operating system to use multiple network interfaces properly. Learn how to
configure Linux or Windows for multiple network interfaces.
Commands
TO O L C OMMAND
2. Select the name of the VM for which you want to view attached network interfaces.
3. In the VM menu bar, select Networking .
To learn about network interface settings and how to change them, see Manage network interfaces. To learn about
how to add, change, or remove IP addresses assigned to a network interface, see Manage network interface IP
addresses.
Commands
TO O L C OMMAND
PowerShell Get-AzVM
NOTE
If only one network interface is listed, you can't detach it, because a virtual machine must always have at least one
network interface attached to it.
Commands
TO O L C OMMAND
Constraints
A VM must have at least one network interface attached to it.
A VM can only have as many network interfaces attached to it as the VM size supports. To learn more about
how many network interfaces each VM size supports, see the sizes in Azure for Linux VMs or Windows
VMs. All sizes support at least two network interfaces.
The network interfaces you add to a VM can't currently be attached to another VM. To learn more about
how to create network interfaces, see Create a network interface.
In the past, you could add network interfaces only to VMs that supported multiple network interfaces and
were created with at least two network interfaces. You couldn't add a network interface to a VM that was
created with one network interface, even if the VM size supported more than one network interface.
Conversely, you could only remove network interfaces from a VM with at least three network interfaces,
because VMs created with at least two network interfaces always had to have at least two network
interfaces. These constraints no longer apply. You can now create a VM with any number of network
interfaces (up to the number supported by the VM size).
By default, the first network interface attached to a VM is the primary network interface. All other network
interfaces in the VM are secondary network interfaces.
You can control which network interface you send outbound traffic to. However, a VM by default sends all
outbound traffic to the IP address that's assigned to the primary IP configuration of the primary network
interface.
In the past, all VMs within the same availability set were required to have a single, or multiple, network
interfaces. VMs with any number of network interfaces can now exist in the same availability set, up to the
number supported by the VM size. You can only add a VM to an availability set when it's created. To learn
more about availability sets, see Manage the availability of VMs in Azure.
You can connect network interfaces in the same VM to different subnets within a virtual network. However,
the network interfaces must all be connected to the same virtual network.
You can add any IP address for any IP configuration of any primary or secondary network interface to an
Azure Load Balancer back-end pool. In the past, only the primary IP address for the primary network
interface could be added to a back-end pool. To learn more about IP addresses and configurations, see Add,
change, or remove IP addresses.
Deleting a VM doesn't delete the network interfaces that are attached to it. When you delete a VM, the
network interfaces are detached from the VM. You can add those network interfaces to different VMs or
delete them.
Achieving the optimal performance documented requires Accelerated Networking. In some cases, you must
explicitly enable Accelerated Networking for Windows or Linux virtual machines.
Next steps
To create a VM with multiple network interfaces or IP addresses, see:
TA SK TO O L
Create a single NIC VM with a private IPv6 address (behind CLI, PowerShell, Azure Resource Manager template
an Azure Load Balancer)
Create and manage a Windows virtual machine that
has multiple NICs
11/2/2020 • 8 minutes to read • Edit Online
Virtual machines (VMs) in Azure can have multiple virtual network interface cards (NICs) attached to them. A
common scenario is to have different subnets for front-end and back-end connectivity. You can associate
multiple NICs on a VM to multiple subnets, but those subnets must all reside in the same virtual network (vNet).
This article details how to create a VM that has multiple NICs attached to it. You also learn how to add or remove
NICs from an existing VM. Different VM sizes support a varying number of NICs, so size your VM accordingly.
Prerequisites
In the following examples, replace example parameter names with your own values. Example parameter names
include myResourceGroup, myVnet, and myVM.
2. Create your virtual network and subnets with New-AzVirtualNetwork. The following example creates a
virtual network named myVnet:
Typically you also create a network security group to filter network traffic to the VM and a load balancer to
distribute traffic across multiple VMs.
Create the virtual machine
Now start to build your VM configuration. Each VM size has a limit for the total number of NICs that you can
add to a VM. For more information, see Windows VM sizes.
1. Set your VM credentials to the $cred variable as follows:
$cred = Get-Credential
2. Define your VM with New-AzVMConfig. The following example defines a VM named myVM and uses a
VM size that supports more than two NICs (Standard_DS3_v2):
4. Attach the two NICs that you previously created with Add-AzVMNetworkInterface:
6. Add routes for secondary NICs to the OS by completing the steps in Configure the operating system for
multiple NICs.
Add a NIC to an existing VM
To add a virtual NIC to an existing VM, you deallocate the VM, add the virtual NIC, then start the VM. Different
VM sizes support a varying number of NICs, so size your VM accordingly. If needed, you can resize a VM.
1. Deallocate the VM with Stop-AzVM. The following example deallocates the VM named myVM in
myResourceGroup:
2. Get the existing configuration of the VM with Get-AzVm. The following example gets information for the
VM named myVM in myResourceGroup:
3. The following example creates a virtual NIC with New-AzNetworkInterface named myNic3 that is
attached to mySubnetBackEnd. The virtual NIC is then attached to the VM named myVM in
myResourceGroup with Add-AzVMNetworkInterface:
5. Add routes for secondary NICs to the OS by completing the steps in Configure the operating system for
multiple NICs.
Remove a NIC from an existing VM
To remove a virtual NIC from an existing VM, you deallocate the VM, remove the virtual NIC, then start the VM.
1. Deallocate the VM with Stop-AzVM. The following example deallocates the VM named myVM in
myResourceGroup:
2. Get the existing configuration of the VM with Get-AzVm. The following example gets information for the
VM named myVM in myResourceGroup:
3. Get information about the NIC remove with Get-AzNetworkInterface. The following example gets
information about myNic3:
4. Remove the NIC with Remove-AzVMNetworkInterface and then update the VM with Update-AzVm. The
following example removes myNic3 as obtained by $nicId in the preceding step:
"copy": {
"name": "multiplenics",
"count": "[parameters('count')]"
}
===========================================================================
Interface List
3...00 0d 3a 10 92 ce ......Microsoft Hyper-V Network Adapter #3
7...00 0d 3a 10 9b 2a ......Microsoft Hyper-V Network Adapter #4
===========================================================================
In this example, Microsoft Hyper-V Network Adapter #4 (interface 7) is the secondary network
interface that doesn't have a default gateway assigned to it.
2. From a command prompt, run the ipconfig command to see which IP address is assigned to the
secondary network interface. In this example, 192.168.2.4 is assigned to interface 7. No default gateway
address is returned for the secondary network interface.
3. To route all traffic destined for addresses outside the subnet of the secondary network interface to the
gateway for the subnet, run the following command:
The gateway address for the subnet is the first IP address (ending in .1) in the address range defined for
the subnet. If you don't want to route all traffic outside the subnet, you could add individual routes to
specific destinations, instead. For example, if you only wanted to route traffic from the secondary network
interface to the 192.168.3.0 network, you enter the command:
4. To confirm successful communication with a resource on the 192.168.3.0 network, for example, enter the
following command to ping 192.168.3.4 using interface 7 (192.168.2.4):
You may need to open ICMP through the Windows firewall of the device you're pinging with the following
command:
5. To confirm the added route is in the route table, enter the route print command, which returns output
similar to the following text:
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 192.168.1.1 192.168.1.4 15
0.0.0.0 0.0.0.0 192.168.2.1 192.168.2.4 5015
The route listed with 192.168.1.1 under Gateway , is the route that is there by default for the primary
network interface. The route with 192.168.2.1 under Gateway , is the route you added.
Next steps
Review Windows VM sizes when you're trying to create a VM that has multiple NICs. Pay attention to the
maximum number of NICs that each VM size supports.
How to create a Linux virtual machine in Azure with
multiple network interface cards
11/2/2020 • 6 minutes to read • Edit Online
This article details how to create a VM with multiple NICs with the Azure CLI.
Create the virtual network with az network vnet create. The following example creates a virtual network named
myVnet and subnet named mySubnetFrontEnd:
Create a subnet for the back-end traffic with az network vnet subnet create. The following example creates a
subnet named mySubnetBackEnd:
Create a network security group with az network nsg create. The following example creates a network security
group named myNetworkSecurityGroup:
az vm create \
--resource-group myResourceGroup \
--name myVM \
--image UbuntuLTS \
--size Standard_DS3_v2 \
--admin-username azureuser \
--generate-ssh-keys \
--nics myNic1 myNic2
Add routing tables to the guest OS by completing the steps in Configure the guest OS for multiple NICs.
Add a NIC to a VM
The previous steps created a VM with multiple NICs. You can also add NICs to an existing VM with the Azure CLI.
Different VM sizes support a varying number of NICs, so size your VM accordingly. If needed, you can resize a
VM.
Create another NIC with az network nic create. The following example creates a NIC named myNic3 connected to
the back-end subnet and network security group created in the previous steps:
To add a NIC to an existing VM, first deallocate the VM with az vm deallocate. The following example deallocates
the VM named myVM:
Add the NIC with az vm nic add. The following example adds myNic3 to myVM:
az vm nic add \
--resource-group myResourceGroup \
--vm-name myVM \
--nics myNic3
Add routing tables to the guest OS by completing the steps in Configure the guest OS for multiple NICs.
Remove the NIC with az vm nic remove. The following example removes myNic3 from myVM:
az vm nic remove \
--resource-group myResourceGroup \
--vm-name myVM \
--nics myNic3
"copy": {
"name": "multiplenics"
"count": "[parameters('count')]"
}
You can read a complete example of creating multiple NICs using Resource Manager templates.
Add routing tables to the guest OS by completing the steps in Configure the guest OS for multiple NICs.
Configure guest OS for multiple NICs
The previous steps created a virtual network and subnet, attached NICs, then created a VM. A public IP address
and network security group rules that allow SSH traffic were not created. To configure the guest OS for multiple
NICs, you need to allow remote connections and run commands locally on the VM.
To allow SSH traffic, create a network security group rule with az network nsg rule create as follows:
Create a public IP address with az network public-ip create and assign it to the first NIC with az network nic ip-
config update:
Now SSH to the public IP address of your VM. The default username provided in a previous step was azureuser.
Provide your own username and public IP address:
ssh azureuser@137.117.58.232
To send to or from a secondary network interface, you have to manually add persistent routes to the operating
system for each secondary network interface. In this article, eth1 is the secondary interface. Instructions for
adding persistent routes to the operating system vary by distro. See documentation for your distro for
instructions.
When adding the route to the operating system, the gateway address is .1 for whichever subnet the network
interface is in. For example, if the network interface is assigned the address 10.0.2.4, the gateway you specify for
the route is 10.0.2.1. You can define a specific network for the route's destination, or specify a destination of
0.0.0.0, if you want all traffic for the interface to go through the specified gateway. The gateway for each subnet is
managed by the virtual network.
Once you've added the route for a secondary interface, verify that the route is in your route table with route -n .
The following example output is for the route table that has the two network interfaces added to the VM in this
article:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.0.1.1 0.0.0.0 UG 0 0 0 eth0
0.0.0.0 10.0.2.1 0.0.0.0 UG 0 0 0 eth1
10.0.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
10.0.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
168.63.129.16 10.0.1.1 255.255.255.255 UGH 0 0 0 eth0
169.254.169.254 10.0.1.1 255.255.255.255 UGH 0 0 0 eth0
Confirm that the route you added persists across reboots by checking your route table again after a reboot. To
test connectivity, you can enter the following command, for example, where eth1 is the name of a secondary
network interface:
Next steps
Review Linux VM sizes when trying to creating a VM with multiple NICs. Pay attention to the maximum number
of NICs each VM size supports.
To further secure your VMs, use just in time VM access. This feature opens network security group rules for SSH
traffic when needed, and for a defined period of time. For more information, see Manage virtual machine access
using just in time.
Create a Windows VM with accelerated networking
using Azure PowerShell
11/2/2020 • 10 minutes to read • Edit Online
In this tutorial, you learn how to create a Windows virtual machine (VM) with accelerated networking.
NOTE
To use accelerated networking with a Linux virtual machine, see Create a Linux VM with accelerated networking.
Accelerated networking enables single root I/O virtualization (SR-IOV) to a VM, greatly improving its networking
performance. This high-performance path bypasses the host from the data path, which reduces latency, jitter, and
CPU utilization for the most demanding network workloads on supported VM types. The following diagram
illustrates how two VMs communicate with and without accelerated networking:
Without accelerated networking, all networking traffic in and out of the VM must traverse the host and the virtual
switch. The virtual switch provides all policy enforcement, such as network security groups, access control lists,
isolation, and other network virtualized services to network traffic.
NOTE
To learn more about virtual switches, see Hyper-V Virtual Switch.
With accelerated networking, network traffic arrives at the VM's network interface (NIC) and is then forwarded to
the VM. All network policies that the virtual switch applies are now offloaded and applied in hardware. Because
policy is applied in hardware, the NIC can forward network traffic directly to the VM. The NIC bypasses the host
and the virtual switch, while it maintains all the policy it applied in the host.
The benefits of accelerated networking only apply to the VM that it's enabled on. For the best results, enable this
feature on at least two VMs connected to the same Azure virtual network. When communicating across virtual
networks or connecting on-premises, this feature has minimal impact to overall latency.
Benefits
Lower Latency / Higher packets per second (pps) : Eliminating the virtual switch from the data path
removes the time packets spend in the host for policy processing. It also increases the number of packets
that can be processed inside the VM.
Reduced jitter : Virtual switch processing depends on the amount of policy that needs to be applied. It also
depends on the workload of the CPU that's doing the processing. Offloading the policy enforcement to the
hardware removes that variability by delivering packets directly to the VM. Offloading also removes the
host-to-VM communication, all software interrupts, and all context switches.
Decreased CPU utilization : Bypassing the virtual switch in the host leads to less CPU utilization for
processing network traffic.
After you create the VM, you can confirm whether accelerated networking is enabled. Follow these instructions:
1. Go to the Azure portal to manage your VMs. Search for and select Vir tual machines .
2. In the virtual machine list, choose your new VM.
3. In the VM menu bar, choose Networking .
In the network interface information, next to the Accelerated networking label, the portal displays either
Disabled or Enabled for the accelerated networking status.
$subnet = New-AzVirtualNetworkSubnetConfig `
-Name "mySubnet" `
-AddressPrefix "192.168.1.0/24"
2. Create a network security group with New-AzNetworkSecurityGroup and assign the Allow-RDP-All security
rule to it. Aside from the Allow-RDP-All rule, the network security group contains several default rules. One
default rule disables all inbound access from the internet. Once it's created, the Allow-RDP-All rule is
assigned to the network security group so that you can remotely connect to the VM.
$nsg = New-AzNetworkSecurityGroup `
-ResourceGroupName myResourceGroup `
-Location centralus `
-Name "myNsg" `
-SecurityRules $rdp
3. Associate the network security group to the mySubnet subnet with Set-AzVirtualNetworkSubnetConfig. The
rule in the network security group is effective for all resources deployed in the subnet.
Set-AzVirtualNetworkSubnetConfig `
-VirtualNetwork $vnet `
-Name 'mySubnet' `
-AddressPrefix "192.168.1.0/24" `
-NetworkSecurityGroup $nsg
$publicIp = New-AzPublicIpAddress `
-ResourceGroupName myResourceGroup `
-Name 'myPublicIp' `
-location centralus `
-AllocationMethod Dynamic
2. Create a network interface with New-AzNetworkInterface with accelerated networking enabled, and assign
the public IP address to the network interface. The following example creates a network interface named
myNic in the mySubnet subnet of the myVnet virtual network, assigning the myPublicIp public IP address
to it:
$nic = New-AzNetworkInterface `
-ResourceGroupName "myResourceGroup" `
-Name "myNic" `
-Location "centralus" `
-SubnetId $vnet.Subnets[0].Id `
-PublicIpAddressId $publicIp.Id `
-EnableAcceleratedNetworking
$cred = Get-Credential
2. Define your VM with New-AzVMConfig. The following command defines a VM named myVM with a VM
size that supports accelerated networking (Standard_DS4_v2):
4. Attach the network interface that you previously created with Add-AzVMNetworkInterface:
NOTE
If the Mellanox adapter fails to start, open an administrator prompt in the remote desktop session and enter the following
command:
netsh int tcp set global rss = enabled
NOTE
When you create a VM individually, without an availability set, you only need to stop or deallocate the individual VM
to enable accelerated networking. If your VM was created with an availability set, you must stop or deallocate all
VMs contained in the availability set before enabling accelerated networking on any of the NICs, so that the VMs
end up on a cluster that supports accelerated networking. The stop or deallocate requirement is unnecessary if you
disable accelerated networking, because clusters that support accelerated networking also work fine with NICs that
don't use accelerated networking.
$nic.EnableAcceleratedNetworking = $true
$nic | Set-AzNetworkInterface
3. Restart your VM or, if in an availability set, all the VMs in the set, and confirm that accelerated networking is
enabled:
$vmss.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations[0].EnableAcceleratedNetworkin
g = $true
3. Set the applied updates to automatic so that the changes are immediately picked up:
$vmss.UpgradePolicy.Mode = "Automatic"
Once you restart, wait for the upgrades to finish. After the upgrades are done, the virtual function (VF) appears
inside the VM. Make sure you're using a supported OS and VM size.
Resizing existing VMs with accelerated networking
If a VM has accelerated networking enabled, you're only able to resize it to a VM that supports accelerated
networking.
A VM with accelerated networking enabled can't be resized to a VM instance that doesn't support accelerated
networking using the resize operation. Instead, to resize one of these VMs:
1. Stop or deallocate the VM. For an availability set or scale set, stop or deallocate all the VMs in the availability
set or scale set.
2. Disable accelerated networking on the NIC of the VM. For an availability set or scale set, disable accelerated
networking on the NICs of all VMs in the availability set or scale set.
3. After you disable accelerated networking, move the VM, availability set, or scale set to a new size that
doesn't support accelerated networking, and then restart them.
Create a Linux virtual machine with Accelerated
Networking using Azure CLI
11/2/2020 • 10 minutes to read • Edit Online
In this tutorial, you learn how to create a Linux virtual machine (VM) with Accelerated Networking. To create a
Windows VM with Accelerated Networking, see Create a Windows VM with Accelerated Networking. Accelerated
networking enables single root I/O virtualization (SR-IOV) to a VM, greatly improving its networking performance.
This high-performance path bypasses the host from the datapath, reducing latency, jitter, and CPU utilization, for
use with the most demanding network workloads on supported VM types. The following picture shows
communication between two VMs with and without accelerated networking:
Without accelerated networking, all networking traffic in and out of the VM must traverse the host and the virtual
switch. The virtual switch provides all policy enforcement, such as network security groups, access control lists,
isolation, and other network virtualized services to network traffic. To learn more about virtual switches, read the
Hyper-V network virtualization and virtual switch article.
With accelerated networking, network traffic arrives at the virtual machine's network interface (NIC), and is then
forwarded to the VM. All network policies that the virtual switch applies are now offloaded and applied in
hardware. Applying policy in hardware enables the NIC to forward network traffic directly to the VM, bypassing
the host and the virtual switch, while maintaining all the policy it applied in the host.
The benefits of accelerated networking only apply to the VM that it is enabled on. For the best results, it is ideal to
enable this feature on at least two VMs connected to the same Azure virtual network (VNet). When communicating
across VNets or connecting on-premises, this feature has minimal impact to overall latency.
Benefits
Lower Latency / Higher packets per second (pps): Removing the virtual switch from the datapath
removes the time packets spend in the host for policy processing and increases the number of packets that can
be processed inside the VM.
Reduced jitter : Virtual switch processing depends on the amount of policy that needs to be applied and the
workload of the CPU that is doing the processing. Offloading the policy enforcement to the hardware removes
that variability by delivering packets directly to the VM, removing the host to VM communication and all
software interrupts and context switches.
Decreased CPU utilization: Bypassing the virtual switch in the host leads to less CPU utilization for
processing network traffic.
CLI creation
Create a virtual network
Install the latest Azure CLI and log in to an Azure account using az login. In the following examples, replace
example parameter names with your own values. Example parameter names included myResourceGroup, myNic,
and myVm.
Create a resource group with az group create. The following example creates a resource group named
myResourceGroup in the centralus location:
The network security group contains several default rules, one of which disables all inbound access from the
Internet. Open a port to allow SSH access to the virtual machine with az network nsg rule create:
Create a network interface with az network nic create with accelerated networking enabled. The following example
creates a network interface named myNic in the mySubnet subnet of the myVnet virtual network and associates
the myNetworkSecurityGroup network security group to the network interface:
az vm create \
--resource-group myResourceGroup \
--name myVM \
--image UbuntuLTS \
--size Standard_DS4_v2 \
--admin-username azureuser \
--generate-ssh-keys \
--nics myNic
{
"fqdns": "",
"id": "/subscriptions/<ID>/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM",
"location": "centralus",
"macAddress": "00-0D-3A-23-9A-49",
"powerState": "VM running",
"privateIpAddress": "192.168.0.4",
"publicIpAddress": "40.68.254.142",
"resourceGroup": "myResourceGroup"
}
From the Bash shell, 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 : 7.4.2017120423
CentOS : 7.4.20171206
Confirm the Mellanox VF device is exposed to the VM with the lspci command. The returned output is similar to
the following output:
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]
Check for activity on the VF (virtual function) with the ethtool -S eth0 | grep vf_ command. If you receive output
similar to the following sample output, accelerated networking is enabled and working.
vf_rx_packets: 992956
vf_rx_bytes: 2749784180
vf_tx_packets: 2656684
vf_tx_bytes: 1099443970
vf_tx_dropped: 0
Important, please note, if your VM was created individually, without an availability set, you only need to
stop/deallocate the individual VM to enable Accelerated Networking. If your VM was created with an availability
set, all VMs contained in the availability set will need to be stopped/deallocated before enabling Accelerated
Networking on any of the NICs.
Once stopped, enable Accelerated Networking on the NIC of your VM:
Restart your VM or, if in an Availability Set, all the VMs in the Set and confirm that Accelerated Networking is
enabled:
VMSS
VMSS is slightly different but follows the same workflow. First, stop the VMs:
az vmss deallocate \
--name myvmss \
--resource-group myrg
Once the VMs are stopped, update the Accelerated Networking property under the network interface:
Please note, a VMSS has VM upgrades that apply updates using three different settings, automatic, rolling and
manual. In these instructions the policy is set to automatic so that the VMSS will pick up the changes immediately
after restarting. To set it to automatic so that the changes are immediately picked up:
az vmss update \
--name myvmss \
--resource-group myrg \
--set upgradePolicy.mode="automatic"
az vmss start \
--name myvmss \
--resource-group myrg
Once you restart, wait for the upgrades to finish but once completed, the VF will appear inside the VM. (Please
make sure you are using a supported OS and VM size.)
Resizing existing VMs with Accelerated Networking
VMs with Accelerated Networking enabled can only be resized to VMs that support Accelerated Networking.
A VM with Accelerated Networking enabled cannot be resized to a VM instance that does not support Accelerated
Networking using the resize operation. Instead, to resize one of these VMs:
Stop/Deallocate the VM or if in an availability set/VMSS, stop/deallocate all the VMs in the set/VMSS.
Accelerated Networking must be disabled on the NIC of the VM or if in an availability set/VMSS, all VMs in the
set/VMSS.
Once Accelerated Networking is disabled, the VM/availability set/VMSS can be moved to a new size that does
not support Accelerated Networking and restarted.
Set up DPDK in a Linux virtual machine
11/2/2020 • 6 minutes to read • Edit Online
Data Plane Development Kit (DPDK) on Azure offers a faster user-space packet processing framework for
performance-intensive applications. This framework bypasses the virtual machine’s kernel network stack.
In typical packet processing that uses the kernel network stack, the process is interrupt-driven. When the network
interface receives incoming packets, there is a kernel interrupt to process the packet and a context switch from the
kernel space to the user space. DPDK eliminates context switching and the interrupt-driven method in favor of a
user-space implementation that uses poll mode drivers for fast packet processing.
DPDK consists of sets of user-space libraries that provide access to lower-level resources. These resources can
include hardware, logical cores, memory management, and poll mode drivers for network interface cards.
DPDK can run on Azure virtual machines that are supporting multiple operating system distributions. DPDK
provides key performance differentiation in driving network function virtualization implementations. These
implementations can take the form of network virtual appliances (NVAs), such as virtual routers, firewalls, VPNs,
load balancers, evolved packet cores, and denial-of-service (DDoS) applications.
Benefit
Higher packets per second (PPS) : Bypassing the kernel and taking control of packets in the user space reduces
the cycle count by eliminating context switches. It also improves the rate of packets that are processed per second
in Azure Linux virtual machines.
L IN UX O S K ERN EL VERSIO N
Region support
All Azure regions support DPDK.
Prerequisites
Accelerated networking must be enabled on a Linux virtual machine. The virtual machine should have at least two
network interfaces, with one interface for management. Learn how to create a Linux virtual machine with
accelerated networking enabled.
Ubuntu 18.04
RHEL7.5/CentOS 7.5
SLES 15 SP1
Azure kernel
zypper \
--no-gpg-checks \
--non-interactive \
--gpg-auto-import-keys install kernel-azure kernel-devel-azure gcc make libnuma-devel numactl librdmacm1
rdma-core-devel
Default kernel
zypper \
--no-gpg-checks \
--non-interactive \
--gpg-auto-import-keys install kernel-default-devel gcc make libnuma-devel numactl librdmacm1 rdma-core-devel
[NOTE] There is a way to modify the grub file so that hugepages are reserved on boot by
following the instructions for the DPDK. The instructions are at the bottom of the page. When
you're using an Azure Linux virtual machine, modify files under /etc/config/grub.d instead, to
reserve hugepages across reboots.
2. MAC & IP addresses: Use ifconfig –a to view the MAC and IP address of the network interfaces. The VF
network interface and NETVSC network interface have the same MAC address, but only the NETVSC network
interface has an IP address. VF interfaces are running as subordinate interfaces of NETVSC interfaces.
3. PCI addresses
Use ethtool -i <vf interface name> to find out which PCI address to use for VF.
If eth0 has accelerated networking enabled, make sure that testpmd doesn’t accidentally take over the VF
pci device for eth0. If the DPDK application accidentally takes over the management network interface
and causes you to lose your SSH connection, use the serial console to stop the DPDK application. You can
also use the serial console to stop or start the virtual machine.
4. Load ibuverbs on each reboot with modprobe -a ib_uverbs . For SLES 15 only, also load mlx4_ib with
modprobe -a mlx4_ib .
Failsafe PMD
DPDK applications must run over the failsafe PMD that is exposed in Azure. If the application runs directly over the
VF PMD, it doesn't receive all packets that are destined to the VM, since some packets show up over the synthetic
interface.
If you run a DPDK application over the failsafe PMD, it guarantees that the application receives all packets that are
destined to it. It also makes sure that the application keeps running in DPDK mode, even if the VF is revoked when
the host is being serviced. For more information about failsafe PMD, see Fail-safe poll mode driver library.
Run testpmd
To run testpmd in root mode, use sudo before the testpmd command.
Basic: Sanity check, failsafe adapter initialization
1. Run the following commands to start a single port testpmd application:
If you're running testpmd with more than two NICs, the --vdev argument follows this pattern:
net_vdev_netvsc<id>,iface=<vf’s pairing eth> .
3. After it's started, run show port info all to check port information. You should see one or two DPDK ports
that are net_failsafe (not net_mlx4).
4. Use start <port> /stop <port> to start traffic.
The previous commands start testpmd in interactive mode, which is recommended for trying out testpmd
commands.
Basic: Single sender/single receiver
The following commands periodically print the packets per second statistics:
1. On the TX side, run the following command:
testpmd \
-l <core-list> \
-n <num of mem channels> \
-w <pci address of the device you plan to use> \
--vdev="net_vdev_netvsc<id>,iface=<the iface to attach to>" \
-- --port-topology=chained \
--nb-cores <number of cores to use for test pmd> \
--forward-mode=txonly \
--eth-peer=<port id>,<receiver peer MAC address> \
--stats-period <display interval in seconds>
testpmd \
-l <core-list> \
-n <num of mem channels> \
-w <pci address of the device you plan to use> \
--vdev="net_vdev_netvsc<id>,iface=<the iface to attach to>" \
-- --port-topology=chained \
--nb-cores <number of cores to use for test pmd> \
--forward-mode=rxonly \
--eth-peer=<port id>,<sender peer MAC address> \
--stats-period <display interval in seconds>
When you're running the previous commands on a virtual machine, change IP_SRC_ADDR and IP_DST_ADDR in
app/test-pmd/txonly.c to match the actual IP address of the virtual machines before you compile. Otherwise, the
packets are dropped before reaching the receiver.
Advanced: Single sender/single forwarder
The following commands periodically print the packets per second statistics:
1. On the TX side, run the following command:
testpmd \
-l <core-list> \
-n <num of mem channels> \
-w <pci address of the device you plan to use> \
--vdev="net_vdev_netvsc<id>,iface=<the iface to attach to>" \
-- --port-topology=chained \
--nb-cores <number of cores to use for test pmd> \
--forward-mode=txonly \
--eth-peer=<port id>,<receiver peer MAC address> \
--stats-period <display interval in seconds>
testpmd \
-l <core-list> \
-n <num of mem channels> \
-w <pci address NIC1> \
-w <pci address NIC2> \
--vdev="net_vdev_netvsc<id>,iface=<the iface to attach to>" \
--vdev="net_vdev_netvsc<2nd id>,iface=<2nd iface to attach to>" (you need as many --vdev arguments as
the number of devices used by testpmd, in this case) \
-- --nb-cores <number of cores to use for test pmd> \
--forward-mode=io \
--eth-peer=<recv port id>,<sender peer MAC address> \
--stats-period <display interval in seconds>
When you're running the previous commands on a virtual machine, change IP_SRC_ADDR and IP_DST_ADDR in
app/test-pmd/txonly.c to match the actual IP address of the virtual machines before you compile. Otherwise, the
packets are dropped before reaching the forwarder. You won’t be able to have a third machine receive forwarded
traffic, because the testpmd forwarder doesn’t modify the layer-3 addresses, unless you make some code changes.
References
EAL options
Testpmd commands
TCP/IP performance tuning for Azure VMs
11/2/2020 • 23 minutes to read • Edit Online
This article discusses common TCP/IP performance tuning techniques and some things to consider when you use
them for virtual machines running on Azure. It will provide a basic overview of the techniques and explore how
they can be tuned.
IMPORTANT
Increasing MTU isn't known to improve performance and could have a negative effect on application performance.
The IP header and the TCP header are 20 bytes each, or 40 bytes total. So an interface with an MTU of 1,500 will
have an MSS of 1,460. But the MSS is configurable.
This setting is agreed to in the TCP three-way handshake when a TCP session is set up between a source and a
destination. Both sides send an MSS value, and the lower of the two is used for the TCP connection.
Keep in mind that the MTUs of the source and destination aren't the only factors that determine the MSS value.
Intermediary network devices, like VPN gateways, including Azure VPN Gateway, can adjust the MTU independently
of the source and destination to ensure optimal network performance.
Path MTU Discovery
MSS is negotiated, but it might not indicate the actual MSS that can be used. This is because other network devices
in the path between the source and the destination might have a lower MTU value than the source and destination.
In this case, the device whose MTU is smaller than the packet will drop the packet. The device will send back an
ICMP Fragmentation Needed (Type 3, Code 4) message that contains its MTU. This ICMP message allows the source
host to reduce its Path MTU appropriately. The process is called Path MTU Discovery (PMTUD).
The PMTUD process is inefficient and affects network performance. When packets are sent that exceed a network
path's MTU, the packets need to be retransmitted with a lower MSS. If the sender doesn't receive the ICMP
Fragmentation Needed message, maybe because of a network firewall in the path (commonly referred to as a
PMTUD blackhole), the sender doesn't know it needs to lower the MSS and will continuously retransmit the packet.
This is why we don’t recommend increasing the Azure VM MTU.
VPN and MTU
If you use VMs that perform encapsulation (like IPsec VPNs), there are some additional considerations regarding
packet size and MTU. VPNs add more headers to packets, which increases the packet size and requires a smaller
MSS.
For Azure, we recommend that you set TCP MSS clamping to 1,350 bytes and tunnel interface MTU to 1,400. For
more information, see the VPN devices and IPSec/IKE parameters page.
Latency, round-trip time, and TCP window scaling
Latency and round-trip time
Network latency is governed by the speed of light over a fiber optic network. Network throughput of TCP is also
effectively governed by the round-trip time (RTT) between two network devices.
RO UT E DISTA N C E O N E- WAY T IM E RT T
This table shows the straight-line distance between two locations. In networks, the distance is typically longer than
the straight-line distance. Here's a simple formula to calculate minimum RTT as governed by the speed of light:
minimum RTT = 2 * (Distance in kilometers / Speed of propagation)
You can use 200 for the speed of propagation. This is the distance, in kilometers, that light travels in 1 millisecond.
Let's take New York to San Francisco as an example. The straight-line distance is 4,148 km. Plugging that value into
the equation, we get the following:
Minimum RTT = 2 * (4,148 / 200)
This table shows the maximum megabytes/per second throughput of a single TCP connection. (For readability,
megabytes is used for the unit of measure.)
M A XIM UM M A XIM UM
M EGA B Y T E/ SEC O N D M EGA B IT / SEC O N D
TC P W IN DO W SIZ E ( B Y T ES) RT T L AT EN C Y ( M S) T H RO UGH P UT T H RO UGH P UT
If packets are lost, the maximum throughput of a TCP connection will be reduced while the sender retransmits data
it has already sent.
TCP window scaling
TCP window scaling is a technique that dynamically increases the TCP window size to allow more data to be sent
before an acknowledgement is required. In the previous example, 45 packets would be sent before an
acknowledgement was required. If you increase the number of packets that can be sent before an
acknowledgement is needed, you're reducing the number of times a sender is waiting for acknowledgement, which
increases the TCP maximum throughput.
This table illustrates those relationships:
M A XIM UM M A XIM UM
M EGA B Y T E/ SEC O N D M EGA B IT / SEC O N D
TC P W IN DO W SIZ E ( B Y T ES) RT T L AT EN C Y ( M S) T H RO UGH P UT T H RO UGH P UT
But the TCP header value for TCP window size is only 2 bytes long, which means the maximum value for a receive
window is 65,535. To increase the maximum window size, a TCP window scale factor was introduced.
The scale factor is also a setting that you can configure in an operating system. Here's the formula for calculating
the TCP window size by using scale factors:
TCP window size = TCP window size in bytes \* (2^scale factor)
Here's the calculation for a window scale factor of 3 and a window size of 65,535:
65,535 \* (2^3) = 262,140 bytes
A scale factor of 14 results in a TCP window size of 14 (the maximum offset allowed). The TCP window size will be
1,073,725,440 bytes (8.5 gigabits).
Support for TCP window scaling
Windows can set different scaling factors for different connection types. (Classes of connections include datacenter,
internet, and so on.) You use the Get-NetTCPConnection PowerShell command to view the window scaling
connection type:
Get-NetTCPConnection
You can use the Get-NetTCPSetting PowerShell command to view the values of each class:
Get-NetTCPSetting
You can set the initial TCP window size and TCP scaling factor in Windows by using the Set-NetTCPSetting
PowerShell command. For more information, see Set-NetTCPSetting.
Set-NetTCPSetting
F O RM UL A TO
C A L C UL AT E M A XIM UM
A UTOT UN IN GL EVEL SC A L IN G FA C TO R SC A L IN G M ULT IP L IER W IN DO W SIZ E
These settings are the most likely to affect TCP performance, but keep in mind that many other factors across the
internet, outside the control of Azure, can also affect TCP performance.
Increase MTU size
Because a larger MTU means a larger MSS, you might wonder whether increasing the MTU can increase TCP
performance. Probably not. There are pros and cons to packet size beyond just TCP traffic. As discussed earlier, the
most important factors affecting TCP throughput performance are TCP window size, packet loss, and RTT.
IMPORTANT
We don't recommend that Azure customers change the default MTU value on virtual machines.
Next steps
Now that you've learned about TCP/IP performance tuning for Azure VMs, you might want to read about other
considerations for planning virtual networks or learn more about connecting and configuring virtual networks.
Virtual machine network bandwidth
11/2/2020 • 3 minutes to read • Edit Online
Azure offers a variety of VM sizes and types, each with a different mix of performance capabilities. One capability is
network throughput (or bandwidth), measured in megabits per second (Mbps). Because virtual machines are
hosted on shared hardware, the network capacity must be shared fairly among the virtual machines sharing the
same hardware. Larger virtual machines are allocated relatively more bandwidth than smaller virtual machines.
The network bandwidth allocated to each virtual machine is metered on egress (outbound) traffic from the virtual
machine. All network traffic leaving the virtual machine is counted toward the allocated limit, regardless of
destination. For example, if a virtual machine has a 1,000 Mbps limit, that limit applies whether the outbound
traffic is destined for another virtual machine in the same virtual network, or outside of Azure.
Ingress is not metered or limited directly. However, there are other factors, such as CPU and storage limits, which
can impact a virtual machine’s ability to process incoming data.
Accelerated networking is a feature designed to improve network performance, including latency, throughput, and
CPU utilization. While accelerated networking can improve a virtual machine’s throughput, it can do so only up to
the virtual machine’s allocated bandwidth. To learn more about Accelerated networking, see Accelerated
networking for Windows or Linux virtual machines.
Azure virtual machines must have one, but may have several, network interfaces attached to them. Bandwidth
allocated to a virtual machine is the sum of all outbound traffic across all network interfaces attached to a virtual
machine. In other words, the allocated bandwidth is per virtual machine, regardless of how many network
interfaces are attached to the virtual machine. To learn how many network interfaces different Azure VM sizes
support, see Azure Windows and Linux VM sizes.
Metrics are available in Azure Monitor to track the number of network flows and the flow creation rate on your VM
or VMSS instances.
Connection establishment and termination rates can also affect network performance as connection establishment
and termination shares CPU with packet processing routines. We recommend that you benchmark workloads
against expected traffic patterns and scale out workloads appropriately to match your performance needs.
Next steps
Optimize network throughput for a virtual machine operating system
Test network throughput for a virtual machine.
Move Azure network security group (NSG) to another
region using the Azure portal
11/2/2020 • 4 minutes to read • Edit Online
There are various scenarios in which you'd want to move your existing NSGs from one region to another. For
example, you may want to create an NSG with the same configuration and security rules for testing. You may also
want to move an NSG to another region as part of disaster recovery planning.
Azure security groups can't be moved from one region to another. You can however, use an Azure Resource
Manager template to export the existing configuration and security rules of an NSG. You can then stage the
resource in another region by exporting the NSG to a template, modifying the parameters to match the destination
region, and then deploy the template to the new region. For more information on Resource Manager and
templates, see Quickstart: Create and deploy Azure Resource Manager templates by using the Azure portal.
Prerequisites
Make sure that the Azure network security group is in the Azure region from which you want to move.
Azure network security groups can't be moved between regions. You'll have to associate the new NSG to
resources in the target region.
To export an NSG configuration and deploy a template to create an NSG in another region, you'll need the
Network Contributor role or higher.
Identify the source networking layout and all the resources that you're currently using. This layout includes
but isn't limited to load balancers, public IPs, and virtual networks.
Verify that your Azure subscription allows you to create NSGs in the target region that's used. Contact
support to enable the required quota.
Make sure that your subscription has enough resources to support the addition of NSGs for this process.
See Azure subscription and service limits, quotas, and constraints.
7. Change the source NSG value in the editor to a name of your choice for the target NSG. Ensure you enclose
the name in quotes.
8. Click Save in the editor.
9. Click TEMPL ATE > Edit template to open the template.json file in the online editor.
10. To edit the target region where the NSG configuration and security rules will be moved, change the location
property under resources in the online editor:
"resources": [
{
"type": "Microsoft.Network/networkSecurityGroups",
"apiVersion": "2019-06-01",
"name": "[parameters('networkSecurityGroups_myVM1_nsg_name')]",
"location": "<target-region>",
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "2c846acf-58c8-416d-be97-ccd00a4ccd78",
}
}
]
11. To obtain region location codes, see Azure Locations. The code for a region is the region name with no
spaces, Central US = centralus .
12. You can also change other parameters in the template if you choose, and are optional depending on your
requirements:
Security rules - You can edit which rules are deployed into the target NSG by adding or removing
rules to the securityRules section in the template.json file:
"resources": [
{
"type": "Microsoft.Network/networkSecurityGroups",
"apiVersion": "2019-06-01",
"name": "[parameters('networkSecurityGroups_myVM1_nsg_name')]",
"location": "<target-region>",
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "2c846acf-58c8-416d-be97-ccd00a4ccd78",
"securityRules": [
{
"name": "RDP",
"etag": "W/\"c630c458-6b52-4202-8fd7-172b7ab49cf5\"",
"properties": {
"provisioningState": "Succeeded",
"protocol": "TCP",
"sourcePortRange": "*",
"destinationPortRange": "3389",
"sourceAddressPrefix": "*",
"destinationAddressPrefix": "*",
"access": "Allow",
"priority": 300,
"direction": "Inbound",
"sourcePortRanges": [],
"destinationPortRanges": [],
"sourceAddressPrefixes": [],
"destinationAddressPrefixes": []
}
},
]
}
To complete the addition or the removal of the rules in the target NSG, you must also edit the custom
rule types at the end of the template.json file in the format of the example below:
{
"type": "Microsoft.Network/networkSecurityGroups/securityRules",
"apiVersion": "2019-06-01",
"name": "[concat(parameters('networkSecurityGroups_myVM1_nsg_name'), '/Port_80')]",
"dependsOn": [
"[resourceId('Microsoft.Network/networkSecurityGroups',
parameters('networkSecurityGroups_myVM1_nsg_name'))]"
],
"properties": {
"provisioningState": "Succeeded",
"protocol": "*",
"sourcePortRange": "*",
"destinationPortRange": "80",
"sourceAddressPrefix": "*",
"destinationAddressPrefix": "*",
"access": "Allow",
"priority": 310,
"direction": "Inbound",
"sourcePortRanges": [],
"destinationPortRanges": [],
"sourceAddressPrefixes": [],
"destinationAddressPrefixes": []
}
Discard
If you wish to discard the target NSG, delete the resource group that contains the target NSG. To do so, select the
resource group from your dashboard in the portal and select Delete at the top of the overview page.
Clean up
To commit the changes and complete the move of the NSG, delete the source NSG or resource group. To do so,
select the network security group or resource group from your dashboard in the portal and select Delete at the top
of each page.
Next steps
In this tutorial, you moved an Azure network security group from one region to another and cleaned up the source
resources. To learn more about moving resources between regions and disaster recovery in Azure, refer to:
Move resources to a new resource group or subscription
Move Azure VMs to another region
Move Azure network security group (NSG) to another
region using Azure PowerShell
11/2/2020 • 4 minutes to read • Edit Online
There are various scenarios in which you'd want to move your existing NSGs from one region to another. For
example, you may want to create an NSG with the same configuration and security rules for testing. You may also
want to move an NSG to another region as part of disaster recovery planning.
Azure security groups can't be moved from one region to another. You can however, use an Azure Resource
Manager template to export the existing configuration and security rules of an NSG. You can then stage the
resource in another region by exporting the NSG to a template, modifying the parameters to match the destination
region, and then deploy the template to the new region. For more information on Resource Manager and
templates, see Export resource groups to templates.
Prerequisites
Make sure that the Azure network security group is in the Azure region from which you want to move.
Azure network security groups can't be moved between regions. You'll have to associate the new NSG to
resources in the target region.
To export an NSG configuration and deploy a template to create an NSG in another region, you'll need the
Network Contributor role or higher.
Identify the source networking layout and all the resources that you're currently using. This layout includes
but isn't limited to load balancers, public IPs, and virtual networks.
Verify that your Azure subscription allows you to create NSGs in the target region that's used. Contact
support to enable the required quota.
Make sure that your subscription has enough resources to support the addition of NSGs for this process.
See Azure subscription and service limits, quotas, and constraints.
NOTE
This article has been updated to use the new Azure PowerShell Az module. You can still use the AzureRM module, which will
continue to receive bug fixes until at least December 2020. To learn more about the new Az module and AzureRM
compatibility, see Introducing the new Azure PowerShell Az module. For Az module installation instructions, see Install Azure
PowerShell.
2. Obtain the resource ID of the NSG you want to move to the target region and place it in a variable using Get-
AzNetworkSecurityGroup:
3. Export the source NSG to a .json file into the directory where you execute the command Export-
AzResourceGroup:
4. The file downloaded will be named after the resource group the resource was exported from. Locate the file
that was exported from the command named <resource-group-name>.json and open it in an editor of
your choice:
notepad <source-resource-group-name>.json
5. To edit the parameter of the NSG name, change the property defaultValue of the source NSG name to the
name of your target NSG, ensure the name is in quotes:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"networkSecurityGroups_myVM1_nsg_name": {
"defaultValue": "<target-nsg-name>",
"type": "String"
}
}
6. To edit the target region where the NSG configuration and security rules will be moved, change the location
property under resources :
"resources": [
{
"type": "Microsoft.Network/networkSecurityGroups",
"apiVersion": "2019-06-01",
"name": "[parameters('networkSecurityGroups_myVM1_nsg_name')]",
"location": "<target-region>",
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "2c846acf-58c8-416d-be97-ccd00a4ccd78",
}
}
7. To obtain region location codes, you can use the Azure PowerShell cmdlet Get-AzLocation by running the
following command:
Get-AzLocation | format-table
8. You can also change other parameters in the <resource-group-name>.json if you choose, and are
optional depending on your requirements:
Security rules - You can edit which rules are deployed into the target NSG by adding or removing
rules to the securityRules section in the <resource-group-name>.json file:
"resources": [
{
"type": "Microsoft.Network/networkSecurityGroups",
"apiVersion": "2019-06-01",
"name": "[parameters('networkSecurityGroups_myVM1_nsg_name')]",
"location": "TARGET REGION",
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "2c846acf-58c8-416d-be97-ccd00a4ccd78",
"securityRules": [
{
"name": "RDP",
"etag": "W/\"c630c458-6b52-4202-8fd7-172b7ab49cf5\"",
"properties": {
"provisioningState": "Succeeded",
"protocol": "TCP",
"sourcePortRange": "*",
"destinationPortRange": "3389",
"sourceAddressPrefix": "*",
"destinationAddressPrefix": "*",
"access": "Allow",
"priority": 300,
"direction": "Inbound",
"sourcePortRanges": [],
"destinationPortRanges": [],
"sourceAddressPrefixes": [],
"destinationAddressPrefixes": []
}
]
}
To complete the addition or the removal of the rules in the target NSG, you must also edit the custom
rule types at the end of the <resource-group-name>.json file in the format of the example below:
{
"type": "Microsoft.Network/networkSecurityGroups/securityRules",
"apiVersion": "2019-06-01",
"name": "[concat(parameters('networkSecurityGroups_myVM1_nsg_name'), '/Port_80')]",
"dependsOn": [
"[resourceId('Microsoft.Network/networkSecurityGroups',
parameters('networkSecurityGroups_myVM1_nsg_name'))]"
],
"properties": {
"provisioningState": "Succeeded",
"protocol": "*",
"sourcePortRange": "*",
"destinationPortRange": "80",
"sourceAddressPrefix": "*",
"destinationAddressPrefix": "*",
"access": "Allow",
"priority": 310,
"direction": "Inbound",
"sourcePortRanges": [],
"destinationPortRanges": [],
"sourceAddressPrefixes": [],
"destinationAddressPrefixes": []
}
11. Deploy the edited <resource-group-name>.json file to the resource group created in the previous step
using New-AzResourceGroupDeployment:
12. To verify the resources were created in the target region, use Get-AzResourceGroup and Get-
AzNetworkSecurityGroup:
Discard
After the deployment, if you wish to start over or discard the NSG in the target, delete the resource group that was
created in the target and the moved NSG will be deleted. To remove the resource group, use Remove-
AzResourceGroup:
Remove-AzResourceGroup -Name <target-resource-group-name>
Clean up
To commit the changes and complete the move of the NSG, delete the source NSG or resource group, use Remove-
AzResourceGroup or Remove-AzNetworkSecurityGroup:
Next steps
In this tutorial, you moved an Azure network security group from one region to another and cleaned up the source
resources. To learn more about moving resources between regions and disaster recovery in Azure, refer to:
Move resources to a new resource group or subscription
Move Azure VMs to another region
Move an Azure virtual network to another region by
using the Azure portal
11/2/2020 • 5 minutes to read • Edit Online
There are various scenarios for moving an existing Azure virtual network from one region to another. For example,
you might want to create a virtual network with the same configuration for testing and availability as your existing
virtual network. Or you might want to move a production virtual network to another region as part of your disaster
recovery planning.
You can use an Azure Resource Manager template to complete the move of the virtual network to another region.
You do this by exporting the virtual network to a template, modifying the parameters to match the destination
region, and then deploying the template to the new region. For more information about Resource Manager
templates, see Quickstart: Create and deploy Azure Resource Manager templates by using the Azure portal.
Prerequisites
Make sure that your virtual network is in the Azure region that you want to move from.
To export a virtual network and deploy a template to create a virtual network in another region, you need to
have the Network Contributor role or higher.
Virtual network peerings won't be re-created, and they'll fail if they're still present in the template. Before
you export the template, you have to remove any virtual network peers. You can then reestablish them after
the virtual network move.
Identify the source networking layout and all the resources that you're currently using. This layout includes
but isn't limited to load balancers, network security groups (NSGs), and public IPs.
Verify that your Azure subscription allows you to create virtual networks in the target region. To enable the
required quota, contact support.
Make sure that your subscription has enough resources to support the addition of virtual networks for this
process. For more information, see Azure subscription and service limits, quotas, and constraints.
7. In the editor, change the source virtual network name value in the editor to a name that you want for the
target virtual network. Be sure to enclose the name in quotation marks.
8. Select Save in the editor.
9. To open the template.json file in the online editor, select Template > Edit template .
10. In the online editor, to edit the target region where the virtual network will be moved, change the location
property under resources :
"resources": [
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2019-06-01",
"name": "[parameters('virtualNetworks_myVNET1_name')]",
"location": "<target-region>",
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "6e2652be-35ac-4e68-8c70-621b9ec87dcb",
"addressSpace": {
"addressPrefixes": [
"10.0.0.0/16"
]
},
11. To obtain region location codes, see Azure Locations. The code for a region is the region name, without
spaces (for example, Central US = centralus ).
12. (Optional) You can also change other parameters in the template, depending on your requirements:
Address Space : Before you save the file, you can alter the address space of the virtual network by
modifying the resources > addressSpace section and changing the addressPrefixes property:
"resources": [
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2019-06-01",
"name": "[parameters('virtualNetworks_myVNET1_name')]",
"location": "<target-region",
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "6e2652be-35ac-4e68-8c70-621b9ec87dcb",
"addressSpace": {
"addressPrefixes": [
"10.0.0.0/16"
]
},
Subnet : You can change or add to the subnet name and the subnet address space by changing the
template's subnets section. You can change the name of the subnet by changing the name property.
And you can change the subnet address space by changing the addressPrefix property:
"subnets": [
{
"name": "subnet-1",
"etag": "W/\"d9f6e6d6-2c15-4f7c-b01f-bed40f748dea\"",
"properties": {
"provisioningState": "Succeeded",
"addressPrefix": "10.0.0.0/24",
"delegations": [],
"privateEndpointNetworkPolicies": "Enabled",
"privateLinkServiceNetworkPolicies": "Enabled"
}
},
{
"name": "GatewaySubnet",
"etag": "W/\"d9f6e6d6-2c15-4f7c-b01f-bed40f748dea\"",
"properties": {
"provisioningState": "Succeeded",
"addressPrefix": "10.0.1.0/29",
"serviceEndpoints": [],
"delegations": [],
"privateEndpointNetworkPolicies": "Enabled",
"privateLinkServiceNetworkPolicies": "Enabled"
}
}
To change the address prefix in the template.json file, edit it in two places: in the code in the preceding
section and in the type section of the following code. Change the addressPrefix property in the
following code to match the addressPrefix property in the code in the preceding section.
"type": "Microsoft.Network/virtualNetworks/subnets",
"apiVersion": "2019-06-01",
"name": "[concat(parameters('virtualNetworks_myVNET1_name'), '/GatewaySubnet')]",
"dependsOn": [
"[resourceId('Microsoft.Network/virtualNetworks',
parameters('virtualNetworks_myVNET1_name'))]"
],
"properties": {
"provisioningState": "Succeeded",
"addressPrefix": "10.0.1.0/29",
"serviceEndpoints": [],
"delegations": [],
"privateEndpointNetworkPolicies": "Enabled",
"privateLinkServiceNetworkPolicies": "Enabled"
}
},
{
"type": "Microsoft.Network/virtualNetworks/subnets",
"apiVersion": "2019-06-01",
"name": "[concat(parameters('virtualNetworks_myVNET1_name'), '/subnet-1')]",
"dependsOn": [
"[resourceId('Microsoft.Network/virtualNetworks',
parameters('virtualNetworks_myVNET1_name'))]"
],
"properties": {
"provisioningState": "Succeeded",
"addressPrefix": "10.0.0.0/24",
"delegations": [],
"privateEndpointNetworkPolicies": "Enabled",
"privateLinkServiceNetworkPolicies": "Enabled"
}
}
]
Next steps
In this tutorial, you moved an Azure virtual network from one region to another by using the Azure portal and then
cleaned up the unneeded source resources. To learn more about moving resources between regions and disaster
recovery in Azure, see:
Move resources to a new resource group or subscription
Move Azure virtual machines to another region
Move an Azure virtual network to another region by
using Azure PowerShell
11/2/2020 • 5 minutes to read • Edit Online
There are various scenarios for moving an existing Azure virtual network from one region to another. For example,
you might want to create a virtual network with the same configuration for testing and availability as your existing
virtual network. Or you might want to move a production virtual network to another region as part of your disaster
recovery planning.
You can use an Azure Resource Manager template to complete the move of the virtual network to another region.
You do this by exporting the virtual network to a template, modifying the parameters to match the destination
region, and then deploying the template to the new region. For more information about Resource Manager
templates, see Export resource groups to templates.
Prerequisites
Make sure that your virtual network is in the Azure region that you want to move from.
To export a virtual network and deploy a template to create a virtual network in another region, you need to
have the Network Contributor role or higher.
Virtual network peerings won't be re-created, and they'll fail if they're still present in the template. Before
you export the template, you have to remove any virtual network peers. You can then reestablish them after
the virtual network move.
Identify the source networking layout and all the resources that you're currently using. This layout includes
but isn't limited to load balancers, network security groups (NSGs), and public IPs.
Verify that your Azure subscription allows you to create virtual networks in the target region. To enable the
required quota, contact support.
Make sure that your subscription has enough resources to support the addition of virtual networks for this
process. For more information, see Azure subscription and service limits, quotas, and constraints.
NOTE
This article has been updated to use the new Azure PowerShell Az module. You can still use the AzureRM module, which will
continue to receive bug fixes until at least December 2020. To learn more about the new Az module and AzureRM
compatibility, see Introducing the new Azure PowerShell Az module. For Az module installation instructions, see Install Azure
PowerShell.
To export the virtual network and deploy the target virtual network by using PowerShell, do the following:
1. Sign in to your Azure subscription with the Connect-AzAccount command, and then follow the on-screen
directions:
Connect-AzAccount
2. Obtain the resource ID of the virtual network that you want to move to the target region, and then place it in
a variable by using Get-AzVirtualNetwork:
3. Export the source virtual network to a .json file in the directory where you execute the command Export-
AzResourceGroup:
4. The downloaded file has the same name as the resource group that the resource was exported from. Locate
the <resource-group-name>.json file, which you exported with the command, and then open it in your
editor:
notepad <source-resource-group-name>.json
5. To edit the parameter of the virtual network name, change the defaultValue property of the source virtual
network name to the name of your target virtual network. Be sure to enclose the name in quotation marks.
"$schema": "https://schema.management.azure.com/schemas/2015-01-
01/deploymentmyResourceGroupVNET.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"virtualNetworks_myVNET1_name": {
"defaultValue": "<target-virtual-network-name>",
"type": "String"
}
6. To edit the target region where the virtual network will be moved, change the location property under
resources:
"resources": [
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2019-06-01",
"name": "[parameters('virtualNetworks_myVNET1_name')]",
"location": "<target-region>",
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "6e2652be-35ac-4e68-8c70-621b9ec87dcb",
"addressSpace": {
"addressPrefixes": [
"10.0.0.0/16"
]
},
7. To obtain region location codes, you can use the Azure PowerShell cmdlet Get-AzLocation by running the
following command:
Get-AzLocation | format-table
8. (Optional) You can also change other parameters in the <resource-group-name>.json file, depending on
your requirements:
Address Space : Before you save the file, you can alter the address space of the virtual network by
modifying the resources > addressSpace section and changing the addressPrefixes property:
"resources": [
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2019-06-01",
"name": "[parameters('virtualNetworks_myVNET1_name')]",
"location": "<target-region",
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "6e2652be-35ac-4e68-8c70-621b9ec87dcb",
"addressSpace": {
"addressPrefixes": [
"10.0.0.0/16"
]
},
Subnet : You can change or add to the subnet name and the subnet address space by changing the
file's subnets section. You can change the name of the subnet by changing the name property. And
you can change the subnet address space by changing the addressPrefix property:
"subnets": [
{
"name": "subnet-1",
"etag": "W/\"d9f6e6d6-2c15-4f7c-b01f-bed40f748dea\"",
"properties": {
"provisioningState": "Succeeded",
"addressPrefix": "10.0.0.0/24",
"delegations": [],
"privateEndpointNetworkPolicies": "Enabled",
"privateLinkServiceNetworkPolicies": "Enabled"
}
},
{
"name": "GatewaySubnet",
"etag": "W/\"d9f6e6d6-2c15-4f7c-b01f-bed40f748dea\"",
"properties": {
"provisioningState": "Succeeded",
"addressPrefix": "10.0.1.0/29",
"serviceEndpoints": [],
"delegations": [],
"privateEndpointNetworkPolicies": "Enabled",
"privateLinkServiceNetworkPolicies": "Enabled"
}
}
To change the address prefix, edit the file in two places: in the code in the preceding section and in the
type section of the following code. Change the addressPrefix property in the following code to
match the addressPrefix property in the code in the preceding section.
"type": "Microsoft.Network/virtualNetworks/subnets",
"apiVersion": "2019-06-01",
"name": "[concat(parameters('virtualNetworks_myVNET1_name'), '/GatewaySubnet')]",
"dependsOn": [
"[resourceId('Microsoft.Network/virtualNetworks',
parameters('virtualNetworks_myVNET1_name'))]"
],
"properties": {
"provisioningState": "Succeeded",
"addressPrefix": "10.0.1.0/29",
"serviceEndpoints": [],
"delegations": [],
"privateEndpointNetworkPolicies": "Enabled",
"privateLinkServiceNetworkPolicies": "Enabled"
}
},
{
"type": "Microsoft.Network/virtualNetworks/subnets",
"apiVersion": "2019-06-01",
"name": "[concat(parameters('virtualNetworks_myVNET1_name'), '/subnet-1')]",
"dependsOn": [
"[resourceId('Microsoft.Network/virtualNetworks',
parameters('virtualNetworks_myVNET1_name'))]"
],
"properties": {
"provisioningState": "Succeeded",
"addressPrefix": "10.0.0.0/24",
"delegations": [],
"privateEndpointNetworkPolicies": "Enabled",
"privateLinkServiceNetworkPolicies": "Enabled"
}
}
]
11. Deploy the edited <resource-group-name>.json file to the resource group that you created in the previous
step by using New-AzResourceGroupDeployment:
12. To verify that the resources were created in the target region, use Get-AzResourceGroup and Get-
AzVirtualNetwork:
Clean up
To commit your changes and complete the virtual network move, do either of the following:
Delete the resource group by using Remove-AzResourceGroup:
Next steps
In this tutorial, you moved a virtual network from one region to another by using PowerShell and then cleaned up
the unneeded source resources. To learn more about moving resources between regions and disaster recovery in
Azure, see:
Move resources to a new resource group or subscription
Move Azure virtual machines to another region
Move Azure Public IP configuration to another region
using the Azure portal
11/2/2020 • 4 minutes to read • Edit Online
There are various scenarios in which you'd want to move your existing Azure Public IP configurations from one
region to another. For example, you may want to create a public IP with the same configuration and sku for testing.
You may also want to move a public IP configuration to another region as part of disaster recovery planning.
Azure Public IPs are region specific and can't be moved from one region to another. You can however,
use an Azure Resource Manager template to export the existing configuration of a public IP. You can then stage the
resource in another region by exporting the public IP to a template, modifying the parameters to match the
destination region, and then deploy the template to the new region. For more information on Resource Manager
and templates, see Quickstart: Create and deploy Azure Resource Manager templates by using the Azure portal.
Prerequisites
Make sure that the Azure Public IP is in the Azure region from which you want to move.
Azure Public IPs can't be moved between regions. You'll have to associate the new public ip to resources in
the target region.
To export a public IP configuration and deploy a template to create a public IP in another region, you'll need
the Network Contributor role or higher.
Identify the source networking layout and all the resources that you're currently using. This layout includes
but isn't limited to load balancers, network security groups (NSGs), and virtual networks.
Verify that your Azure subscription allows you to create public IPs in the target region that's used. Contact
support to enable the required quota.
Make sure that your subscription has enough resources to support the addition of public IPs for this process.
See Azure subscription and service limits, quotas, and constraints.
"resources": [
{
"type": "Microsoft.Network/publicIPAddresses",
"apiVersion": "2019-06-01",
"name": "[parameters('publicIPAddresses_myPubIP_name')]",
"location": "<target-region>",
"sku": {
"name": "Basic",
"tier": "Regional"
},
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "7549a8f1-80c2-481a-a073-018f5b0b69be",
"ipAddress": "52.177.6.204",
"publicIPAddressVersion": "IPv4",
"publicIPAllocationMethod": "Dynamic",
"idleTimeoutInMinutes": 4,
"ipTags": []
}
}
]
10. To obtain region location codes, see Azure Locations. The code for a region is the region name with no
spaces, Central US = centralus .
11. You can also change other parameters in the template if you choose, and are optional depending on your
requirements:
Sku - You can change the sku of the public IP in the configuration from standard to basic or basic to
standard by altering the sku > name property in the template.json file:
"resources": [
{
"type": "Microsoft.Network/publicIPAddresses",
"apiVersion": "2019-06-01",
"name": "[parameters('publicIPAddresses_myPubIP_name')]",
"location": "<target-region>",
"sku": {
"name": "Basic",
"tier": "Regional"
},
For more information on the differences between basic and standard sku public ips, see Create,
change, or delete a public IP address:
Public IP allocation method and Idle timeout - You can change both of these options in the
template by altering the publicIPAllocationMethod property from Dynamic to Static or Static to
Dynamic . The idle timeout can be changed by altering the idleTimeoutInMinutes property to your
desired amount. The default is 4 :
"resources": [
{
"type": "Microsoft.Network/publicIPAddresses",
"apiVersion": "2019-06-01",
"name": "[parameters('publicIPAddresses_myPubIP_name')]",
"location": "<target-region>",
"sku": {
"name": "Basic",
"tier": "Regional"
},
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "7549a8f1-80c2-481a-a073-018f5b0b69be",
"ipAddress": "52.177.6.204",
"publicIPAddressVersion": "IPv4",
"publicIPAllocationMethod": "Dynamic",
"idleTimeoutInMinutes": 4,
"ipTags": []
For more information on the allocation methods and the idle timeout values, see Create, change, or
delete a public IP address.
12. Click Save in the online editor.
13. Click BASICS > Subscription to choose the subscription where the target public IP will be deployed.
14. Click BASICS > Resource group to choose the resource group where the target public IP will be deployed.
You can click Create new to create a new resource group for the target public IP. Ensure the name isn't the
same as the source resource group of the existing source public IP.
15. Verify BASICS > Location is set to the target location where you wish for the public IP to be deployed.
16. Verify under SETTINGS that the name matches the name that you entered in the parameters editor above.
17. Check the box under TERMS AND CONDITIONS .
18. Click the Purchase button to deploy the target public IP.
Discard
If you wish to discard the target public IP, delete the resource group that contains the target public IP. To do so, select
the resource group from your dashboard in the portal and select Delete at the top of the overview page.
Clean up
To commit the changes and complete the move of the public IP, delete the source public IP or resource group. To do
so, select the public IP or resource group from your dashboard in the portal and select Delete at the top of each
page.
Next steps
In this tutorial, you moved an Azure Public IP from one region to another and cleaned up the source resources. To
learn more about moving resources between regions and disaster recovery in Azure, refer to:
Move resources to a new resource group or subscription
Move Azure VMs to another region
Move Azure Public IP configuration to another region
using Azure PowerShell
11/2/2020 • 5 minutes to read • Edit Online
There are various scenarios in which you'd want to move your existing Azure Public IP configurations from one
region to another. For example, you may want to create a public IP with the same configuration and sku for testing.
You may also want to move a public IP configuration to another region as part of disaster recovery planning.
Azure Public IPs are region specific and can't be moved from one region to another. You can however,
use an Azure Resource Manager template to export the existing configuration of a public IP. You can then stage the
resource in another region by exporting the public IP to a template, modifying the parameters to match the
destination region, and then deploy the template to the new region. For more information on Resource Manager
and templates, see Export resource groups to templates
Prerequisites
Make sure that the Azure Public IP is in the Azure region from which you want to move.
Azure Public IPs cannot be moved between regions. You'll have to associate the new public ip to resources in
the target region.
To export a public IP configuration and deploy a template to create a public IP in another region, you'll need
the Network Contributor role or higher.
Identify the source networking layout and all the resources that you're currently using. This layout includes
but isn't limited to load balancers, network security groups (NSGs), and virtual networks.
Verify that your Azure subscription allows you to create public IPs in the target region that's used. Contact
support to enable the required quota.
Make sure that your subscription has enough resources to support the addition of public IPs for this process.
See Azure subscription and service limits, quotas, and constraints.
NOTE
This article has been updated to use the new Azure PowerShell Az module. You can still use the AzureRM module, which will
continue to receive bug fixes until at least December 2020. To learn more about the new Az module and AzureRM
compatibility, see Introducing the new Azure PowerShell Az module. For Az module installation instructions, see Install Azure
PowerShell.
Connect-AzAccount
2. Obtain the resource ID of the public IP you want to move to the target region and place it in a variable using
Get-AzPublicIPAddress:
3. Export the source virtual network to a .json file into the directory where you execute the command Export-
AzResourceGroup:
4. The file downloaded will be named after the resource group the resource was exported from. Locate the file
that was exported from the command named <resource-group-name>.json and open it in an editor of
your choice:
notepad <source-resource-group-name>.json
5. To edit the parameter of the public IP name, change the property defaultValue of the source public IP name
to the name of your target public IP, ensure the name is in quotes:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"publicIPAddresses_myVM1pubIP_name": {
"defaultValue": "<target-publicip-name>",
"type": "String"
}
}
6. To edit the target region where the public IP will be moved, change the location property under resources:
"resources": [
{
"type": "Microsoft.Network/publicIPAddresses",
"apiVersion": "2019-06-01",
"name": "[parameters('publicIPAddresses_myPubIP_name')]",
"location": "<target-region>",
"sku": {
"name": "Basic",
"tier": "Regional"
},
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "7549a8f1-80c2-481a-a073-018f5b0b69be",
"ipAddress": "52.177.6.204",
"publicIPAddressVersion": "IPv4",
"publicIPAllocationMethod": "Dynamic",
"idleTimeoutInMinutes": 4,
"ipTags": []
}
}
]
7. To obtain region location codes, you can use the Azure PowerShell cmdlet Get-AzLocation by running the
following command:
Get-AzLocation | format-table
8. You can also change other parameters in the template if you choose, and are optional depending on your
requirements:
Sku - You can change the sku of the public IP in the configuration from standard to basic or basic to
standard by altering the sku > name property in the <resource-group-name>.json file:
"resources": [
{
"type": "Microsoft.Network/publicIPAddresses",
"apiVersion": "2019-06-01",
"name": "[parameters('publicIPAddresses_myPubIP_name')]",
"location": "<target-region>",
"sku": {
"name": "Basic",
"tier": "Regional"
},
For more information on the differences between basic and standard sku public ips, see Create,
change, or delete a public IP address.
Public IP allocation method and Idle timeout - You can change both of these options in the
template by altering the publicIPAllocationMethod property from Dynamic to Static or Static to
Dynamic . The idle timeout can be changed by altering the idleTimeoutInMinutes property to your
desired amount. The default is 4 :
"resources": [
{
"type": "Microsoft.Network/publicIPAddresses",
"apiVersion": "2019-06-01",
"name": "[parameters('publicIPAddresses_myPubIP_name')]",
"location": "<target-region>",
"sku": {
"name": "Basic",
"tier": "Regional"
},
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "7549a8f1-80c2-481a-a073-018f5b0b69be",
"ipAddress": "52.177.6.204",
"publicIPAddressVersion": "IPv4",
"publicIPAllocationMethod": "Dynamic",
"idleTimeoutInMinutes": 4,
"ipTags": []
}
}
For more information on the allocation methods and the idle timeout values, see Create, change, or
delete a public IP address.
9. Save the <resource-group-name>.json file.
10. Create a resource group in the target region for the target public IP to be deployed using New-
AzResourceGroup.
New-AzResourceGroup -Name <target-resource-group-name> -location <target-region>
11. Deploy the edited <resource-group-name>.json file to the resource group created in the previous step
using New-AzResourceGroupDeployment:
12. To verify the resources were created in the target region, use Get-AzResourceGroup and Get-
AzPublicIPAddress:
Discard
After the deployment, if you wish to start over or discard the public ip in the target, delete the resource group that
was created in the target and the moved public IP will be deleted. To remove the resource group, use Remove-
AzResourceGroup:
Clean up
To commit the changes and complete the move of the virtual network, delete the source virtual network or
resource group, use Remove-AzResourceGroup or Remove-AzPublicIPAddress:
Next steps
In this tutorial, you moved an Azure Public IP from one region to another and cleaned up the source resources. To
learn more about moving resources between regions and disaster recovery in Azure, refer to:
Move resources to a new resource group or subscription
Move Azure VMs to another region
Tutorial: Create a NAT gateway using Azure
PowerShell
11/2/2020 • 8 minutes to read • Edit Online
This tutorial shows you how to use Azure Virtual Network NAT service. You'll create a NAT gateway to provide
outbound connectivity for a virtual machine in Azure.
O P T IO N EXA M P L E/ L IN K
Select the Cloud Shell button on the menu bar at the upper
right in the Azure portal.
NOTE
This article has been updated to use the new Azure PowerShell Az module. You can still use the AzureRM module, which will
continue to receive bug fixes until at least December 2020. To learn more about the new Az module and AzureRM
compatibility, see Introducing the new Azure PowerShell Az module. For Az module installation instructions, see Install
Azure PowerShell.
$rsg = 'myResourceGroupNAT'
$loc = 'eastus2'
$rsg = 'myResourceGroupNAT'
$loc = 'eastus2'
$sku = 'Standard'
$pbnm = 'myPublicIP'
$publicIP =
New-AzPublicIpAddress -Name $pbnm -ResourceGroupName $rsg -AllocationMethod Static -Location $loc -Sku $sku
$rsg = 'myResourceGroupNAT'
$loc = 'eastus2'
$pxnm = 'myPublicIPprefix'
$publicIPPrefix =
New-AzPublicIpPrefix -Name $pxnm -ResourceGroupName $rsg -Location $loc -PrefixLength 31
$rsg = 'myResourceGroupNAT'
$loc = 'eastus2'
$sku = 'Standard'
$gnm = 'myNATgateway'
$natGateway =
New-AzNatGateway -Name $gnm -ResourceGroupName $rsg -PublicIpAddress $publicIP -PublicIpPrefix
$publicIPPrefix -Location $loc -Sku $sku -IdleTimeoutInMinutes 10
At this point, the NAT gateway is functional and all that is missing is to configure which subnets of a virtual
network should use it.
$sbnm = 'mySubnet'
$vnnm = 'myVnet'
$rsg = 'myResourceGroupNAT'
$loc = 'eastus2'
$pfxsub = '192.168.0.0/24'
$pfxvn = '192.168.0.0/16'
$subnet =
New-AzVirtualNetworkSubnetConfig -Name $sbnm -AddressPrefix $pfxsub -NatGateway $natGateway
$vnet =
New-AzVirtualNetwork -Name $vnnm -ResourceGroupName $rsg -Location $loc -AddressPrefix $pfxvn -Subnet $subnet
All outbound traffic to Internet destinations is now using the NAT service. It isn't necessary to configure a UDR.
$rsg = 'myResourceGroupNAT'
$loc = 'eastus2'
$ipnm = 'myPublicIPVM'
$sku = 'Standard'
$publicIpVM =
New-AzPublicIpAddress -Name $ipnm -ResourceGroupName $rsg -AllocationMethod Static -Location $loc -Sku $sku
$rnm = 'ssh'
$rdesc = 'SSH access'
$acc = 'Allow'
$pro = 'Tcp'
$dir = 'Inbound'
$pri = '100'
$prt = '22'
$rsg = 'myResourceGroupNAT'
$rnm = 'myNSG'
$loc = 'eastus2'
$sshrule =
New-AzNetworkSecurityRuleConfig -Name $rnm -Description $rdesc -Access $acc -Protocol $pro -Direction $dir -
Priority $pri -SourceAddressPrefix * -SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange
$prt
$nsg =
New-AzNetworkSecurityGroup -ResourceGroupName $rsg -Name $rnm -Location $loc -SecurityRules $sshrule
$rsg = 'myResourceGroupNAT'
$nmn = 'myNic'
$loc = 'eastus2'
$nic =
New-AzNetworkInterface -ResourceGroupName $rsg -Name $nmn -NetworkSecurityGroupID $nsg.Id -PublicIPAddressID
$publicIPVM.Id -SubnetID $vnet.Subnets[0].Id -Location $loc
Create VM
Create SSH key pair
You need an SSH key pair to complete this quickstart. If you already have an SSH key pair, you can skip this step.
Use ssh-keygen to create an SSH key pair.
For more detailed information on how to create SSH key pairs, including the use of PuTTy, see How to use SSH
keys with Windows.
If you create the SSH key pair using the Cloud Shell, the key pair is stored in a container image. This storage
account is automatically created. Don't delete the storage account, or the file share within, until after you've
retrieved your keys.
Create VM Configuration
To create a VM in PowerShell, you create a configuration that has settings for the image to use, size, and
authentication options. The configuration is used to build the VM.
Define the SSH credentials, OS information, and VM size. In this example, the SSH key is stored in
~/.ssh/id_rsa.pub.
#Define a credential object
$securePassword =
ConvertTo-SecureString ' ' -AsPlainText -Force
$cred =
New-Object System.Management.Automation.PSCredential ("azureuser", $securePassword)
$vnm = 'myVM'
$vsz = 'Standard_D1'
$pub = 'Canonical'
$off = 'UbuntuServer'
$sku = '18.04-LTS'
$ver = 'latest'
$vmConfig =
New-AzVMConfig -VMName $vnm -VMSize $vsz
Set-AzVMSourceImage -VM $vmConfig -PublisherName $pub -Offer $off -Skus $sku -Version $ver
$rsg = 'myResourceGroupNAT'
$loc = 'eastus2'
Wait for the VM to prepare to deploy then continue with the rest of the steps.
$rsg = 'myResourceGroupNAT'
$nmn = 'myPublicIPVM'
IMPORTANT
Copy the public IP address, and then paste it into a notepad so you can use it to access the VM.
Sign in to VM
The SSH credentials should be stored in your Cloud Shell from the previous operation. Open an Azure Cloud
Shell in your browser. Use the IP address retrieved in the previous step to SSH to the virtual machine.
ssh azureuser@<ip-address-destination>
Clean up resources
When no longer needed, you can use the Remove-AzResourceGroup command to remove the resource group
and all resources contained within.
Next steps
In this tutorial, you created a NAT gateway and a VM to use it.
Review metrics in Azure Monitor to see your NAT service operating. Diagnose issues such as resource exhaustion
of available SNAT ports. Resource exhaustion of SNAT ports is addressed by adding additional public IP address
resources or public IP prefix resources or both.
Learn about Azure Virtual Network NAT
Learn about NAT gateway resource.
Quickstart for deploying NAT gateway resource using Azure CLI.
Quickstart for deploying NAT gateway resource using Azure PowerShell.
Quickstart for deploying NAT gateway resource using Azure portal.
Create a NAT gateway using Azure CLI
11/2/2020 • 6 minutes to read • Edit Online
This tutorial shows you how to use Azure Virtual Network NAT service. You'll create a NAT gateway to provide
outbound connectivity for a virtual machine in Azure.
O P T IO N EXA M P L E/ L IN K
Select the Cloud Shell button on the menu bar at the upper
right in the Azure portal.
At this point, the NAT gateway is functional and all that is missing is to configure which subnets of a virtual
network should use it.
All outbound traffic to Internet destinations is now using the NAT gateway. It's not necessary to configure a UDR.
Create VM
Create the virtual machine with az vm create. We generate ssh keys for this VM and store the private key to use
later.
az vm create \
--resource-group myResourceGroupNAT \
--name myVM \
--nics myNic \
--image UbuntuLTS \
--generate-ssh-keys
Wait for the VM to deploy then continue with the rest of the steps.
IMPORTANT
Copy the public IP address, and then paste it into a notepad so you can use it to access the VM.
Sign in to VM
The SSH credentials should be stored in your Cloud Shell from the previous operation. Open an Azure Cloud Shell
in your browser. Use the IP address retrieved in the previous step to SSH to the virtual machine.
ssh <ip-address-destination>
Clean up resources
When no longer needed, you can use the az group delete command to remove the resource group and all
resources contained within.
az group delete \
--name myResourceGroupNAT
Next steps
In this tutorial, you created a NAT gateway and a VM to use it.
Review metrics in Azure Monitor to see your NAT service operating. Diagnose issues such as resource exhaustion
of available SNAT ports. Resource exhaustion of SNAT ports is addressed by adding additional public IP address
resources or public IP prefix resources or both.
Learn about Azure Virtual Network NAT
Learn about NAT gateway resource.
Quickstart for deploying NAT gateway resource using Azure CLI.
Quickstart for deploying NAT gateway resource using Azure PowerShell.
Quickstart for deploying NAT gateway resource using Azure portal.
Quickstart: Create a NAT gateway - ARM template
11/2/2020 • 5 minutes to read • Edit Online
Get started with Virtual Network NAT by using an Azure Resource Manager template (ARM template). This
template deploys a virtual network, a NAT gateway resource, and Ubuntu virtual machine. The Ubuntu virtual
machine is deployed to a subnet that is associated with the NAT gateway resource.
An ARM template is a JavaScript Object Notation (JSON) file that defines the infrastructure and configuration for
your project. The template uses declarative syntax. In declarative syntax, you describe your intended deployment
without writing the sequence of programming commands to create the deployment.
If your environment meets the prerequisites and you're familiar with using ARM templates, select the Deploy to
Azure button. The template will open in the Azure portal.
Prerequisites
If you don't have an Azure subscription, create a free account before you begin.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmname": {
"defaultValue": "myVM",
"type": "String",
"metadata": {
"description": "Name of the virtual machine"
}
},
"vmsize": {
"defaultValue": "Standard_D2s_v3",
"type": "String",
"metadata": {
"description": "Size of the virtual machine"
}
},
"vnetname": {
"defaultValue": "myVnet",
"type": "String",
"metadata": {
"description": "Name of the virtual network"
}
},
},
"subnetname": {
"defaultValue": "mySubnet",
"type": "String",
"metadata": {
"description": "Name of the subnet for virtual network"
}
},
"vnetaddressspace": {
"defaultValue": "192.168.0.0/16",
"type": "String",
"metadata": {
"description": "Address space for virtual network"
}
},
"vnetsubnetprefix": {
"defaultValue": "192.168.0.0/24",
"type": "String",
"metadata": {
"description": "Subnet prefix for virtual network"
}
},
"natgatewayname": {
"defaultValue": "myNATgateway",
"type": "String",
"metadata": {
"description": "Name of the NAT gateway"
}
},
"networkinterfacename": {
"defaultValue": "myvmNIC",
"type": "String",
"metadata": {
"description": "Name of the virtual machine nic"
}
},
"publicipname": {
"defaultValue": "myPublicIP",
"type": "String",
"metadata": {
"description": "Name of the NAT gateway public IP"
}
},
"nsgname": {
"defaultValue": "myVMnsg",
"type": "String",
"metadata": {
"description": "Name of the virtual machine NSG"
}
},
"publicipvmname": {
"defaultValue": "myPublicIPVM",
"type": "String",
"metadata": {
"description": "Name of the virtual machine public IP"
}
},
"publicipprefixname": {
"defaultValue": "myPublicIPPrefix",
"type": "String",
"metadata": {
"description": "Name of the NAT gateway public IP"
}
},
"adminusername": {
"type": "String",
"metadata": {
"description": "Administrator username for virtual machine"
}
},
},
"adminpassword": {
"type": "secureString",
"metadata": {
"description": "Administrator password for virtual machine"
}
},
"location": {
"defaultValue": "[resourceGroup().location]",
"type": "String",
"metadata": {
"description": "Name of resource group"
}
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Network/networkSecurityGroups",
"apiVersion": "2020-06-01",
"name": "[parameters('nsgname')]",
"location": "[parameters('location')]",
"properties": {
"securityRules": [
{
"name": "SSH",
"properties": {
"protocol": "TCP",
"sourcePortRange": "*",
"destinationPortRange": "22",
"sourceAddressPrefix": "*",
"destinationAddressPrefix": "*",
"access": "Allow",
"priority": 300,
"direction": "Inbound"
}
}
]
}
},
{
"type": "Microsoft.Network/publicIPAddresses",
"apiVersion": "2020-06-01",
"name": "[parameters('publicipname')]",
"location": "[parameters('location')]",
"sku": {
"name": "Standard"
},
"properties": {
"publicIPAddressVersion": "IPv4",
"publicIPAllocationMethod": "Static",
"idleTimeoutInMinutes": 4
}
},
{
"type": "Microsoft.Network/publicIPAddresses",
"apiVersion": "2020-06-01",
"name": "[parameters('publicipvmname')]",
"location": "[parameters('location')]",
"sku": {
"name": "Standard"
},
"properties": {
"publicIPAddressVersion": "IPv4",
"publicIPAllocationMethod": "Static",
"idleTimeoutInMinutes": 4
}
},
{
"type": "Microsoft.Network/publicIPPrefixes",
"apiVersion": "2020-06-01",
"name": "[parameters('publicipprefixname')]",
"location": "[parameters('location')]",
"sku": {
"name": "Standard"
},
"properties": {
"prefixLength": 31,
"publicIPAddressVersion": "IPv4"
}
},
{
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2020-06-01",
"name": "[parameters('vmname')]",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Network/networkInterfaces', parameters('networkinterfacename'))]"
],
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('vmsize')]"
},
"storageProfile": {
"imageReference": {
"publisher": "Canonical",
"offer": "UbuntuServer",
"sku": "18.04-LTS",
"version": "latest"
},
"osDisk": {
"osType": "Linux",
"name": "[concat(parameters('vmname'), '_disk1')]",
"createOption": "FromImage",
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Premium_LRS"
},
"diskSizeGB": 30
}
},
"osProfile": {
"computerName": "[parameters('vmname')]",
"adminUsername": "[parameters('adminusername')]",
"adminPassword": "[parameters('adminpassword')]",
"linuxConfiguration": {
"disablePasswordAuthentication": false,
"provisionVMAgent": true
},
"allowExtensionOperations": true
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', parameters('networkinterfacename'))]"
}
]
}
}
},
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2020-06-01",
"name": "[parameters('vnetname')]",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Network/natGateways', parameters('natgatewayname'))]"
],
"properties": {
"addressSpace": {
"addressPrefixes": [
"[parameters('vnetaddressspace')]"
]
},
"subnets": [
{
"name": "[parameters('subnetname')]",
"properties": {
"addressPrefix": "[parameters('vnetsubnetprefix')]",
"natGateway": {
"id": "[resourceId('Microsoft.Network/natGateways', parameters('natgatewayname'))]"
},
"privateEndpointNetworkPolicies": "Enabled",
"privateLinkServiceNetworkPolicies": "Enabled"
}
}
],
"enableDdosProtection": false,
"enableVmProtection": false
}
},
{
"type": "Microsoft.Network/natGateways",
"apiVersion": "2020-06-01",
"name": "[parameters('natgatewayname')]",
"location": "[parameters('location')]",
"sku": {
"name": "Standard"
},
"dependsOn": [
"[resourceId('Microsoft.Network/publicIPAddresses', parameters('publicipname'))]",
"[resourceId('Microsoft.Network/publicIPPrefixes', parameters('publicipprefixname'))]"
],
"properties": {
"idleTimeoutInMinutes": 4,
"publicIpAddresses": [
{
"id": "[resourceId('Microsoft.Network/publicIPAddresses', parameters('publicipname'))]"
}
],
"publicIpPrefixes": [
{
"id": "[resourceId('Microsoft.Network/publicIPPrefixes', parameters('publicipprefixname'))]"
}
]
}
},
{
"type": "Microsoft.Network/virtualNetworks/subnets",
"apiVersion": "2020-05-01",
"name": "[concat(parameters('vnetname'), '/mySubnet')]",
"dependsOn": [
"[resourceId('Microsoft.Network/virtualNetworks', parameters('vnetname'))]",
"[resourceId('Microsoft.Network/natGateways', parameters('natgatewayname'))]"
],
"properties": {
"addressPrefix": "[parameters('vnetsubnetprefix')]",
"natGateway": {
"id": "[resourceId('Microsoft.Network/natGateways', parameters('natgatewayname'))]"
},
"privateEndpointNetworkPolicies": "Enabled",
"privateLinkServiceNetworkPolicies": "Enabled"
}
},
{
"type": "Microsoft.Network/networkInterfaces",
"apiVersion": "2020-06-01",
"apiVersion": "2020-06-01",
"name": "[parameters('networkinterfacename')]",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Network/publicIPAddresses', parameters('publicipvmname'))]",
"[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('vnetname'), 'mySubnet')]",
"[resourceId('Microsoft.Network/networkSecurityGroups', parameters('nsgname'))]"
],
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAddress": "192.168.0.4",
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses', parameters('publicipvmname'))]"
},
"subnet": {
"id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('vnetname'),
'mySubnet')]"
},
"primary": true,
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false,
"enableIPForwarding": false,
"networkSecurityGroup": {
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', parameters('nsgname'))]"
}
}
}
]
}
az group create \
--name $resourceGroupName \
--location $location
Azure PowerShell
$resourceGroupName = "myResourceGroupNAT"
az group delete \
--name myResourceGroupNAT
Azure PowerShell
When no longer needed, you can use the Remove-AzResourceGroup command to remove the resource group and
all resources contained within.
Next steps
In this quickstart, you created a:
NAT gateway resource
Virtual network
Ubuntu virtual machine
The virtual machine is deployed to a virtual network subnet associated with the NAT gateway.
To learn more about Virtual Network NAT and Azure Resource Manager, continue to the articles below.
Read an Overview of Virtual Network NAT
Read about the NAT Gateway resource
Learn more about Azure Resource Manager
Tutorial: Create a NAT gateway using Azure
PowerShell and test the NAT service
11/2/2020 • 13 minutes to read • Edit Online
In this tutorial, you'll create a NAT gateway to provide outbound connectivity for virtual machines in Azure. To test
the NAT gateway, you deploy a source and destination virtual machine. You'll test the NAT gateway by making
outbound connections to a public IP address. These connections will come from the source to the destination
virtual machine. This tutorial deploys source and destination in two different virtual networks in the same resource
group for simplicity.
O P T IO N EXA M P L E/ L IN K
Select the Cloud Shell button on the menu bar at the upper
right in the Azure portal.
NOTE
This article has been updated to use the new Azure PowerShell Az module. You can still use the AzureRM module, which will
continue to receive bug fixes until at least December 2020. To learn more about the new Az module and AzureRM
compatibility, see Introducing the new Azure PowerShell Az module. For Az module installation instructions, see Install Azure
PowerShell.
Create a resource group
Create a resource group with az group create. An Azure resource group is a logical container into which Azure
resources are deployed and managed.
The following example creates a resource group named myResourceGroupNAT in the eastus2 location:
$rgname = 'myResourceGroupNAT'
$loc = 'eastus2'
$pipname = 'myPublicIPsource'
$alm = 'Static'
$sku = 'Standard'
$publicIPsource =
New-AzPublicIpAddress -Name $pipname -ResourceGroupName $rg.ResourceGroupName -AllocationMethod $alm -Sku $sku
-Location $rg.Location
$prefixname = 'mypublicIPprefixsource'
$publicIPPrefixsource =
New-AzPublicIpPrefix -Name $prefixname -ResourceGroupName $rg.ResourceGroupName -PrefixLength 31 -Location
$rg.Location
$natGateway =
New-AzNatGateway -Name $natname -ResourceGroupName $rg.ResourceGroupName -PublicIpAddress $publicIPsource -
PublicIpPrefix $publicIPPrefixsource -Sku $sku -IdleTimeoutInMinutes 10 -Location $rg.Location
At this point, the NAT gateway is functional and all that is missing is to configure which subnets of a virtual
network should use it.
$subnetname = 'mySubnetsource'
$subnetprefix = '192.168.0.0/24'
$vnetname = 'myVnetsource'
$vnetprefix = '192.168.0.0/16'
$subnetsource =
New-AzVirtualNetworkSubnetConfig -Name $subnetname -AddressPrefix $subnetprefix -NatGateway $natGateway
$vnetsource =
New-AzVirtualNetwork -Name $vnetname -ResourceGroupName $rg.ResourceGroupName -AddressPrefix $vnetprefix -
Subnet $subnetsource -Location $rg.Location
All outbound traffic to Internet destinations is now using the NAT service. It isn't necessary to configure a UDR.
Before we can test the NAT gateway, we need to create a source VM. We'll assign a public IP address resource as an
instance-level Public IP to access this VM from the outside. This address is only used to access it for the test. We'll
demonstrate how the NAT service takes precedence over other outbound options.
You could also create this VM without a public IP and create another VM to use as a jumpbox without a public IP as
an exercise.
Create public IP for source VM
We create a public IP to be used to access the VM. Use New-AzPublicIpAddress to create a public IP address
resource named myPublicIPVM in myResourceGroupNAT . The result of this command will be stored in a
variable named $publicIpsourceVM for later use.
$sku = 'Standard'
$pipvmname = 'myPublicIpsourceVM'
$alm = 'Static'
$publicIpsourceVM =
New-AzPublicIpAddress -Name $pipvmname -ResourceGroupName $rg.ResourceGroupName -AllocationMethod $alm -sku
$sku -Location $rg.Location
$rnm = 'ssh'
$rdsc = 'SSH access'
$acc = 'Allow'
$prt = 'Tcp'
$dir = 'Inbound'
$nsnm = 'myNSGsource'
$sshrule =
New-AzNetworkSecurityRuleConfig -Name $rnm -Description $rdsc -Access $acc -Protocol $prt -Direction $dir -
Priority 100 -SourceAddressPrefix * -SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange 22
$nsgsource =
New-AzNetworkSecurityGroup -ResourceGroupName $rg.ResourceGroupName -Name $nsnm -SecurityRules $sshrule -
Location $rg.Location
$nin = 'myNicsource'
$nicsource =
New-AzNetworkInterface -ResourceGroupName $rg.ResourceGroupName -Name $nin -NetworkSecurityGroupID
$nsgsource.Id -PublicIPAddressID $publicIPVMsource.Id -SubnetID $vnetsource.Subnets[0].Id -Location
$rg.Location
Create a source VM
Create SSH key pair
You need an SSH key pair to complete this quickstart. If you already have an SSH key pair, you can skip this step.
Use ssh-keygen to create an SSH key pair.
For more detailed information on how to create SSH key pairs, including the use of PuTTy, see How to use SSH
keys with Windows.
If you create the SSH key pair using the Cloud Shell, the key pair is stored in a container image. This storage
account is automatically created. Don't delete the storage account, or the file share within, until after you've
retrieved your keys.
Create VM Configuration
To create a VM in PowerShell, you create a configuration that has settings like the image to use, size, and
authentication options. Then the configuration is used to build the VM.
Define the SSH credentials, OS information, and VM size. In this example, the SSH key is stored in
~/.ssh/id_rsa.pub.
$securePassword =
ConvertTo-SecureString ' ' -AsPlainText -Force
$cred =
New-Object System.Management.Automation.PSCredential ("azureuser", $securePassword)
$vmConfigsource =
New-AzVMConfig -VMName $vmn -VMSize $vms
Set-AzVMSourceImage -VM $vmConfigsource -PublisherName $pub -Offer $off -Skus $skus -Version $ver
While the command will return immediately, it may take a few minutes for the VM to get deployed.
$sbdn = 'mySubnetdestination'
$spfx = '192.168.0.0/24'
$vdn = 'myVnetdestination'
$vpfx = '192.168.0.0/16'
$subnetdestination =
New-AzVirtualNetworkSubnetConfig -Name $sbdn -AddressPrefix $spfx
$vnetdestination =
New-AzVirtualNetwork -Name $vdn -ResourceGroupName $rg.ResourceGroupName -AddressPrefix $vpfx -Subnet
$subnetdestination -Location $rg.Location
$sku = 'Standard'
$all = 'Static'
$pipd = 'myPublicIPdestinationVM'
$publicIpdestinationVM =
New-AzPublicIpAddress -Name $pipd -ResourceGroupName $rg.ResourceGroupName -AllocationMethod $all -Sku $sku -
Location $rg.Location
$sshrule =
New-AzNetworkSecurityRuleConfig -Name $snm -Description $sdsc -Access $acc -Protocol $prt -Direction $dir -
Priority 100 -SourceAddressPrefix * -SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange 22
$httprule =
New-AzNetworkSecurityRuleConfig -Name $hnm -Description $hdsc -Access $acc -Protocol $prt -Direction $dir -
Priority 101 -SourceAddressPrefix * -SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange 80
$nsgdestination =
New-AzNetworkSecurityGroup -ResourceGroupName $rg.ResourceGroupName -Name $nsnm -SecurityRules
$sshrule,$httprule -Location $rg.Location
$nnm = 'myNicdestination'
$nicdestination =
New-AzNetworkInterface -ResourceGroupName $rg.ResourceGroupName -Name $nnm -NetworkSecurityGroupID
$nsgdestination.Id -PublicIPAddressID $publicIPdestinationVM.Id -SubnetID $vnetdestination.Subnets[0].Id -
Location $rg.Location
Create a destination VM
Create VM Configuration
To create a VM in PowerShell, you create a configuration that has settings like the image to use, size, and
authentication options. Then the configuration is used to build the VM.
Define the SSH credentials, OS information, and VM size. In this example, the SSH key is stored in
~/.ssh/id_rsa.pub.
# Define a credential object
$securePassword =
ConvertTo-SecureString ' ' -AsPlainText -Force
$cred =
New-Object System.Management.Automation.PSCredential ("azureuser", $securePassword)
$vmd = 'myVMdestination'
$vms = 'Standard_DS1_v2'
$pub = 'Canonical'
$off = 'UbuntuServer'
$skus = '18.04-LTS'
$ver = 'latest'
Set-AzVMSourceImage -VM $vmConfigdestination -PublisherName $pub -Offer $off -Skus $skus -Version $ver
While the command will return immediately, it may take a few minutes for the VM to get deployed.
$pipname = 'myPublicIPdestinationVM'
$destip
IMPORTANT
Copy the public IP address, and then paste it into a notepad so you can use it in subsequent steps. Indicate this is the
destination virtual machine.
Sign in to destination VM
The SSH credentials should be stored in your Cloud Shell from the previous operation. Open an Azure Cloud Shell
in your browser. Use the IP address retrieved in the previous step to SSH to the virtual machine.
ssh azureuser@$destip
Copy and paste the following commands once you've logged in.
These commands will update your virtual machine, install nginx, and create a 100-KBytes file. This file will be
retrieved from the source VM using the NAT service.
Close the SSH session with the destination VM.
$pipname = 'myPublicIPsourceVM'
$srcip
IMPORTANT
Copy the public IP address, and then paste it into a notepad so you can use it in subsequent steps. Indicate this is the source
virtual machine.
ssh azureuser@$srcip
Copy and paste the following commands to prepare for testing the NAT service.
sudo apt -y update && \
sudo apt -y upgrade && \
sudo apt install -y nload golang && \
echo 'export GOPATH=${HOME}/go' >> .bashrc && \
echo 'export PATH=${PATH}:${GOPATH}/bin' >> .bashrc && \
. ~/.bashrc &&
go get -u github.com/rakyll/hey
These commands will update your virtual machine, install go, install hey from GitHub, and update your shell
environment.
You're now ready to test NAT service.
You can also generate a series of requests using hey . Again, replace <ip-address-destination> with the
destination IP address you have previously copied.
This command will generate 100 requests, 10 concurrently, with a timeout of 30 seconds. The TCP connection
won't be reused. Each request will retrieve 100 Kbytes. At the end of the run, hey will report some statistics about
how well the NAT service did.
Clean up resources
When no longer needed, you can use the Remove-AzResourceGroup command to remove the resource group and
all resources contained within.
Next steps
In this tutorial, you created a NAT gateway, created a source and destination VM, and then tested the NAT gateway.
Review metrics in Azure Monitor to see your NAT service operating. Diagnose issues such as resource exhaustion
of available SNAT ports. Resource exhaustion of SNAT ports is easily addressed by adding additional public IP
address resources or public IP prefix resources or both.
Learn about Virtual Network NAT
Learn about NAT gateway resource.
Quickstart for deploying NAT gateway resource using Azure CLI.
Quickstart for deploying NAT gateway resource using Azure PowerShell.
Quickstart for deploying NAT gateway resource using Azure portal.
Tutorial: Create a NAT gateway using Azure CLI and
test the NAT service
11/2/2020 • 12 minutes to read • Edit Online
In this tutorial, you'll create a NAT gateway to provide outbound connectivity for virtual machines in Azure. To test
the NAT gateway, you deploy a source and destination virtual machine. You'll test the NAT gateway by making
outbound connections to a public IP address. These connections will come from the source to the destination
virtual machine. This tutorial deploys source and destination in two different virtual networks in the same resource
group for simplicity only.
O P T IO N EXA M P L E/ L IN K
Select the Cloud Shell button on the menu bar at the upper
right in the Azure portal.
az group create \
--name myResourceGroupNAT \
--location eastus2
At this point, the NAT gateway is functional and all that is missing is to configure which subnets of a virtual
network should use it.
Prepare the source for outbound traffic
We'll guide you through setup of a full test environment. You'll set up a test using open-source tools to verify the
NAT gateway. We'll start with the source, which will use the NAT gateway we created previously.
Configure virtual network for source
Before you deploy a VM and can test your NAT gateway, we need to create the virtual network.
Create a virtual network named myVnetsource with a subnet named mySubnetsource in the
myResourceGroupNAT using az network Microsoft Azure Virtual Network create. The IP address space for the
virtual network is 192.168.0.0/16 . The subnet within the virtual network is 192.168.0.0/24 .
All outbound traffic to Internet destinations is now using the NAT service. It's not necessary to configure a UDR.
Before we can test the NAT gateway, we need to create a source VM. We'll assign a public IP address resource as an
instance-level public IP to access this VM from the outside. This address is only used to access it for the test. We'll
demonstrate how the NAT service takes precedence over other outbound options.
You could also create this VM without a public IP and create another VM to use as a jumpbox without a public IP as
an exercise.
Create public IP for source VM
We create a public IP to be used to access the source VM. Use az network public-ip create to create a public IP
address resource named myPublicIPsourceVM in myResourceGroupNAT .
Create a source VM
Create the virtual machine with az vm create. We generate ssh keys for this VM and store the private key to use
later.
az vm create \
--resource-group myResourceGroupNAT \
--name myVMsource \
--nics myNicsource \
--image UbuntuLTS \
--generate-ssh-keys \
--no-wait
While the command will return immediately, it may take a few minutes for the VM to get deployed.
Create a destination VM
Create the virtual machine with az vm create. We generate ssh keys for this VM and store the private key to use
later.
az vm create \
--resource-group myResourceGroupNAT \
--name myVMdestination \
--nics myNicdestination \
--image UbuntuLTS \
--generate-ssh-keys \
--no-wait
While the command will return immediately, it may take a few minutes for the VM to get deployed.
IMPORTANT
Copy the public IP address, and then paste it into a notepad so you can use it in subsequent steps. Indicate this is the
destination virtual machine.
Sign in to destination VM
The SSH credentials should be stored in your Cloud Shell from the previous operation. Open an Azure Cloud Shell
in your browser. Use the IP address retrieved in the previous step to SSH to the virtual machine.
ssh <ip-address-destination>
Copy and paste the following commands once you've signed in.
These commands will update your virtual machine, install nginx, and create a 100-KBytes file. This file will be
retrieved from the source VM using the NAT service.
Close the SSH session with the destination VM.
IMPORTANT
Copy the public IP address, and then paste it into a notepad so you can use it in subsequent steps. Indicate this is the
source virtual machine.
Sign in to source VM
Again, the SSH credentials are stored in Cloud Shell. Open a new tab for Azure Cloud Shell in your browser. Use
the IP address retrieved in the previous step to SSH to the virtual machine.
ssh <ip-address-source>
Copy and paste the following commands to prepare for testing the NAT service.
sudo apt -y update && \
sudo apt -y upgrade && \
sudo apt install -y nload golang && \
echo 'export GOPATH=${HOME}/go' >> .bashrc && \
echo 'export PATH=${PATH}:${GOPATH}/bin' >> .bashrc && \
. ~/.bashrc &&
go get -u github.com/rakyll/hey
This command will update your virtual machine, install go, install hey from GitHub, and update your shell
environment.
You're now ready to test the NAT service.
You can also generate a series of requests using hey . Again, replace <ip-address-destination> with the
destination IP address you have previously copied.
This command will generate 100 requests, 10 concurrently, with a timeout of 30 seconds. The TCP connection
won't be reused. Each request will retrieve 100 Kbytes. At the end of the run, hey will report some statistics about
how well the NAT service did.
Clean up resources
When no longer needed, you can use the az group delete command to remove the resource group and all
resources contained within.
Next steps
In this tutorial, you created a NAT gateway, created a source and destination VM, and then tested the NAT gateway.
Review metrics in Azure Monitor to see your NAT service operating. Diagnose issues such as resource exhaustion
of available SNAT ports. Resource exhaustion of SNAT ports is easily addressed by adding additional public IP
address resources or public IP prefix resources or both.
Learn about Virtual Network NAT
Learn about NAT gateway resource.
Quickstart for deploying NAT gateway resource using Azure CLI.
Quickstart for deploying NAT gateway resource using Azure PowerShell.
Quickstart for deploying NAT gateway resource using Azure portal.
Troubleshoot virtual network peering issues
5/19/2020 • 7 minutes to read • Edit Online
This troubleshooting guide provides steps to help you resolve most virtual network peering issues.
NOTE
Connectivity doesn't work over global virtual network peering for the following resources:
Virtual machines (VMs) behind Basic internal load balancer (ILB) SKU
Redis cache (uses Basic ILB SKU)
Application gateway (uses Basic ILB SKU)
Virtual machine scale sets (uses Basic ILB SKU)
Azure Service Fabric clusters (uses Basic ILB SKU)
SQL Server Always On (uses Basic ILB SKU)
Azure App Service Environment for PowerApps (uses Basic ILB SKU)
Azure API Management (uses Basic ILB SKU)
Azure Active Directory Domain Services (Azure AD DS) (uses Basic ILB SKU)
For more information, see the requirements and constraints of global peering.
The virtual networks are in different subscriptions or Active Directory tenants
To configure virtual network peering for virtual networks in different subscriptions or Active Directory tenants, see
Create peering in different subscriptions for Azure CLI.
NOTE
To configure network peering, you must have Network Contributor permissions in both subscriptions. For more
information, see Peering permissions.
NOTE
If you require help to set up an NVA, contact the NVA vendor.
For help with troubleshooting the NVA device setup and routing, see Network virtual appliance issues in Azure.
The virtual networks are in different regions
Transit over global virtual network peering is now supported. Connectivity does not work over global virtual
network peering for the following resources:
VMs behind Basic ILB SKU
Redis cache (uses Basic ILB SKU)
Application gateway (uses Basic ILB SKU)
Scale sets (uses Basic ILB SKU)
Service Fabric clusters (uses Basic ILB SKU)
SQL Server Always On (uses Basic ILB SKU)
App Service Environment (uses Basic ILB SKU)
API Management (uses Basic ILB SKU)
Azure AD DS (uses Basic ILB SKU)
To learn more about global peering requirements and restraints, see Virtual network peering.
c. After the TcpPing is complete, stop the network trace on the destination.
d. If packets arrive from the source, there is no networking issue. Examine both the VM firewall and the
application listening on that port to locate the configuration issue.
NOTE
You can't connect to the following resource types over global virtual network peering (virtual networks in different
regions):
VMs behind Basic ILB SKU
Redis cache (uses Basic ILB SKU)
Application gateway (uses Basic ILB SKU)
Scale sets (uses Basic ILB SKU)
Service Fabric clusters (uses Basic ILB SKU)
SQL Server Always On (uses Basic ILB SKU)
App Service Environment (uses Basic ILB SKU)
API Management (uses Basic ILB SKU)
Azure AD DS (uses Basic ILB SKU)
For more information, see the requirements and constraints of global peering.
The peering status is "Disconnected"
To resolve this issue, delete the peering from both virtual networks, and then re-create them.
Next steps
Troubleshooting connectivity problems between Azure VMs
Configure and validate virtual network or VPN
connections
11/2/2020 • 15 minutes to read • Edit Online
This walkthrough provides step-by-step guidance to configure and validate various Azure VPN and virtual network
deployments. Scenarios include transit routing, network-to-network connections, Border Gateway Protocol (BGP),
multisite connections, and point-to-site connections.
Azure VPN gateways enable flexibility in arranging almost any kind of connected virtual network topology in Azure.
For example, you can connect virtual networks:
Across regions.
Between virtual network types (Azure Resource Manager versus classic).
Within Azure or within an on-premises hybrid environment.
In different subscriptions.
If your virtual networks are in the same region, you might want to consider connecting them by using virtual
network peering. Virtual network peering doesn't use a VPN gateway. It increases throughput and decreases
latency. To configure a virtual network peering connection, select Configure and validate VNet Peering .
If your virtual networks were created through the Azure Resource Manger deployment model, select Configure
and validate a Resource Manager VNet to a Resource Manager VNet connection to configure a VPN
connection.
If one of the virtual networks was created through the Azure classic deployment model, and the other was created
through Resource Manager, select Configure and validate a classic VNet to a Resource Manager VNet
connection to configure a VPN connection.
Configure virtual network peering for two virtual networks in the same region
Before you start to implement and configure Azure virtual network peering, make sure that you meet the following
prerequisites:
The peered virtual networks must exist in the same Azure region.
The peered virtual networks must have IP address spaces that don't overlap.
Virtual network peering is between two virtual networks. There's no derived transitive relationship across
peerings. For example, if VNetA is peered with VNetB, and VNetB is peered with VNetC, VNetA is not peered
with VNetC.
When you meet the requirements, you can follow Tutorial: Connect virtual networks with virtual network peering
by using the Azure portal to create and configure the peering.
To check the peering configuration, use the following method:
1. Sign in to the Azure portal by using an account that has the necessary roles and permissions.
2. In the box that contains the text Search resources at the top of the portal, type vir tual networks . When
Vir tual networks appears in the search results, select it.
3. In the Vir tual networks blade that appears, select the virtual network for which you want to create a peering.
4. In the pane that appears for the virtual network, select Peerings in the Settings section.
5. Select a peering and view the configuration results.
For Azure PowerShell, run the command Get-AzureRmVirtualNetworkPeering to get the virtual network peering.
Here's an example:
Connect a Resource Manager virtual network to another Resource Manager virtual network
You can configure a connection from one Resource Manager virtual network to another Resource Manager virtual
network directly. Or you can configure the connection by using IPsec.
Configure a VPN connection between Resource Manager virtual networks
To configure a connection between Resource Manager virtual networks without IPsec, see Configure a network-to-
network VPN gateway connection by using the Azure portal.
To configure a connection with IPsec between two Resource Manager virtual networks, follow steps 1 to 5 in Create
a site-to-site connection in the Azure portal for each virtual network.
NOTE
These steps work only for virtual networks in the same subscription. If your virtual networks are in different subscriptions,
you must use PowerShell to make the connection. See the PowerShell article.
To check that your VPN connection is configured correctly, follow these instructions.
NOTE
The numbers after virtual network components in these steps correspond to the numbers in the preceding diagram.
1. Make sure there are no overlapping address spaces in the connected virtual networks.
2. Verify that the address range for the Azure Resource Manager virtual network (1) is defined accurately in the
Connection object instance (4).
3. Verify that the address range for the Azure Resource Manager virtual network (6) is defined accurately in the
Connection object instance (3).
4. Verify that the pre-shared keys are matching on the connection objects.
5. Verify that the Azure Resource Manager virtual network gateway VIP (2) is defined accurately in the
Connection object instance (4).
6. Verify that the Azure Resource Manager virtual network gateway VIP (5) is defined accurately in the
Connection object instance (3).
Connect a classic virtual network to a Resource Manager virtual network
You can create a connection between virtual networks that are in different subscriptions and in different regions.
You can also connect virtual networks that already have connections to on-premises networks, as long as you have
configured the gateway type as route-based.
To configure a connection between a classic virtual network and a Resource Manager virtual network, see Connect
virtual networks from different deployment models by using the Azure portal.
To check the configuration when you connect a classic virtual network to an Azure Resource Manager virtual
network, follow these instructions.
NOTE
The numbers after virtual network components in these steps correspond to the numbers in the preceding diagram.
1. Make sure there are no overlapping address spaces in the connected virtual networks.
2. Verify that the address range for the Azure Resource Manager virtual network (6) is defined accurately in the
classic local network definition (3).
3. Verify that the address range for the classic virtual network (1) is defined accurately in the Azure Resource
Manager Connection object instance (4).
4. Verify that the classic virtual network gateway VIP (2) is defined accurately in the Azure Resource Manager
Connection object instance (4).
5. Verify that the Azure Resource Manager virtual network gateway (5) is defined accurately in the classic Local
Network Definition instance (3).
6. Verify that the pre-shared keys are matching on both connected virtual networks:
Classic virtual network: Local Network Definition (3)
Azure Resource Manager virtual network: Connection object (4)
Azure currently works with two deployment models: Resource Manager and classic. The two models aren't
completely compatible with each other. To configure a multisite connection with different models, see the following
articles:
Add a site-to-site connection to a virtual network with an existing VPN gateway connection
Add a site-to-site connection to a virtual network with an existing VPN gateway connection (classic)
NOTE
The steps in those articles don't apply to Azure ExpressRoute and site-to-site coexisting connection configurations. For more
information, see ExpressRoute and site-to-site coexisting connections.
NOTE
We recommend that if VNetA and VNetB are in the same geopolitical region, you link both virtual networks to the
ExpressRoute circuit instead of configuring transit routing. If your virtual networks are in different geopolitical regions, you
can also link them to your circuit directly if you have ExpressRoute Premium.
If you have ExpressRoute and site-to-site coexistence, transit routing isn't supported. For more information, see
Configure ExpressRoute and site-to-site by using PowerShell.
If you have enabled ExpressRoute to connect your local networks to an Azure virtual network, you can enable
peering between the virtual networks where you want to have transit routing. To allow your local networks to
connect to the remote virtual network, you must configure virtual network peering.
NOTE
Virtual network peering is available only for virtual networks in the same region.
To check whether you have configured transit routing for virtual network peering, follow these instructions:
1. Sign in to the Azure portal by using an account that has the necessary roles and permissions.
2. Create a peering between VNetA and VNetB as shown in the earlier diagram.
3. In the pane that appears for the virtual network, select Peerings in the Settings section.
4. Select the peering you want to view. Then, select Configuration to validate that you have enabled Allow
Gateway Transit on the VNetA network connected to the ExpressRoute circuit and Use Remote Gateway on
the remote VNetB network not connected to the ExpressRoute circuit.
Configure transit routing in a virtual network peering connection
When virtual networks are peered, you can also configure the gateway in the peered virtual network as a transit
point to an on-premises network. To configure a transit route in virtual network peering, see Network-to-network
connections.
NOTE
Gateway transit isn't supported in the peering relationship between virtual networks created through different deployment
models. Both virtual networks in the peering relationship must have been created through Resource Manager for gateway
transit to work.
To check whether you have configured a transit route for virtual network peering, follow these instructions:
1. Sign in to the Azure portal by using an account that has the necessary roles and permissions.
2. In the box that contains the text Search resources at the top of the portal, type vir tual networks . When
Vir tual networks appears in the search results, select it.
3. In the Vir tual networks blade that appears, select the virtual network for which you want to check the peering
setting.
4. In the pane that appears for the virtual network that you selected, select Peerings in the Settings section.
5. Select the peering that you want to view. Validate that you have enabled Allow gateway transit and Use
remote gateways under Configuration .
NOTE
You configure classic network-to-network connections by using the Azure classic portal, or by using a network configuration
file in the classic portal. You can't create or modify a classic virtual network through the Azure Resource Manager deployment
model or the Azure portal. For more information on transit routing for classic virtual networks, see the Microsoft Developer
blog.
NOTE
You configure classic site-to-site connections by using the Azure classic portal, or by using a network configuration file in the
classic portal. You can't create or modify a classic virtual network through the Azure Resource Manager deployment model or
the Azure portal. For more information on transit routing for classic virtual networks, see the Microsoft Developer blog.
"Asn": AsnNumber,
"PeerWeight": 0
NOTE
When you add addresses to the local network gateway for BGP-enabled active/active mode, add only the /32 addresses of
the BGP peers. If you add more addresses, they will be considered static routes and take precedence over BGP routes.
You must use different BGP AS numbers for your on-premises networks that are connecting to Azure. (If they're the same,
you have to change your virtual network AS number if your on-premises VPN device already uses the ASN to peer with
other BGP neighbors.)
NOTE
This process will take around 60 minutes.
Next steps
Troubleshooting connectivity problems between Azure VMs
Diagnose a virtual machine network traffic filter
problem
11/2/2020 • 12 minutes to read • Edit Online
In this article, you learn how to diagnose a network traffic filter problem by viewing the network security group
(NSG) security rules that are effective for a virtual machine (VM).
NSGs enable you to control the types of traffic that flow in and out of a VM. You can associate an NSG to a subnet
in an Azure virtual network, a network interface attached to a VM, or both. The effective security rules applied to a
network interface are an aggregation of the rules that exist in the NSG associated to a network interface, and the
subnet the network interface is in. Rules in different NSGs can sometimes conflict with each other and impact a
VM's network connectivity. You can view all the effective security rules from NSGs that are applied on your VM's
network interfaces. If you're not familiar with virtual network, network interface, or NSG concepts, see Virtual
network overview, Network interface, and Network security groups overview.
Scenario
You attempt to connect to a VM over port 80 from the internet, but the connection fails. To determine why you
can't access port 80 from the Internet, you can view the effective security rules for a network interface using the
Azure portal, PowerShell, or the Azure CLI.
The steps that follow assume you have an existing VM to view the effective security rules for. If you don't have an
existing VM, first deploy a Linux or Windows VM to complete the tasks in this article with. The examples in this
article are for a VM named myVM with a network interface named myVMVMNic. The VM and network interface
are in a resource group named myResourceGroup, and are in the East US region. Change the values in the steps,
as appropriate, for the VM you are diagnosing the problem for.
Though the AzureLoadBalancer service tag only represents one prefix, other service tags represent
several prefixes.
5. The previous steps showed the security rules for a network interface named myVMVMNic , but you've also
seen a network interface named myVMVMNic2 in some of the previous pictures. The VM in this example
has two network interfaces attached to it. The effective security rules can be different for each network
interface.
To see the rules for the myVMVMNic2 network interface, select it. As shown in the picture that follows, the
network interface has the same rules associated to its subnet as the myVMVMNic network interface,
because both network interfaces are in the same subnet. When you associate an NSG to a subnet, its rules
are applied to all network interfaces in the subnet.
Unlike the myVMVMNic network interface, the myVMVMNic2 network interface does not have a
network security group associated to it. Each network interface and subnet can have zero, or one, NSG
associated to it. The NSG associated to each network interface or subnet can be the same, or different. You
can associate the same network security group to as many network interfaces and subnets as you choose.
Though effective security rules were viewed through the VM, you can also view effective security rules through an
individual:
Network interface : Learn how to view a network interface.
NSG : Learn how to view an NSG.
You can run the commands that follow in the Azure Cloud Shell, or by running PowerShell from your computer.
The Azure Cloud Shell is a free interactive shell. It has common Azure tools preinstalled and configured to use
with your account. If you run PowerShell from your computer, you need the Azure PowerShell module, version
1.0.0 or later. Run Get-Module -ListAvailable Az on your computer, 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 log into Azure with an account that has the necessary permissions].
Get the effective security rules for a network interface with Get-AzEffectiveNetworkSecurityGroup. The following
example gets the effective security rules for a network interface named myVMVMNic, that is in a resource group
named myResourceGroup:
Get-AzEffectiveNetworkSecurityGroup `
-NetworkInterfaceName myVMVMNic `
-ResourceGroupName myResourceGroup
Output is returned in json format. To understand the output, see interpret command output. Output is only
returned if an NSG is associated with the network interface, the subnet the network interface is in, or both. The VM
must be in the running state. A VM may have multiple network interfaces with different NSGs applied. When
troubleshooting, run the command for each network interface.
If you're still having a connectivity problem, see additional diagnosis and considerations.
If you don't know the name of a network interface, but do know the name of the VM the network interface is
attached to, the following commands return the IDs of all network interfaces attached to a VM:
NetworkInterfaces
-----------------
{/subscriptions/<ID>/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/myVMVMNic
Output is returned in json format. To understand the output, see interpret command output. Output is only
returned if an NSG is associated with the network interface, the subnet the network interface is in, or both. The VM
must be in the running state. A VM may have multiple network interfaces with different NSGs applied. When
troubleshooting, run the command for each network interface.
If you're still having a connectivity problem, see additional diagnosis and considerations.
If you don't know the name of a network interface, but do know the name of the VM the network interface is
attached to, the following commands return the IDs of all network interfaces attached to a VM:
az vm show \
--name myVM \
--resource-group myResourceGroup
Within the returned output, you see information similar to the following example:
"networkProfile": {
"additionalProperties": {},
"networkInterfaces": [
{
"additionalProperties": {},
"id":
"/subscriptions/<ID>/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/myVMVMNic",
"primary": true,
"resourceGroup": "myResourceGroup"
},
Resolve a problem
Whether you use the Azure portal, PowerShell, or the Azure CLI to diagnose the problem presented in the
scenario in this article, the solution is to create a network security rule with the following properties:
P RO P ERT Y VA L UE
Source Any
Protocol TCP
Action Allow
Priority 100
Name Allow-HTTP-All
After you create the rule, port 80 is allowed inbound from the internet, because the priority of the rule is higher
than the default security rule named DenyAllInBound, that denies the traffic. Learn how to create a security rule. If
different NSGs are associated to both the network interface, and the subnet, you must create the same rule in
both NSGs.
When Azure processes inbound traffic, it processes rules in the NSG associated to the subnet (if there is an
associated NSG), and then it processes the rules in the NSG associated to the network interface. If there is an NSG
associated to the network interface and the subnet, the port must be open in both NSGs, for the traffic to reach
the VM. To ease administration and communication problems, we recommend that you associate an NSG to a
subnet, rather than individual network interfaces. If VMs within a subnet need different security rules, you can
make the network interfaces members of an application security group (ASG), and specify an ASG as the source
and destination of a security rule. Learn more about application security groups.
If you're still having communication problems, see Considerations and Additional diagnosis.
Considerations
Consider the following points when troubleshooting connectivity problems:
Default security rules block inbound access from the internet, and only permit inbound traffic from the virtual
network. To allow inbound traffic from the Internet, add security rules with a higher priority than default rules.
Learn more about default security rules, or how to add a security rule.
If you have peered virtual networks, by default, the VIRTUAL_NETWORK service tag automatically expands to
include prefixes for peered virtual networks. To troubleshoot any issues related to virtual network peering, you
can view the prefixes in the ExpandedAddressPrefix list. Learn more about virtual network peering and
service tags.
Effective security rules are only shown for a network interface if there is an NSG associated with the VM's
network interface and, or, subnet, and if the VM is in the running state.
If there are no NSGs associated with the network interface or subnet, and you have a public IP address
assigned to a VM, all ports are open for inbound access from and outbound access to anywhere. If the VM has
a public IP address, we recommend applying an NSG to the subnet the network interface.
Additional diagnosis
To run a quick test to determine if traffic is allowed to or from a VM, use the IP flow verify capability of Azure
Network Watcher. IP flow verify tells you if traffic is allowed or denied. If denied, IP flow verify tells you which
security rule is denying the traffic.
If there are no security rules causing a VM's network connectivity to fail, the problem may be due to:
Firewall software running within the VM's operating system
Routes configured for virtual appliances or on-premises traffic. Internet traffic can be redirected to your
on-premises network via forced-tunneling. If you force tunnel internet traffic to a virtual appliance, or
on-premises, you may not be able to connect to the VM from the internet. To learn how to diagnose
route problems that may impede the flow of traffic out of the VM, see Diagnose a virtual machine
network traffic routing problem.
Next steps
Learn about all tasks, properties, and settings for a network security group and security rules.
Learn about default security rules, service tags, and how Azure processes security rules for inbound and
outbound traffic for a VM.
Diagnose a virtual machine routing problem
11/2/2020 • 9 minutes to read • Edit Online
In this article, you learn how to diagnose a routing problem by viewing the routes that are effective for a network
interface in a virtual machine (VM). Azure creates several default routes for each virtual network subnet. You can
override Azure's default routes by defining routes in a route table, and then associating the route table to a
subnet. The combination of routes you create, Azure's default routes, and any routes propagated from your on-
premises network through an Azure VPN gateway (if your virtual network is connected to your on-premises
network) via the border gateway protocol (BGP), are the effective routes for all network interfaces in a subnet. If
you're not familiar with virtual network, network interface, or routing concepts, see Virtual network overview,
Network interface, and Routing overview.
Scenario
You attempt to connect to a VM, but the connection fails. To determine why you can't connect to the VM, you can
view the effective routes for a network interface using the Azure portal, PowerShell, or the Azure CLI.
The steps that follow assume you have an existing VM to view the effective routes for. If you don't have an existing
VM, first deploy a Linux or Windows VM to complete the tasks in this article with. The examples in this article are
for a VM named myVM with a network interface named myVMNic1. The VM and network interface are in a
resource group named myResourceGroup, and are in the East US region. Change the values in the steps, as
appropriate, for the VM you are diagnosing the problem for.
4. On the left, select Effective routes . The effective routes for a network interface named myVMNic1 are
shown, in the following picture:
If there are multiple network interfaces attached to the VM, you can view the effective routes for any
network interface by selecting it. Since each network interface can be in a different subnet, each network
interface can have different effective routes.
In the example shown in the previous picture, the listed routes are default routes that Azure creates for
each subnet. Your list has at least these routes, but may have additional routes, depending on capabilities
you may have enabled for your virtual network such as it being peered with another virtual network or
connected to your on-premises network through an Azure VPN gateway. To learn more about each of the
routes, and other routes you may see for your network interface, see Virtual network traffic routing. If your
list has a large number of routes, you may find it easier to select Download , to download a .csv file with
the list of routes.
Though effective routes were viewed through the VM in the previous steps, you can also view effective routes
through an:
Individual network interface : Learn how to view a network interface.
Individual route table : Learn how to view a route table.
You can run the commands that follow in the Azure Cloud Shell, or by running PowerShell from your computer.
The Azure Cloud Shell is a free interactive shell. It has common Azure tools preinstalled and configured to use
with your account. If you run PowerShell from your computer, you need the Azure PowerShell module, version
1.0.0 or later. Run Get-Module -ListAvailable Az on your computer, 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 log into Azure with an account that has the necessary permissions.
Get the effective routes for a network interface with Get-AzEffectiveRouteTable. The following example gets the
effective routes for a network interface named myVMNic1, that is in a resource group named myResourceGroup:
Get-AzEffectiveRouteTable `
-NetworkInterfaceName myVMNic1 `
-ResourceGroupName myResourceGroup `
| Format-Table
To understand the information returned in the output, see Routing overview. Output is only returned if the VM is
in the running state. If there are multiple network interfaces attached to the VM, you can review the effective
routes for each network interface. Since each network interface can be in a different subnet, each network
interface can have different effective routes. If you're still having a communication problem, see additional
diagnosis and considerations.
If you don't know the name of a network interface, but do know the name of the VM the network interface is
attached to, the following commands return the IDs of all network interfaces attached to a VM:
NetworkInterfaces
-----------------
{/subscriptions/<ID>/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/myVMNic1
To understand the information returned in the output, see Routing overview. Output is only returned if the VM is
in the running state. If there are multiple network interfaces attached to the VM, you can review the effective
routes for each network interface. Since each network interface can be in a different subnet, each network
interface can have different effective routes. If you're still having a communication problem, see additional
diagnosis and considerations.
If you don't know the name of a network interface, but do know the name of the VM the network interface is
attached to, the following commands return the IDs of all network interfaces attached to a VM:
az vm show \
--name myVM \
--resource-group myResourceGroup
Resolve a problem
Resolving routing problems typically consists of:
Adding a custom route to override one of Azure's default routes. Learn how to add a custom route.
Change or remove a custom route that may cause routing to an undesired location. Learn how to change or
delete a custom route.
Ensuring that the route table that contains any custom routes you've defined is associated to the subnet the
network interface is in. Learn how to associate a route table to a subnet.
Ensuring that devices such as Azure VPN gateway or network virtual appliances you've deployed are operable.
Use the VPN diagnostics capability of Network Watcher to determine any problems with an Azure VPN
gateway.
If you're still having communication problems, see Considerations and Additional diagnosis.
Considerations
Consider the following points when troubleshooting communication problems:
Routing is based on longest prefix match (LPM) among routes that you've defined, border gateway protocol
(BGP), and system routes. If there is more than one route with the same LPM match, then a route is selected
based on its origin in the order listed in Routing overview. With effective routes, you can only see effective
routes that are an LPM match, based on all the available routes. Seeing how the routes are evaluated for a
network interface makes it a lot easier to troubleshoot specific routes that may be impacting communication
from your VM.
If you've defined custom routes to a network virtual appliance (NVA), with Virtual Appliance as the next hop
type, ensure that IP forwarding is enabled on the NVA receiving the traffic, or packets are dropped. Learn more
about enabling IP forwarding for a network interface. Additionally, the operating system, or application within
the NVA must also be able to forward network traffic and be configured to do so.
If you've created a route to 0.0.0.0/0, all outbound internet traffic is routed to the next hop you specified, such
as to an NVA or VPN gateway. Creating such a route is often referred to as forced tunneling. Remote
connections using the RDP or SSH protocols from the internet to your VM may not work with this route,
depending on how the next hop handles the traffic. Forced-tunneling can be enabled:
When using site-to-site VPN, by creating a route with a next hop type of VPN Gateway. Learn more
about configuring forced tunneling.
If a 0.0.0.0/0 (default route) is advertised over BGP through a virtual network gateway when using a
site-to-site VPN, or ExpressRoute circuit. Learn more about using BGP with a site-to-site VPN or
ExpressRoute.
For virtual network peering traffic to work correctly, a system route with a next hop type of VNet Peering must
exist for the peered virtual network's prefix range. If such a route doesn't exist, and the virtual network peering
link is Connected :
Wait a few seconds, and retry. If it's a newly established peering link, it occasionally takes longer to
propagate routes to all the network interfaces in a subnet. To learn more about virtual network peering,
see Virtual network peering overview and manage virtual network peering.
Network security group rules may be impacting communication. For more information, see Diagnose a
virtual machine network traffic filter problem.
Though Azure assigns default routes to each Azure network interface, if you have multiple network interfaces
attached to the VM, only the primary network interface is assigned a default route (0.0.0.0/0), or gateway,
within the VM's operating system. Learn how to create a default route for secondary network interfaces
attached to a Windows or Linux VM. Learn more about primary and secondary network interfaces.
Additional diagnosis
To run a quick test to determine the next hop type for traffic destined to a location, use the Next hop capability
of Azure Network Watcher. Next hop tells you what the next hop type is for traffic destined to a specified
location.
If there are no routes causing a VM's network communication to fail, the problem may be due to firewall
software running within the VM's operating system
If you are force tunneling traffic to an on-premises device through a VPN gateway, or NVA, you may not be
able to connect to a VM from the internet, depending on how you've configured routing for the devices.
Confirm that the routing you have configured for the device routes traffic to either a public or private IP
address for the VM.
Use the connection troubleshoot capability of Network Watcher to determine routing, filtering, and in-OS
causes of outbound communication problems.
Next steps
Learn about all tasks, properties, and settings for a route table and routes.
Learn about all next hop types, system routes, and how Azure selects a route.
Bandwidth/Throughput testing (NTTTCP)
11/2/2020 • 3 minutes to read • Edit Online
When testing network throughput performance in Azure, it's best to use a tool that targets the network for testing
and minimizes the use of other resources that could impact performance. NTTTCP is recommended.
Copy the tool to two Azure VMs of the same size. One VM functions as SENDER and the other as RECEIVER.
Deploying VMs for testing
For the purposes of this test, the two VMs should be in either the same Proximity Placement Group or the same
Availability Set so that we can use their internal IPs and exclude the Load Balancers from the test. It is possible to
test with the VIP but this kind of testing is outside the scope of this document.
Make a note of the RECEIVER's IP address. Let's call that IP "a.b.c.r"
Make a note of the number of cores on the VM. Let's call this "#num_cores"
Run the NTTTCP test for 300 seconds (or 5 minutes) on the sender VM and receiver VM.
Tip: When setting up this test for the first time, you might try a shorter test period to get feedback sooner. Once the
tool is working as expected, extend the test period to 300 seconds for the most accurate results.
NOTE
The sender and receiver must specify the same test duration parameter (-t).
NOTE
The preceding sample should only be used to confirm your configuration. Valid examples of testing are covered later in this
document.
ntttcp -r -t 300
Sender <Linux> :
Sender <Windows>:
<Endpoints>
<InternalEndpoint name="Endpoint3" protocol="any" />
</Endpoints>
Next steps
Depending on results, there may be room to Optimize network throughput machines for your scenario.
Read about how bandwidth is allocated to virtual machines
Learn more with Azure Virtual Network frequently asked questions (FAQ)
Test VM network latency
11/2/2020 • 5 minutes to read • Edit Online
To achieve the most accurate results, measure your Azure virtual machine (VM) network latency with a tool that's
designed for the task. Publicly available tools such as SockPerf (for Linux) and latte.exe (for Windows) can isolate
and measure network latency while excluding other types of latency, such as application latency. These tools focus
on the kind of network traffic that affects application performance (namely, Transmission Control Protocol [TCP]
and User Datagram Protocol [UDP] traffic).
Other common connectivity tools, such as Ping, might measure latency, but their results might not represent the
network traffic that's used in real workloads. That's because most of these tools employ the Internet Control
Message Protocol (ICMP), which can be treated differently from application traffic and whose results might not
apply to workloads that use TCP and UDP.
For accurate network latency testing of the protocols used by most applications, SockPerf (for Linux) and latte.exe
(for Windows) produce the most relevant results. This article covers both of these tools.
Overview
By using two VMs, one as sender and one as receiver, you create a two-way communications channel. With this
approach, you can send and receive packets in both directions and measure the round-trip time (RTT).
You can use this approach to measure network latency between two VMs or even between two physical computers.
Latency measurements can be useful for the following scenarios:
Establish a benchmark for network latency between the deployed VMs.
Compare the effects of changes in network latency after related changes are made to:
Operating system (OS) or network stack software, including configuration changes.
A VM deployment method, such as deploying to an availability zone or proximity placement group (PPG).
VM properties, such as Accelerated Networking or size changes.
A virtual network, such as routing or filtering changes.
Tools for testing
To measure latency, you have two different tool options:
For Windows-based systems: latte.exe (Windows)
For Linux-based systems: SockPerf (Linux)
By using these tools, you help ensure that only TCP or UDP payload delivery times are measured and not ICMP
(Ping) or other packet types that aren't used by applications and don't affect their performance.
Tips for creating an optimal VM configuration
When you create your VM configuration, keep in mind the following recommendations:
Use the latest version of Windows or Linux.
Enable Accelerated Networking for best results.
Deploy VMs with an Azure proximity placement group.
Larger VMs generally perform better than smaller VMs.
Tips for analysis
As you're analyzing test results, keep in mind the following recommendations:
Establish a baseline early, as soon as deployment, configuration, and optimizations are complete.
Always compare new results to a baseline or, otherwise, from one test to another with controlled changes.
Repeat tests whenever changes are observed or planned.
netsh advfirewall firewall add rule program=<path>\latte.exe name="Latte" protocol=any dir=in action=allow
enable=yes profile=ANY
For example, if you copied latte.exe to the c:\tools folder, this would be the command:
netsh advfirewall firewall add rule program=c:\tools\latte.exe name="Latte" protocol=any dir=in action=allow
enable=yes profile=ANY
On the sender, start latte.exe (run it from the CMD window, not from PowerShell):
The resulting command is the same as on the receiver, except with the addition of -c to indicate that this is
the client, or sender:
latte -c -a 10.0.0.4:5005 -i 65100
Wait for the results. Depending on how far apart the VMs are, the test could take a few minutes to finish. Consider
starting with fewer iterations to test for success before running longer tests.
For Ubuntu
Run the following commands:
Now that the server is listening, the client can begin sending packets to the server on the port on which it is
listening (in this case, 12345).
About 100 seconds is long enough to return representative results, as shown in the following example:
Next steps
Improve latency with an Azure proximity placement group.
Learn how to Optimize networking for VMs for your scenario.
Read about how bandwidth is allocated to virtual machines.
For more information, see Azure Virtual Network FAQ.
Troubleshooting: Failed to delete a virtual network in
Azure
11/11/2020 • 2 minutes to read • Edit Online
You might receive errors when you try to delete a virtual network in Microsoft Azure. This article provides
troubleshooting steps to help you resolve this problem.
If your Azure issue is not addressed in this article, visit the Azure forums on MSDN and Stack Overflow. You can
post your issue in these forums, or post to @AzureSupport on Twitter. You also can submit an Azure support
request. To submit a support request, on the Azure support page, select Get suppor t .
Troubleshooting guidance
1. Check whether a virtual network gateway is running in the virtual network.
2. Check whether an application gateway is running in the virtual network.
3. Check whether Azure container instances still exist in the virtual network.
4. Check whether Azure Active Directory Domain Service is enabled in the virtual network.
5. Check whether the virtual network is connected to other resource.
6. Check whether a virtual machine is still running in the virtual network.
7. Check whether the virtual network is stuck in migration.
Troubleshooting steps
Check whether a virtual network gateway is running in the virtual network
To remove the virtual network, you must first remove the virtual network gateway.
For classic virtual networks, go to the Over view page of the classic virtual network in the Azure portal. In the VPN
connections section, if the gateway is running in the virtual network, you will see the IP address of the gateway.
For virtual networks, go to the Over view page of the virtual network. Check Connected devices for the virtual
network gateway.
Before you can remove the gateway, first remove any Connection objects in the gateway.
Check whether an application gateway is running in the virtual network
Go to the Over view page of the virtual network. Check the Connected devices for the application gateway.
If there is an application gateway, you must remove it before you can delete the virtual network.
Check whether Azure container instances still exist in the virtual network
1. In the Azure portal, go to the resource group's Over view page.
2. In the header for the list of the resource group's resources, select Show hidden types . The network profile
type is hidden in the Azure portal by default.
3. Select the network profile related to the container groups.
4. Select Delete .
To disable the service, see Disable Azure Active Directory Domain Services using the Azure portal.
Check whether the virtual network is connected to other resource
Check for Circuit Links, connections, and virtual network peerings. Any of these can cause a virtual network
deletion to fail.
The recommended deletion order is as follows:
1. Gateway connections
2. Gateways
3. IPs
4. Virtual network peerings
5. App Service Environment (ASE)
Check whether a virtual machine is still running in the virtual network
Make sure that no virtual machine is in the virtual network.
Check whether the virtual network is stuck in migration
If the virtual network is stuck in a migration state, it cannot be deleted. Run the following command to abort the
migration, and then delete the virtual network.
Next steps
Azure Virtual Network
Azure Virtual Network frequently asked questions (FAQ)
Troubleshooting connectivity problems between
Azure VMs
11/2/2020 • 3 minutes to read • Edit Online
You might experience connectivity problems between Azure virtual machines (VMs). This article provides
troubleshooting steps to help you resolve this problem.
If your Azure issue is not addressed in this article, visit the Azure forums on MSDN and Stack Overflow. You can
post your issue in these forums, or post to @AzureSupport on Twitter. You also can submit an Azure support
request. To submit a support request, on the Azure support page, select Get suppor t .
Symptom
One Azure VM cannot connect to another Azure VM.
Troubleshooting guidance
1. Check whether NIC is misconfigured
2. Check whether network traffic is blocked by NSG or UDR
3. Check whether network traffic is blocked by VM firewall
4. Check whether VM app or service is listening on the port
5. Check whether the problem is caused by SNAT
6. Check whether traffic is blocked by ACLs for the classic VM
7. Check whether the endpoint is created for the classic VM
8. Try to connect to a VM network share
9. Check Inter-Vnet connectivity
Troubleshooting steps
Follow these steps to troubleshoot the problem. After you complete each step, check whether the problem is
resolved.
Step 1: Check whether NIC is misconfigured
Follow the steps in How to reset network interface for Azure Windows VM.
If the problem occurs after you modify the network interface (NIC), follow these steps:
Multi-NIC VMs
1. Add a NIC.
2. Fix the problems in the bad NIC or remove the bad NIC. Then add the NIC again.
For more information, see Add network interfaces to or remove from virtual machines.
Single-NIC VM
Redeploy Windows VM
Redeploy Linux VM
Step 2: Check whether network traffic is blocked by NSG or UDR
Use Network Watcher IP Flow Verify and NSG Flow Logging to determine whether there is a Network Security
Group (NSG) or User-Defined Route (UDR) that is interfering with traffic flow.
Step 3: Check whether network traffic is blocked by VM firewall
Disable the firewall, and then test the result. If the problem is resolved, verify the firewall settings, and then re-
enable the firewall.
Step 4: Check whether VM app or service is listening on the port
You can use one of the following methods to check whether the VM app or service is listening on the port.
Run the following commands to check whether the server is listening on that port.
Windows VM
netstat –ano
Linux VM
netstat -l
Run the telnet command on the virtual machine itself to test the port. If the test fails, the application or service
is not configured to listen on that port.
Step 5: Check whether the problem is caused by SNAT
In some scenarios, the VM is placed behind a load balance solution that has a dependency on resources outside of
Azure. In these scenarios, if you experience intermittent connection problems, the problem may be caused by SNAT
port exhaustion. To resolve the issue, create a VIP (or ILPIP for classic) for each VM that is behind the load balancer
and secure with NSG or ACL.
Step 6: Check whether traffic is blocked by ACLs for the classic VM
An access control list (ACL) provides the ability to selectively permit or deny traffic for a virtual machine endpoint.
For more information, see Manage the ACL on an endpoint.
Step 7: Check whether the endpoint is created for the classic VM
All VMs that you create in Azure by using the classic deployment model can automatically communicate over a
private network channel with other virtual machines in the same cloud service or virtual network. However,
computers on other virtual networks require endpoints to direct the inbound network traffic to a virtual machine.
For more information, see How to set up endpoints.
Step 8: Try to connect to a VM network share
If you cannot connect to a VM network share, the problem may be caused by unavailable NICs in the VM. To delete
the unavailable NICs, see How to delete the unavailable NICs
Step 9: Check Inter-Vnet connectivity
Use Network Watcher IP Flow Verify and NSG Flow Logging to determine whether there is a NSG or UDR that is
interfering with traffic flow. You can also verify your Inter-Vnet configuration here.
Need help? Contact support.
If you still need help, contact support to get your issue resolved quickly.
Configure reverse lookup zones for an SMTP banner
check
11/2/2020 • 2 minutes to read • Edit Online
This article describes how to use a reverse zone in Azure DNS and create a Reverse DNS (PTR) record for SMTP
Banner Check.
Symptom
If you host an SMTP server in Microsoft Azure, you may receive the following error message when send or receive
a message from remote mail servers:
554: No PTR Record
Solution
For a virtual IP address in Azure, the reverse records are created in Microsoft owned domain zones, not custom
domain zones.
To configure PTR records in Microsoft owned zones, use the -ReverseFqdn property on the PublicIpAddress
resource. For more information, see Configure reverse DNS for services hosted in Azure.
When you configure the PTR records, make sure that the IP address and the reverse FQDN are owned by the
subscription. If you try to set a reverse FQDN that does not belong to the subscription, you receive the following
error message:
Set-AzPublicIpAddress : ReverseFqdn mail.contoso.com that PublicIPAddress ip01 is trying to use does not belong
to subscription <Subscription ID>. One of the following conditions need to be met to establish ownership:
If you manually change your SMTP banner to match our default reverse FQDN, the remote mail server can still fail
because it may expect the SMTP banner host to match the MX record for the domain.
Network virtual appliance issues in Azure
11/2/2020 • 5 minutes to read • Edit Online
NOTE
This article has been updated to use the new Azure PowerShell Az module. You can still use the AzureRM module, which will
continue to receive bug fixes until at least December 2020. To learn more about the new Az module and AzureRM
compatibility, see Introducing the new Azure PowerShell Az module. For Az module installation instructions, see Install Azure
PowerShell.
You may experience VM or VPN connectivity issues and errors when using a third party Network Virtual Appliance
(NVA) in Microsoft Azure. This article provides basic steps to help you validate basic Azure Platform requirements
for NVA configurations.
Technical support for third-party NVAs and their integration with the Azure platform is provided by the NVA
vendor.
NOTE
If you have a connectivity or routing problem that involves an NVA, you should contact the vendor of the NVA directly.
If your Azure issue is not addressed in this article, visit the Azure forums on MSDN and Stack Overflow. You can
post your issue in these forums, or post to @AzureSupport on Twitter. You also can submit an Azure support
request. To submit a support request, on the Azure support page, select Get suppor t .
Check for NSG when using Standard SKU Pubilc IP When using a Standard SKU and Public IPs, there must be
an NSG created and an explicit rule to allow the traffic to the NVA.
Check whether the traffic can be routed to the NVA
1. On Azure portal, open Network Watcher , select Next Hop .
2. Specify a VM that is configured to redirect the traffic to the NVA, and a destination IP address at which to view
the next hop.
3. If the NVA is not listed as the next hop , check and update the Azure route tables.
Check whether the traffic can reach the NVA
1. In Azure portal, open Network Watcher , and then select IP Flow Verify .
2. Specify the VM and the IP address of the NVA, and then check whether the traffic is blocked by any Network
security groups (NSG).
3. If there is an NSG rule that blocks the traffic, locate the NSG in effective security rules and then update it to
allow traffic to pass. Then run IP Flow Verify again and use Connection troubleshoot to test TCP
communications from VM to your internal or external IP address.
Check whether NVA and VMs are listening for expected traffic
1. Connect to the NVA by using RDP or SSH, and then run following command:
For Windows:
netstat -an
For Linux:
3. Open the network trace from the destination VM by using Network Monitor or tcpdump. Apply a display
filter for the IP of the Source VM you ran PsPing or Nmap from, such as
IPv4.address==10.0.0.4 (Windows netmon) or tcpdump -nn -r vmtrace.cap src or dst host 10.0.0.4 (Linux).
Analyze traces
If you do not see the packets incoming to the backend VM trace, there is likely an NSG or UDR interfering or the
NVA routing tables are incorrect.
If you do see the packets coming in but no response, then you may need to address a VM application or a firewall
issue. For either of these issues, contact the NVA vendor for assistance as needed.
Troubleshoot outbound SMTP connectivity issues in
Azure
11/2/2020 • 3 minutes to read • Edit Online
Starting on November 15, 2017, outbound email messages that are sent directly to external domains (such as
outlook.com and gmail.com) from a virtual machine (VM) are made available only to certain subscription types in
Microsoft Azure. Outbound SMTP connections that use TCP port 25 were blocked. (Port 25 is primarily used for
unauthenticated email delivery.)
This change in behavior applies only to new subscriptions and new deployments since November 15, 2017.
Enterprise Agreement
For Enterprise Agreement Azure users, there's no change in the technical ability to send email without using an
authenticated relay. Both new and existing Enterprise Agreement users can try outbound email delivery from Azure
VMs directly to external email providers without any restrictions from the Azure platform. Although it's not
guaranteed that email providers will accept incoming email from any given user, delivery attempts won't be
blocked by the Azure platform for VMs within Enterprise Agreement subscriptions. You'll have to work directly with
email providers to fix any message delivery or SPAM filtering issues that involve specific providers.
Pay-As-You-Go
If you signed up before November 15, 2017 for the Pay-As-You-Go or Microsoft Partner Network subscription
offers, there will be no change in the technical ability to try outbound email delivery. You'll continue to be able to
try outbound email delivery from Azure VMs within these subscriptions directly to external email providers without
any restrictions from the Azure platform. Again, it's not guaranteed that email providers will accept incoming email
from any given user, and users will have to work directly with email providers to fix any message delivery or SPAM
filtering issues that involve specific providers.
For Pay-As-You-Go or Microsoft Partner Network subscriptions that were created after November 15, 2017, there
will be technical restrictions that block email that's sent directly from VMs within these subscriptions. If you want
the ability to send email from Azure VMs directly to external email providers (not using an authenticated SMTP
relay), you can make a request to remove the restriction. Requests will be reviewed and approved at Microsoft's
discretion, and they'll be granted only after additional anti-fraud checks are made. To make a request, open a
support case by using the following issue type: Technical > Vir tual Network > Connectivity > Cannot send
email (SMTP/Por t 25) . Make sure that you add details about why your deployment has to send mail directly to
mail providers instead of using an authenticated relay.
After a Pay-As-You-Go or Microsoft Partner Network subscription is exempted and the VMs have been 'Stopped' &
'Started' from the Azure portal, all VMs within that subscription will be exempted going forward. The exemption is
only applicable to the subscription requested and only applies to Virtual Machine traffic routed directly to the
internet. Routing port 25 traffic via Azure PaaS services such as Azure Firewall is unsupported.
NOTE
Microsoft reserves the right to revoke this exemption if it's determined that a violation of terms of service has occurred.
MSDN, Azure Pass, Azure in Open, Education, BizSpark, and Free Trial
If you created an MSDN, Azure Pass, Azure in Open, Education, BizSpark, Azure Sponsorship, Azure Student, Free
Trial, or any Visual Studio subscription after November 15, 2017, you'll have technical restrictions that block email
that's sent from VMs within these subscriptions directly to email providers. The restrictions are done to prevent
abuse. No requests to remove this restriction will be granted.
If you're using these subscription types, you're encouraged to use SMTP relay services, as outlined earlier in this
article or change your subscription type.
IP address 168.63.129.16 is a virtual public IP address that is used to facilitate a communication channel to Azure
platform resources. Customers can define any address space for their private virtual network in Azure. Therefore,
the Azure platform resources must be presented as a unique public IP address. This virtual public IP address
facilitates the following things:
Enables the VM Agent to communicate with the Azure platform to signal that it is in a "Ready" state.
Enables communication with the DNS virtual server to provide filtered name resolution to the resources (such
as VM) that do not have a custom DNS server. This filtering makes sure that customers can resolve only the
hostnames of their resources.
Enables health probes from Azure load balancer to determine the health state of VMs.
Enables the VM to obtain a dynamic IP address from the DHCP service in Azure.
Enables Guest Agent heartbeat messages for the PaaS role.
NOTE
In a non-virtual network scenario (Classic), a private IP address is used instead of 168.63.129.16. This private IP address is
dynamically discovered through DHCP. Firewall rules specific to 168.63.129.16 need to be adjusted as appropriate.
Next steps
Security groups
Create, change, or delete a network security group
Troubleshoot Azure VM connectivity problems
11/2/2020 • 6 minutes to read • Edit Online
This article helps administrators diagnose and resolve connectivity problems that affect Azure virtual machines
(VMs).
Problems
An Azure VM that’s deployed by using Resource Manager can't connect to another Azure VM in same virtual
network.
An Azure VM can't connect to the second network adapter of an Azure VM in same virtual network.
An Azure VM can't connect to the internet.
To resolve these problems, follow the steps in the following section.
Resolution
Azure VM cannot connect to another Azure VM in same virtual network
Step 1: Verify that VMs can communicate with each other.
1. Download TCping to your source VM.
2. Open a Command Prompt window.
3. Navigate to the folder in which you downloaded TCping.
4. Ping the destination from the source VM by using the following command:
TIP
If the ping test is successful, go to Step 3. Otherwise, go to the next step.
NOTE
Rules that have a lower number will be matched first. For example, if you have a rule that has priority 1000 and 6500, the
rule that has priority 1000 will be matched first.
After that, try to ping the destination from the source VM again:
tcping64.exe -t <destination VM address> 3389
Step 3: Check whether you can connect to the destination VM by using Remote Desktop or SSH.
To connect by using Remote Desktop, follow these steps.
Windows :
1. Sign in to the Azure portal.
2. In the left menu, select Vir tual Machines .
3. Select the virtual machine in the list.
4. On the page for the virtual machine, select Connect .
For more information, see How to connect and sign on to an Azure virtual machine running Windows.
Linux :
For more information, see Connect to a Linux VM in Azure.
If the Remote Desktop or SSH connection is successful, go to next step.
Step 4: Perform a connectivity check.
Run a connectivity check on the source VM, and check the response.
Windows : Check connectivity with Azure Network Watcher using PowerShell
Linux : Check connectivity with Azure Network Watcher using Azure CLI 2.0
The following is an example response:
ConnectionStatus : Unreachable
AvgLatencyInMs :
MinLatencyInMs :
MaxLatencyInMs :
ProbesSent : 100
ProbesFailed : 100
Hops : [
{
"Type": "Source",
"Id": "c5222ea0-3213-4f85-a642-cee63217c2f3",
"Address": "10.1.1.4",
"ResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGrou
ps/ContosoRG/providers/Microsoft.Network/networkInterfaces/appNic0/ipConfigurat
ions/ipconfig1",
"NextHopIds": [
"9283a9f0-cc5e-4239-8f5e-ae0f3c19fbaa"
],
"Issues": []
},
{
"Type": "VirtualAppliance",
"Id": "9283a9f0-cc5e-4239-8f5e-ae0f3c19fbaa",
"Address": "10.1.2.4",
"ResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGrou
ps/ContosoRG/providers/Microsoft.Network/networkInterfaces/fwNic/ipConfiguratio
ns/ipconfig1",
"NextHopIds": [
"0f1500cd-c512-4d43-b431-7267e4e67017"
],
"Issues": []
},
2. Find the corresponding resolution in the following table, and follow the indicated steps to resolve the issues.
ISSUE T Y P E VA L UE RESO L UT IO N A C T IO N
NetworkSecurityRule Name of the blocking NSG You can delete the NSG rule or
modify the rule as described here.
UserDefinedRoute Name of the blocking UDR If you do not require this route,
delete the UDR. If you can’t delete
the route, update the route by using
the appropriate address prefix and
next hop. You can also adjust the
Network Virtual Appliance to forward
traffic appropriately. For more
information, see: Virtual network
traffic routing and Route network
traffic with a route table using
PowerShell.
Guest Firewall Name of the firewall blocking Follow these steps: Turn Windows
Defender Firewall on or off.
DNS Resolution Name of the DNS Follow these steps: Azure DNS
troubleshooting guide and Name
resolution for resources in Azure
virtual networks.
3. Run the connectivity check again to determine whether the problem is resolved.
Azure VM cannot connect to the second network adapter of an Azure VM in same virtual network
Step 1: Make sure that the second network adapter is enabled to talk outside the subnet.
By default, secondary network adapters (also known as network interface cards, or network adapters) are not
configured to have a default gateway. Therefore, the traffic flow on the secondary adapter will be limited to the
same subnet.
If users want to enable secondary network adapters to talk outside their own subnet, they must add an entry to the
routing table to configure the gateway. To do this, follow these steps:
1. On the VM that has the second network adapter configured, open a Command Prompt window as an
administrator.
2. Run the following command to add the entry in routing table:
For example, if the second IP address is 192.168.0.4, the gateway IP should be 192.168.0.1. You have to run
the following command:
3. Run route print. If the entry is added successfully, you will see an entry that resembles the following:
Now, try to connect to secondary network adapter. If the connection is still unsuccessful, go to next step.
Step 2: Check NSG settings for the network adapters.
For both the primary and secondary network adapters, check the default Inbound port rules (Allow VNet Inbound,
Allow Load Balancer) to inbound on both network adapters. You should also make sure that there are no matching
blocking rules that have a lower-priority rule above them.
ConnectionStatus : Unreachable
AvgLatencyInMs :
MinLatencyInMs :
MaxLatencyInMs :
ProbesSent : 100
ProbesFailed : 100
Hops : [
{
"Type": "Source",
"Id": "c5222ea0-3213-4f85-a642-cee63217c2f3",
"Address": "10.1.1.4",
"ResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGrou
ps/ContosoRG/providers/Microsoft.Network/networkInterfaces/appNic0/ipConfigurat
ions/ipconfig1",
"NextHopIds": [
"9283a9f0-cc5e-4239-8f5e-ae0f3c19fbaa"
],
"Issues": []
},
{
"Type": "VirtualAppliance",
"Id": "9283a9f0-cc5e-4239-8f5e-ae0f3c19fbaa",
"Address": "10.1.2.4",
"ResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGrou
ps/ContosoRG/providers/Microsoft.Network/networkInterfaces/fwNic/ipConfiguratio
ns/ipconfig1",
"NextHopIds": [
"0f1500cd-c512-4d43-b431-7267e4e67017"
],
"Issues": []
},
Step 4: Refer the table under Step 5, and follow these steps to resolve the issues.
9. Select the affected network interface, and then select the Put option.
NOTE
After you make this selection, the ProvisioningState is displayed as Updating . The same result is shown on the
regular Azure Resource Manager portal. If the operation is completed successfully, the ProvisioningState value
changes to Succeeded , as shown.
10. Refresh your portal. The network adapter should be in a success state.
Step 2: Follow Step 4 to run a connectivity check.
Step 3: Refer the table under Step 5, and follow the steps to resolve the issues.
Next steps
Troubleshooting connectivity problems between Azure VMs
Azure Policy built-in definitions for Azure Virtual
Network
11/2/2020 • 9 minutes to read • Edit Online
This page is an index of Azure Policy built-in policy definitions for Azure Virtual Network. For additional Azure
Policy built-ins for other services, see Azure Policy built-in definitions.
The name of each built-in policy definition links to the policy definition in the Azure portal. Use the link in the
Version column to view the source on the Azure Policy GitHub repo.
A custom IPsec/IKE policy This policy ensures that all Audit, Disabled 1.0.0
must be applied to all Azure Azure virtual network
virtual network gateway gateway connections use a
connections custom Internet Protocol
Security(Ipsec)/Internet Key
Exchange(IKE) policy.
Supported algorithms and
key strengths -
https://aka.ms/AA62kb0
All Internet traffic should be Azure Security Center has AuditIfNotExists, Disabled 3.0.0-preview
routed via your deployed identified that some of your
Azure Firewall subnets aren't protected
with a next generation
firewall. Protect your subnets
from potential threats by
restricting access to them
with Azure Firewall or a
supported next generation
firewall
App Service should use a This policy audits any App AuditIfNotExists, Disabled 1.0.0
virtual network service Service not configured to
endpoint use a virtual network service
endpoint.
Azure VPN gateways should This policy ensures that VPN Audit, Disabled 1.0.0
not use 'basic' SKU gateways do not use 'basic'
SKU.
Container Registry should This policy audits any Audit, Disabled 1.0.0-preview
use a virtual network service Container Registry not
endpoint configured to use a virtual
network service endpoint.
Cosmos DB should use a This policy audits any Audit, Disabled 1.0.0
virtual network service Cosmos DB not configured
endpoint to use a virtual network
service endpoint.
NAME VERSIO N
DESC RIP T IO N EF F EC T ( S)
Deploy a flow log resource Configures flow log for deployIfNotExists 1.0.0
with target network security specific network security
group group. It will allow to log
information about IP traffic
flowing through an network
security group. Flow log
helps to identify unknown or
undesired traffic, verify
network isolation and
compliance with enterprise
access rules, analyze network
flows from compromised IPs
and network interfaces.
Event Hub should use a This policy audits any Event AuditIfNotExists, Disabled 1.0.0
virtual network service Hub not configured to use a
endpoint virtual network service
endpoint.
Key Vault should use a This policy audits any Key Audit, Disabled 1.0.0
virtual network service Vault not configured to use
endpoint a virtual network service
endpoint.
NAME VERSIO N
DESC RIP T IO N EF F EC T ( S)
RDP access from the This policy audits any Audit, Disabled 2.0.0
Internet should be blocked network security rule that
allows RDP access from
Internet
Service Bus should use a This policy audits any Service AuditIfNotExists, Disabled 1.0.0
virtual network service Bus not configured to use a
endpoint virtual network service
endpoint.
SQL Server should use a This policy audits any SQL AuditIfNotExists, Disabled 1.0.0
virtual network service Server not configured to use
endpoint a virtual network service
endpoint.
SSH access from the Internet This policy audits any Audit, Disabled 2.0.0
should be blocked network security rule that
allows SSH access from
Internet
NAME VERSIO N
DESC RIP T IO N EF F EC T ( S)
Storage Accounts should use This policy audits any Audit, Disabled 1.0.0
a virtual network service Storage Account not
endpoint configured to use a virtual
network service endpoint.
Virtual machines should be This policy audits any virtual Audit, Deny, Disabled 1.0.0
connected to an approved machine connected to a
virtual network virtual network that is not
approved.
Virtual networks should use This policy audits any virtual AuditIfNotExists, Disabled 1.0.0
specified virtual network network if the default route
gateway does not point to the
specified virtual network
gateway.
Web Application Firewall Requires Web Application Audit, Deny, Disabled 1.0.0
(WAF) should be enabled for Firewall (WAF) on any
Application Gateway Application Gateway. A Web
Application Firewall provides
greater security for your
other Azure resources.
Web Application Firewall Requires Web Application Audit, Deny, Disabled 1.0.0
(WAF) should be enabled for Firewall (WAF) on any Azure
Azure Front Door Service Front Door Service. A Web
Application Firewall provides
greater security for your
other Azure resources.
Web Application Firewall Mandates the use of Audit, Deny, Disabled 1.0.0
(WAF) should use the 'Detection' or 'Prevention'
specified mode for mode to be active on all
Application Gateway Web Application Firewall
policies for Application
Gateway.
Web Application Firewall Mandates the use of Audit, Deny, Disabled 1.0.0
(WAF) should use the 'Detection' or 'Prevention'
specified mode for Azure mode to be active on all
Front Door Service Web Application Firewall
policies for Azure Front Door
Service.
Tags
NAME VERSIO N
( A ZURE PO RTA L) DESC RIP T IO N EF F EC T ( S) ( GIT HUB)
NAME VERSIO N
DESC RIP T IO N EF F EC T ( S)
Add a tag to resource Adds the specified tag and modify 1.0.0
groups value when any resource
group missing this tag is
created or updated. Existing
resource groups can be
remediated by triggering a
remediation task. If the tag
exists with a different value it
will not be changed.
Add a tag to resources Adds the specified tag and modify 1.0.0
value when any resource
missing this tag is created or
updated. Existing resources
can be remediated by
triggering a remediation
task. If the tag exists with a
different value it will not be
changed. Does not modify
tags on resource groups.
Append a tag and its value Appends the specified tag append 1.0.0
from the resource group with its value from the
resource group when any
resource which is missing
this tag is created or
updated. Does not modify
the tags of resources created
before this policy was
applied until those resources
are changed. New 'modify'
effect policies are available
that support remediation of
tags on existing resources
(see
https://aka.ms/modifydoc).
NAME VERSIO N
DESC RIP T IO N EF F EC T ( S)
Append a tag and its value Appends the specified tag append 1.0.0
to resource groups and value when any
resource group which is
missing this tag is created or
updated. Does not modify
the tags of resource groups
created before this policy
was applied until those
resource groups are
changed. New 'modify' effect
policies are available that
support remediation of tags
on existing resources (see
https://aka.ms/modifydoc).
Append a tag and its value Appends the specified tag append 1.0.1
to resources and value when any
resource which is missing
this tag is created or
updated. Does not modify
the tags of resources created
before this policy was
applied until those resources
are changed. Does not apply
to resource groups. New
'modify' effect policies are
available that support
remediation of tags on
existing resources (see
https://aka.ms/modifydoc).
Inherit a tag from the Adds the specified tag with modify 1.0.0
resource group if missing its value from the parent
resource group when any
resource missing this tag is
created or updated. Existing
resources can be remediated
by triggering a remediation
task. If the tag exists with a
different value it will not be
changed.
Inherit a tag from the Adds the specified tag with modify 1.0.0
subscription if missing its value from the containing
subscription when any
resource missing this tag is
created or updated. Existing
resources can be remediated
by triggering a remediation
task. If the tag exists with a
different value it will not be
changed.
Require a tag and its value Enforces a required tag and deny 1.0.0
on resource groups its value on resource groups.
Require a tag and its value Enforces a required tag and deny 1.0.1
on resources its value. Does not apply to
resource groups.
General
NAME VERSIO N
( A ZURE PO RTA L) DESC RIP T IO N EF F EC T ( S) ( GIT HUB)
Audit usage of custom RBAC Audit built-in roles such as Audit, Disabled 1.0.0
rules 'Owner, Contributer, Reader'
instead of custom RBAC
roles, which are error prone.
Using custom roles is
treated as an exception and
requires a rigorous review
and threat modeling
Custom subscription owner This policy ensures that no Audit, Disabled 2.0.0
roles should not exist custom subscription owner
roles exist.
Not allowed resource types This policy enables you to Deny 1.0.0
specify the resource types
that your organization
cannot deploy.
Next steps
See the built-ins on the Azure Policy GitHub repo.
Review the Azure Policy definition structure.
Review Understanding policy effects.
Azure Virtual Network frequently asked questions
(FAQ)
11/2/2020 • 28 minutes to read • Edit Online
Configuration
What tools do I use to create a VNet?
You can use the following tools to create or configure a VNet:
Azure portal
PowerShell
Azure CLI
A network configuration file (netcfg - for classic VNets only). See the Configure a VNet using a network
configuration file article.
What address ranges can I use in my VNets?
We recommend that you use the address ranges enumerated in RFC 1918, which have been set aside by the IETF
for private, non-routable address spaces:
10.0.0.0 - 10.255.255.255 (10/8 prefix)
172.16.0.0 - 172.31.255.255 (172.16/12 prefix)
192.168.0.0 - 192.168.255.255 (192.168/16 prefix)
Other address spaces may work but may have undesirable side effects.
In addition, you cannot add the following address ranges:
224.0.0.0/4 (Multicast)
255.255.255.255/32 (Broadcast)
127.0.0.0/8 (Loopback)
169.254.0.0/16 (Link-local)
168.63.129.16/32 (Internal DNS)
Can I have public IP addresses in my VNets?
Yes. For more information about public IP address ranges, see Create a virtual network. Public IP addresses are not
directly accessible from the internet.
Is there a limit to the number of subnets in my VNet?
Yes. See Azure limits for details. Subnet address spaces cannot overlap one another.
Are there any restrictions on using IP addresses within these subnets?
Yes. Azure reserves 5 IP addresses within each subnet. These are x.x.x.0-x.x.x.3 and the last address of the subnet.
x.x.x.1-x.x.x.3 is reserved in each subnet for Azure services.
x.x.x.0: Network address
x.x.x.1: Reserved by Azure for the default gateway
x.x.x.2, x.x.x.3: Reserved by Azure to map the Azure DNS IPs to the VNet space
x.x.x.255: Network broadcast address
How small and how large can VNets and subnets be?
The smallest supported IPv4 subnet is /29, and the largest is /8 (using CIDR subnet definitions). IPv6 subnets must
be exactly /64 in size.
Can I bring my VLANs to Azure using VNets?
No. VNets are Layer-3 overlays. Azure does not support any Layer-2 semantics.
Can I specify custom routing policies on my VNets and subnets?
Yes. You can create a route table and associate it to a subnet. For more information about routing in Azure, see
Routing overview.
Do VNets support multicast or broadcast?
No. Multicast and broadcast are not supported.
What protocols can I use within VNets?
You can use TCP, UDP, and ICMP TCP/IP protocols within VNets. Unicast is supported within VNets, with the
exception of Dynamic Host Configuration Protocol (DHCP) via Unicast (source port UDP/68 / destination port
UDP/67) and UDP source port 65330 which is reserved for the host. Multicast, broadcast, IP-in-IP encapsulated
packets, and Generic Routing Encapsulation (GRE) packets are blocked within VNets.
Can I ping my default routers within a VNet?
No.
Can I use tracert to diagnose connectivity?
No.
Can I add subnets after the VNet is created?
Yes. Subnets can be added to VNets at any time as long as the subnet address range is not part of another subnet
and there is available space left in the virtual network's address range.
Can I modify the size of my subnet after I create it?
Yes. You can add, remove, expand, or shrink a subnet if there are no VMs or services deployed within it.
Can I modify Vnet after I created them?
Yes. You can add, remove, and modify the CIDR blocks used by a VNet.
If I am running my services in a VNet, can I connect to the internet?
Yes. All services deployed within a VNet can connect outbound to the internet. To learn more about outbound
internet connections in Azure, see Outbound connections. If you want to connect inbound to a resource deployed
through Resource Manager, the resource must have a public IP address assigned to it. To learn more about public
IP addresses, see Public IP addresses. Every Azure Cloud Service deployed in Azure has a publicly addressable VIP
assigned to it. You define input endpoints for PaaS roles and endpoints for virtual machines to enable these
services to accept connections from the internet.
Do VNets support IPv6?
Yes, VNets can be IPv4-only or dual stack (IPv4+IPv6). For details, see Overview of IPv6 for Azure Virtual
Networks.
Can a VNet span regions?
No. A VNet is limited to a single region. A virtual network does, however, span availability zones. To learn more
about availability zones, see Availability zones overview. You can connect virtual networks in different regions with
virtual network peering. For details, see Virtual network peering overview
Can I connect a VNet to another VNet in Azure?
Yes. You can connect one VNet to another VNet using either:
Vir tual network peering : For details, see VNet peering overview
An Azure VPN Gateway : For details, see Configure a VNet-to-VNet connection.
Security
What is the security model for VNets?
VNets are isolated from one another, and other services hosted in the Azure infrastructure. A VNet is a trust
boundary.
Can I restrict inbound or outbound traffic flow to VNet-connected resources?
Yes. You can apply Network Security Groups to individual subnets within a VNet, NICs attached to a VNet, or both.
Can I implement a firewall between VNet-connected resources?
Yes. You can deploy a firewall network virtual appliance from several vendors through the Azure Marketplace.
Is there information available about securing VNets?
Yes. For details, see Azure Network Security Overview.
Do Virtual Networks store customer data?
No. Virtual Networks doesn't store any customer data.
VNet peering
What is VNet peering?
VNet peering (or virtual network peering) enables you to connect virtual networks. A VNet peering connection
between virtual networks enables you to route traffic between them privately through IPv4 addresses. Virtual
machines in the peered VNets can communicate with each other as if they are within the same network. These
virtual networks can be in the same region or in different regions (also known as Global VNet Peering). VNet
peering connections can also be created across Azure subscriptions.
Can I create a peering connection to a VNet in a different region?
Yes. Global VNet peering enables you to peer VNets in different regions. Global VNet peering is available in all
Azure public regions, China cloud regions, and Government cloud regions. You cannot globally peer from Azure
public regions to national cloud regions.
What are the constraints related to Global VNet Peering and Load Balancers?
If the two virtual networks in two different regions are peered over Global VNet Peering, you cannot connect to
resources that are behind a Basic Load Balancer through the Front End IP of the Load Balancer. This restriction
does not exist for a Standard Load Balancer. The following resources can use Basic Load Balancers which means
you cannot reach them through the Load Balancer's Front End IP over Global VNet Peering. You can however use
Global VNet peering to reach the resources directly through their private VNet IPs, if permitted.
VMs behind Basic Load Balancers
Virtual machine scale sets with Basic Load Balancers
Redis Cache
Application Gateway (v1) SKU
Service Fabric
API Management
Active Directory Domain Service (ADDS)
Logic Apps
HDInsight
Azure Batch
App Service Environment
You can connect to these resources via ExpressRoute or VNet-to-VNet through VNet Gateways.
Can I enable VNet Peering if my virtual networks belong to subscriptions within different Azure Active
Directory tenants?
Yes. It is possible to establish VNet Peering (whether local or global) if your subscriptions belong to different Azure
Active Directory tenants. You can do this via Portal, PowerShell or CLI.
My VNet peering connection is in Initiated state, why can't I connect?
If your peering connection is in an Initiated state, this means you have created only one link. A bidirectional link
must be created in order to establish a successful connection. For example, to peer VNet A to VNet B, a link must
be created from VNetA to VNetB and from VNetB to VNetA. Creating both links will change the state to Connected.
My VNet peering connection is in Disconnected state, why can't I create a peering connection?
If your VNet peering connection is in a Disconnected state, it means one of the links created was deleted. In order
to re-establish a peering connection, you will need to delete the link and recreate it.
Can I peer my VNet with a VNet in a different subscription?
Yes. You can peer VNets across subscriptions and across regions.
Can I peer two VNets with matching or overlapping address ranges?
No. Address spaces must not overlap to enable VNet Peering.
How much do VNet peering links cost?
There is no charge for creating a VNet peering connection. Data transfer across peering connections is charged.
See here.
Is VNet peering traffic encrypted?
When Azure traffic moves between datacenters (outside physical boundaries not controlled by Microsoft or on
behalf of Microsoft), MACsec data-link layer encryption is utilized on the underlying network hardware. This is
applicable to VNet peering traffic.
Why is my peering connection in a Disconnected state?
VNet peering connections go into Disconnected state when one VNet peering link is deleted. You must delete both
links in order to reestablish a successful peering connection.
If I peer VNetA to VNetB and I peer VNetB to VNetC, does that mean VNetA and VNetC are peered?
No. Transitive peering is not supported. You must peer VNetA and VNetC for this to take place.
Are there any bandwidth limitations for peering connections?
No. VNet peering, whether local or global, does not impose any bandwidth restrictions. Bandwidth is only limited
by the VM or the compute resource.
How can I troubleshoot VNet Peering issues?
Here is a troubleshooter guide you can try.
NOTE
Both the operations described above must be completed before you can limit the Azure service access to the allowed VNet
and subnet. Only turning on service endpoints for the Azure service on the network side does not provide you the limited
access. In addition, you must also set up VNet ACLs on the Azure service side.
Certain services (such as SQL and CosmosDB) allow exceptions to the above sequence through the
IgnoreMissingVnetSer viceEndpoint flag. Once the flag is set to True , VNet ACLs can be set on the Azure
service side prior to setting up the service endpoints on the network side. Azure services provide this flag to help
customers in cases where the specific IP firewalls are configured on Azure services and turning on the service
endpoints on the network side can lead to a connectivity drop since the source IP changes from a public IPv4
address to a private address. Setting up VNet ACLs on the Azure service side before setting service endpoints on
the network side can help avoid a connectivity drop.
Do all Azure services reside in the Azure virtual network provided by the customer? How does VNet service
endpoint work with Azure services?
No, not all Azure services reside in the customer's virtual network. The majority of Azure data services such as
Azure Storage, Azure SQL, and Azure Cosmos DB, are multi-tenant services that can be accessed over public IP
addresses. You can learn more about virtual network integration for Azure services here.
When you use the VNet service endpoints feature (turning on VNet service endpoint on the network side and
setting up appropriate VNet ACLs on the Azure service side), access to an Azure service is restricted from an
allowed VNet and subnet.
How does VNet service endpoint provide security?
The VNet service endpoint feature (turning on VNet service endpoint on the network side and setting up
appropriate VNet ACLs on the Azure service side) limits the Azure service access to the allowed VNet and subnet,
thus providing a network level security and isolation of the Azure service traffic. All traffic using VNet service
endpoints flows over Microsoft backbone, thus providing another layer of isolation from the public internet.
Moreover, customers can choose to fully remove public Internet access to the Azure service resources and allow
traffic only from their virtual network through a combination of IP firewall and VNet ACLs, thus protecting the
Azure service resources from unauthorized access.
What does the VNet service endpoint protect - VNet resources or Azure service?
VNet service endpoints help protect Azure service resources. VNet resources are protected through Network
Security Groups (NSGs).
Is there any cost for using VNet service endpoints?
No, there is no additional cost for using VNet service endpoints.
Can I turn on VNet service endpoints and set up VNet ACLs if the virtual network and the Azure service
resources belong to different subscriptions?
Yes, it is possible. Virtual networks and Azure service resources can be either in the same or different
subscriptions. The only requirement is that both the virtual network and Azure service resources must be under
the same Active Directory (AD) tenant.
Can I turn on VNet service endpoints and set up VNet ACLs if the virtual network and the Azure service
resources belong to different AD tenants?
Yes, it is possible when using service endpoints for Azure Storage and Azure Key Vault. For rest of services, VNet
service endpoints and VNet ACLs are not supported across AD tenants.
Can an on-premises device’s IP address that is connected through Azure Virtual Network gateway (VPN ) or
ExpressRoute gateway access Azure PaaS Service over VNet service endpoints?
By default, Azure service resources secured to virtual networks are not reachable from on-premises networks. If
you want to allow traffic from on-premises, you must also allow public (typically, NAT) IP addresses from your on-
premises or ExpressRoute. These IP addresses can be added through the IP firewall configuration for the Azure
service resources.
Can I use VNet Service Endpoint feature to secure Azure service to multiple subnets within a virtual network or
across multiple virtual networks?
To secure Azure services to multiple subnets within a virtual network or across multiple virtual networks, enable
service endpoints on the network side on each of the subnets independently and then secure Azure service
resources to all of the subnets by setting up appropriate VNet ACLs on the Azure service side.
How can I filter outbound traffic from a virtual network to Azure services and still use service endpoints?
If you want to inspect or filter the traffic destined to an Azure service from a virtual network, you can deploy a
network virtual appliance within the virtual network. You can then apply service endpoints to the subnet where
the network virtual appliance is deployed and secure Azure service resources only to this subnet through VNet
ACLs. This scenario might also be helpful if you wish to restrict Azure service access from your virtual network
only to specific Azure resources using network virtual appliance filtering. For more information, see egress with
network virtual appliances.
What happens when you access an Azure service account that has a virtual network access control list (ACL )
enabled from outside the VNet?
The HTTP 403 or HTTP 404 error is returned.
Are subnets of a virtual network created in different regions allowed to access an Azure service account in
another region?
Yes, for most of the Azure services, virtual networks created in different regions can access Azure services in
another region through the VNet service endpoints. For example, if an Azure Cosmos DB account is in West US or
East US and virtual networks are in multiple regions, the virtual network can access Azure Cosmos DB. Storage
and SQL are exceptions and are regional in nature and both the virtual network and the Azure service need to be
in the same region.
Can an Azure service have both a VNet ACL and an IP firewall?
Yes, a VNet ACL and an IP firewall can co-exist. Both features complement each other to ensure isolation and
security.
What happens if you delete a virtual network or subnet that has service endpoint turned on for Azure service?
Deletion of VNets and subnets are independent operations and are supported even when service endpoints are
turned on for Azure services. In cases where the Azure services have VNet ACLs set up, for those VNets and
subnets, the VNet ACL information associated with that Azure service is disabled when a VNet or subnet that has
VNet service endpoint turned on is deleted.
What happens if an Azure service account that has a VNet Service endpoint enabled is deleted?
The deletion of an Azure service account is an independent operation and is supported even when the service
endpoint is enabled on the network side and VNet ACLs are set up on Azure service side.
What happens to the source IP address of a resource (like a VM in a subnet) that has VNet service endpoint
enabled?
When virtual network service endpoints are enabled, the source IP addresses of the resources in your virtual
network's subnet switches from using public IPV4 addresses to the Azure virtual network's private IP addresses for
traffic to Azure service. Note that this can cause specific IP firewalls that are set to public IPV4 address earlier on
the Azure services to fail.
Does the service endpoint route always take precedence?
Service endpoints add a system route which takes precedence over BGP routes and provides optimum routing for
the service endpoint traffic. Service endpoints always take service traffic directly from your virtual network to the
service on the Microsoft Azure backbone network. For more information about how Azure selects a route, see
Azure Virtual network traffic routing.
How does NSG on a subnet work with service endpoints?
To reach the Azure service, NSGs need to allow outbound connectivity. If your NSGs are opened to all Internet
outbound traffic, then the service endpoint traffic should work. You can also limit the outbound traffic to service
IPs only using the Service tags.
What permissions do I need to set up service endpoints?
Service endpoints can be configured on a virtual network independently by a user with write access to the virtual
network. To secure Azure service resources to a VNet, the user must have permission
Microsoft.Network/vir tualNetworks/subnets/joinViaSer viceEndpoint/action for the subnets being
added. This permission is included in the built-in service administrator role by default and can be modified by
creating custom roles. Learn more about built-in roles and assigning specific permissions to custom roles.
Can I filter virtual network traffic to Azure services, allowing only specific azure service resources, over VNet
service endpoints?
Virtual network (VNet) service endpoint policies allow you to filter virtual network traffic to Azure services,
allowing only specific Azure service resources over the service endpoints. Endpoint policies provide granular
access control from the virtual network traffic to the Azure services. You can learn more about the service
endpoint policies here.
Does Azure Active Directory (Azure AD) support VNet service endpoints?
Azure Active Directory (Azure AD) doesn't support service endpoints natively. Complete list of Azure Services
supporting VNet service endpoints can be seen here. Note that the "Microsoft.AzureActiveDirectory" tag listed
under services supporting service endpoints is used for supporting service endpoints to ADLS Gen 1. For ADLS
Gen 1, virtual network integration for Azure Data Lake Storage Gen1 makes use of the virtual network service
endpoint security between your virtual network and Azure Active Directory (Azure AD) to generate additional
security claims in the access token. These claims are then used to authenticate your virtual network to your Data
Lake Storage Gen1 account and allow access. Learn more about Azure Data Lake Store Gen 1 VNet Integration
Are there any limits on how many VNet service endpoints I can set up from my VNet?
There is no limit on the total number of VNet service endpoints in a virtual network. For an Azure service resource
(such as an Azure Storage account), services may enforce limits on the number of subnets used for securing the
resource. The following table shows some example limits:
Azure Cosmos DB 64
A Z URE SERVIC E L IM IT S O N VN ET RUL ES
NOTE
The limits are subjected to changes at the discretion of the Azure service. Refer to the respective service documentation for
services details.