Overview
Azure Traffic Manager is a DNS‑based load balancer that enables you to distribute traffic for your services across multiple Azure regions or external endpoints. It improves availability, reduces latency, and provides geo‑routing capabilities.
Routing methods
| Method | Description |
|---|---|
| Priority | Directs traffic to the primary endpoint; fails over to secondary endpoints if primary is unavailable. |
| Weighted | Distributes traffic across endpoints based on assigned weights. |
| Performance | Sends users to the endpoint with the lowest network latency. |
| Geographic | Routes users based on their DNS‑resolved geographic location. |
| Multi‑Value | Returns multiple IP addresses to improve client‑side resilience. |
| Subnet | Routes traffic based on the client’s subnet IP range. |
Profile types
A Traffic Manager profile groups DNS endpoints and defines the routing method. Choose the profile type that matches your scenario:
- Public – Exposes your service over the internet.
- Private – Used within Azure Virtual Networks via Private Link.
Configuration steps
- Create a Traffic Manager profile in the Azure portal.
- Choose a routing method that aligns with your business needs.
- Add endpoints (Azure, external, or nested Traffic Manager profiles).
- Configure health probes (protocol, port, path, interval).
- Update your DNS CNAME record to point to the Traffic Manager domain (e.g.,
myapp.trafficmanager.net).
Monitoring & alerts
Traffic Manager continuously probes each endpoint. You can configure alerts based on endpoint health using Azure Monitor.
az monitor metrics alert create \
--name "EndpointHealthAlert" \
--resource-group MyResourceGroup \
--scopes /subscriptions/xxxx/resourceGroups/MyResourceGroup/providers/microsoft.network/trafficmanagerprofiles/MyProfile \
--condition "max TrafficManagerEndpointHealthState > 0" \
--description "Alert when any endpoint becomes unhealthy"
Sample code
Below is a simple .NET Core snippet that retrieves the list of endpoints for a profile using Azure SDK.
using Azure;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.TrafficManager;
using System;
using System.Threading.Tasks;
public class TrafficManagerDemo
{
public static async Task Main()
{
var credential = new DefaultAzureCredential();
var armClient = new ArmClient(credential);
var subscription = await armClient.GetDefaultSubscriptionAsync();
var tmProfile = await subscription.GetTrafficManagerProfiles()
.GetAsync("myTrafficManagerProfile");
await foreach (var endpoint in tmProfile.Value.GetEndpoints().GetAllAsync())
{
Console.WriteLine($"{endpoint.Data.Name} - {endpoint.Data.Target}");
}
}
}
FAQ
- Does Traffic Manager improve performance?
- Yes, especially when using the Performance routing method, which directs users to the nearest endpoint.
- Can I combine multiple routing methods?
- Traffic Manager supports a single routing method per profile. To achieve hybrid scenarios, use nested profiles.
- How does health monitoring work?
- Health probes are sent from multiple Azure regions at configurable intervals. If an endpoint fails > N consecutive probes, it is marked unhealthy.