How to Create User-Defined Routes in Azure with PowerShell

Although the default system routes in Azure handle traffic automatically, there are often cases where you prefer to control the routing of traffic on your own.  Such cases are typical when you want to route traffic through a virtual appliance.  To facilitate this capability, you can create user-defined routes (UDRs) that specify the next hop for packets that are bound for a specific subnet.  With a UDR, you can direct such traffic to a virtual appliance instead, where the traffic can be filtered, captured, inspected, or whatever else you want done with it.

Configuring user-defined routes in Azure requires you to configure routing tables for your subnets as well as specific routes within those routing tables.  You must then assign your routing tables to the correct subnets.

In this article, I am going to explain how to take traffic that flows from SubnetA directly to SubnetB, and re-route that traffic, so it flows from SubnetA to our pretend firewall (FW1) and then out to SubnetB.  In this configuration, we could do any number of things with the traffic as it passes through FW1 (i.e. IDS).

To prepare my environment in Azure for this demonstration, I created a single Virtual Network ( and three subnets:,, and  I spun up a Windows 2102 R2 box on each subnet and configured the server on the subnet as an RRAS server.

For those who are more interested in diagrams (like me), this is how it looked:

As you can see in the diagram, ServerA resided on SubnetA, ServerB resided on SubnetB, and the FW1 server lived on the subnet labeled DMZ.

Click here to join the Understanding Azure Facebook group or here for the latest Azure practice questions, answers, explanations, and reference materials.

Thomas Mitchell

Tom is a 20+ year veteran of the IT industry and carries numerous Microsoft certifications, including the MCSE: Cloud Platform and Infrastructure certification. A Subject Matter Expert in Active Directory and Microsoft Exchange, Tom also possesses expert-level knowledge in several other IT disciplines, including Azure, Storage, and O365/Exchange Online. You can find Tom at his website, on LinkedIn, or on Facebook. Need to reach him by phone? Call 484-334-2790.