Traffic Manager subnet override using Azure CLI
Traffic Manager subnet override allows you to alter the routing method of a profile. The addition of an override will direct traffic based upon the end user's IP address with a predefined IP range to endpoint mapping.
How subnet override works
When subnet overrides are added to a traffic manager profile, Traffic Manager will first check if there's a subnet override for the end user’s IP address. If one is found, the user’s DNS query will be directed to the corresponding endpoint. If a mapping is not found, Traffic Manager will fall back to the profile’s original routing method.
The IP address ranges can be specified as either CIDR ranges (for example, 188.8.131.52/24) or as address ranges (for example, 184.108.40.206-220.127.116.11). The IP ranges associated with each endpoint must be unique to that endpoint. Any overlap of IP ranges among different endpoints will cause the profile to be rejected by Traffic Manager.
There are two types of routing profiles that support subnet overrides:
- Geographic - If Traffic Manager finds a subnet override for the DNS query's IP address, it will route the query to the endpoint whatever the health of the endpoint is.
- Performance - If Traffic Manager finds a subnet override for the DNS query's IP address, it will only route the traffic to the endpoint if it's healthy. Traffic Manager will fall back to the performance routing heuristic if the subnet override endpoint isn't healthy.
Create a Traffic Manager subnet override
To create a Traffic Manager subnet override, you can use Azure CLI to add the subnets for the override to the Traffic Manager endpoint.
If you prefer to run CLI reference commands locally, install the Azure CLI. If you're running on Windows or macOS, consider running Azure CLI in a Docker container. For more information, see How to run the Azure CLI in a Docker container.
If you're using a local installation, sign in to the Azure CLI by using the az login command. To finish the authentication process, follow the steps displayed in your terminal. For other sign-in options, see Sign in with the Azure CLI.
When you're prompted, install the Azure CLI extension on first use. For more information about extensions, see Use extensions with the Azure CLI.
- This article requires version 2.0.28 or later of the Azure CLI. If using Azure Cloud Shell, the latest version is already installed.
Update the Traffic Manager endpoint with subnet override.
Use Azure CLI to update your endpoint with az network traffic-manager endpoint update.
### Add a range of IPs ### az network traffic-manager endpoint update \ --name MyEndpoint \ --profile-name MyTmProfile \ --resource-group MyResourceGroup \ --subnets 18.104.22.168-22.214.171.124 \ --type AzureEndpoints ### Add a subnet ### az network traffic-manager endpoint update \ --name MyEndpoint \ --profile-name MyTmProfile \ --resource-group MyResourceGroup \ --subnets 126.96.36.199:24 \ --type AzureEndpoints
You can remove the IP address ranges by running the az network traffic-manager endpoint update with the --remove option.
az network traffic-manager endpoint update \ --name MyEndpoint \ --profile-name MyTmProfile \ --resource-group MyResourceGroup \ --remove subnets \ --type AzureEndpoints
Learn more about Traffic Manager traffic routing methods.
Learn about the Subnet traffic-routing method