During Public Preview you can use the Team plan for free, and get an early-adopter discount at GA. Sign in
Deploying a Route Table
This guide shows you how to deploy a Route Table against Locally, add routes to it and attach it to a subnet. As with the other guides we're going to use the Azure CLI, but the same resources can be provisioned with HashiCorp Terraform, Pulumi or Bicep too.
Before you start
- The Azure CLI (
az) installed. - Locally installed, with Locally Setup completed.
1. Start Locally
Firstly, we need to launch Locally which we can do from a terminal by running:
$
locally build
Once Locally has started, the Locally Dashboard will open automatically:
2. Create a Resource Group
Next we can create the Resource Group:
$
locally run az group create -n sample-routes -l berlin
There's two things to note here:
- The Azure CLI supports Automatic Configuration, meaning that it can automatically be configured to work against Locally just by prefixing commands with
locally run. - Locally intentionally uses a different set of locations to Azure as a safety precaution, so that you can be confident you're deploying against Locally rather than regular Azure. You can also configure Locally to use the Azure locations too, but you'll want to be extra sure that you're prefixing commands with
locally runwhen you do.
3. Create the Route Table
We'll create the Route Table with BGP route propagation turned off, so that only the routes we add apply to the subnet:
$
locally run az network route-table create -g sample-routes -n sample-rt --disable-bgp-route-propagation true --query "{name:name, disableBgpRoutePropagation:disableBgpRoutePropagation, state:provisioningState}"
{
"disableBgpRoutePropagation": true,
"name": "sample-rt",
"state": "Succeeded"
}
4. Add some routes
A common setup sends all outbound traffic through a firewall. This route sends everything to a virtual appliance at 10.0.2.4:
$
locally run az network route-table route create -g sample-routes --route-table-name sample-rt -n to-firewall --address-prefix 0.0.0.0/0 --next-hop-type VirtualAppliance --next-hop-ip-address 10.0.2.4 --query "{name:name, prefix:addressPrefix, nextHopType:nextHopType, nextHop:nextHopIpAddress, state:provisioningState}"
{
"name": "to-firewall",
"nextHop": "10.0.2.4",
"nextHopType": "VirtualAppliance",
"prefix": "0.0.0.0/0",
"state": "Succeeded"
}
And this one drops any traffic for 192.168.0.0/16:
$
locally run az network route-table route create -g sample-routes --route-table-name sample-rt -n blackhole --address-prefix 192.168.0.0/16 --next-hop-type None --query "{name:name, prefix:addressPrefix, nextHopType:nextHopType, state:provisioningState}"
{
"name": "blackhole",
"nextHopType": "None",
"prefix": "192.168.0.0/16",
"state": "Succeeded"
}
A VirtualAppliance route needs an address to send traffic to, so leaving it out fails:
$
locally run az network route-table route create -g sample-routes --route-table-name sample-rt -n bad --address-prefix 10.10.0.0/16 --next-hop-type VirtualAppliance
ERROR: (NextHopIpAddressRequired) Route "bad" with nextHopType VirtualAppliance requires a nextHopIpAddress.
Code: NextHopIpAddressRequired
Message: Route "bad" with nextHopType VirtualAppliance requires a nextHopIpAddress.
5. Attach it to a subnet
A Route Table does nothing until a subnet uses it. We'll create a Virtual Network with a single subnet:
$
locally run az network vnet create -g sample-routes -n sample-vnet --address-prefixes 10.0.0.0/16 --subnet-name workloads --subnet-prefixes 10.0.1.0/24
Then point the subnet at the Route Table:
$
locally run az network vnet subnet update -g sample-routes --vnet-name sample-vnet -n workloads --route-table sample-rt --query "{name:name, prefix:addressPrefix, routeTable:routeTable.id}"
{
"name": "workloads",
"prefix": "10.0.1.0/24",
"routeTable": "/subscriptions/0f766306-391f-4f66-b9ee-927fb2db629c/resourceGroups/sample-routes/providers/Microsoft.Network/routeTables/sample-rt"
}
Note
6. List the routes
To see the routes in the Route Table:
$
locally run az network route-table route list -g sample-routes --route-table-name sample-rt --query "[].{Name:name, Prefix:addressPrefix, NextHopType:nextHopType, NextHop:nextHopIpAddress}" -o table
Name Prefix NextHopType NextHop
----------- -------------- ---------------- ---------
blackhole 192.168.0.0/16 None
to-firewall 0.0.0.0/0 VirtualAppliance 10.0.2.4
We can see the Route Table and its routes in the Locally Dashboard too:
Doing this with other tooling
Whilst this guide used the Azure CLI, Route Tables work the same way through any of the tooling that Locally supports - a Microsoft.Network/routeTables resource in HashiCorp Terraform or OpenTofu, Pulumi, Bicep or an ARM Template all provision against Locally in the same way, with only the location changed.
Next steps
To control what traffic the subnet allows, add a Network Security Group. To send outbound traffic from a fixed address instead, see NAT Gateway.
Should you encounter any issues, please take a look at the troubleshooting section, reach out in our Discord or open an issue and we'll take a look.
Resource types this guide uses
These are the Azure resource types this guide creates in Locally:
During Public Preview you can use the Team plan for free, and get an early-adopter discount at GA. Sign in