Bird
Raised Fist0
Azurecloud~5 mins

Traffic Manager routing methods in Azure - Commands & Configuration

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Introduction
Traffic Manager helps direct internet traffic to different servers or services based on rules. It solves the problem of sending users to the best or closest server to improve speed and reliability.
When you want to send users to the closest server to reduce loading time.
When you want to balance traffic evenly across multiple servers to avoid overload.
When you want to send traffic only to healthy servers to avoid downtime.
When you want to prioritize one server but use others as backup if it fails.
When you want to distribute traffic based on geographic location of users.
Config File - traffic-manager-profile.json
traffic-manager-profile.json
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "resources": [
    {
      "type": "Microsoft.Network/trafficManagerProfiles",
      "apiVersion": "2021-02-01",
      "name": "myTrafficManager",
      "location": "global",
      "properties": {
        "profileStatus": "Enabled",
        "trafficRoutingMethod": "Performance",
        "dnsConfig": {
          "relativeName": "mytrafficmanager",
          "ttl": 30
        },
        "monitorConfig": {
          "protocol": "HTTP",
          "port": 80,
          "path": "/"
        },
        "endpoints": [
          {
            "name": "endpoint1",
            "type": "Microsoft.Network/trafficManagerProfiles/azureEndpoints",
            "properties": {
              "targetResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Web/sites/myApp1",
              "endpointStatus": "Enabled",
              "weight": 10,
              "endpointLocation": "eastus"
            }
          },
          {
            "name": "endpoint2",
            "type": "Microsoft.Network/trafficManagerProfiles/azureEndpoints",
            "properties": {
              "targetResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Web/sites/myApp2",
              "endpointStatus": "Enabled",
              "weight": 20,
              "endpointLocation": "westus"
            }
          }
        ]
      }
    }
  ]
}

This JSON defines an Azure Traffic Manager profile named myTrafficManager.

trafficRoutingMethod sets how traffic is routed; here it is Performance to send users to the closest endpoint.

dnsConfig sets the DNS name and time-to-live for caching.

monitorConfig defines how Traffic Manager checks if endpoints are healthy.

endpoints lists the servers or services to route traffic to, with details like location and weight.

Commands
This command creates a Traffic Manager profile named 'myTrafficManager' in the resource group 'myResourceGroup' using the Performance routing method. It sets the DNS name and health probe details.
Terminal
az network traffic-manager profile create --name myTrafficManager --resource-group myResourceGroup --routing-method Performance --unique-dns-name mytrafficmanager --ttl 30 --protocol HTTP --port 80 --path /
Expected OutputExpected
{ "dnsConfig": { "relativeName": "mytrafficmanager", "ttl": 30 }, "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/trafficManagerProfiles/myTrafficManager", "location": "global", "name": "myTrafficManager", "profileStatus": "Enabled", "trafficRoutingMethod": "Performance", "monitorConfig": { "path": "/", "port": 80, "protocol": "HTTP" }, "resourceGroup": "myResourceGroup", "type": "Microsoft.Network/trafficManagerProfiles" }
→
--routing-method - Sets how Traffic Manager routes traffic (Performance, Priority, Weighted, Geographic, etc.)
→
--unique-dns-name - Sets the DNS name for the Traffic Manager profile
This command adds an endpoint named 'endpoint1' to the Traffic Manager profile. It points to an Azure web app in East US with weight 10, used in Weighted routing.
Terminal
az network traffic-manager endpoint create --resource-group myResourceGroup --profile-name myTrafficManager --name endpoint1 --type azureEndpoints --target-resource-id /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Web/sites/myApp1 --endpoint-location eastus --weight 10
Expected OutputExpected
{ "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/trafficManagerProfiles/myTrafficManager/azureEndpoints/endpoint1", "name": "endpoint1", "properties": { "endpointStatus": "Enabled", "endpointLocation": "eastus", "weight": 10, "targetResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Web/sites/myApp1" }, "type": "Microsoft.Network/trafficManagerProfiles/azureEndpoints" }
→
--weight - Sets the weight of the endpoint for Weighted routing
→
--endpoint-location - Specifies the geographic location of the endpoint
This command adds a second endpoint named 'endpoint2' in West US with weight 20, used in Weighted routing.
Terminal
az network traffic-manager endpoint create --resource-group myResourceGroup --profile-name myTrafficManager --name endpoint2 --type azureEndpoints --target-resource-id /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Web/sites/myApp2 --endpoint-location westus --weight 20
Expected OutputExpected
{ "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/trafficManagerProfiles/myTrafficManager/azureEndpoints/endpoint2", "name": "endpoint2", "properties": { "endpointStatus": "Enabled", "endpointLocation": "westus", "weight": 20, "targetResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Web/sites/myApp2" }, "type": "Microsoft.Network/trafficManagerProfiles/azureEndpoints" }
→
--weight - Sets the weight of the endpoint for Weighted routing
This command shows the details of the Traffic Manager profile to verify its configuration and endpoints.
Terminal
az network traffic-manager profile show --name myTrafficManager --resource-group myResourceGroup
Expected OutputExpected
{ "name": "myTrafficManager", "resourceGroup": "myResourceGroup", "trafficRoutingMethod": "Performance", "dnsConfig": { "relativeName": "mytrafficmanager", "ttl": 30 }, "monitorConfig": { "protocol": "HTTP", "port": 80, "path": "/" }, "endpoints": [ { "name": "endpoint1", "properties": { "endpointStatus": "Enabled", "endpointLocation": "eastus" } }, { "name": "endpoint2", "properties": { "endpointStatus": "Enabled", "endpointLocation": "westus" } } ] }
Key Concept

If you remember nothing else from this pattern, remember: Traffic Manager routes user traffic based on rules like location, priority, or weight to send users to the best available endpoint.

Common Mistakes
Setting routing method but forgetting to add endpoints.
Traffic Manager needs endpoints to route traffic; without them, it cannot send users anywhere.
Always add at least one endpoint after creating the Traffic Manager profile.
Using Priority routing but assigning the same priority to multiple endpoints.
Priority routing requires unique priorities to decide which endpoint is primary and which are backups.
Assign distinct priority numbers to endpoints when using Priority routing.
Not configuring health probes correctly, so Traffic Manager thinks endpoints are down.
Incorrect health probe settings cause Traffic Manager to mark healthy endpoints as unhealthy, disrupting traffic flow.
Set correct protocol, port, and path in monitorConfig to match the actual endpoint health check.
Summary
Create a Traffic Manager profile with a routing method and health probe settings.
Add endpoints with details like location, priority, or weight depending on routing method.
Verify the profile and endpoints to ensure Traffic Manager routes traffic correctly.

Practice

(1/5)
1. Which Azure Traffic Manager routing method directs user traffic to the endpoint with the lowest network latency?
easy
A. Performance routing
B. Priority routing
C. Weighted routing
D. Geographic routing

Solution

  1. Step 1: Understand routing methods

    Performance routing sends users to the endpoint with the lowest latency to improve speed.
  2. Step 2: Compare other methods

    Priority routing sends traffic to a primary endpoint first; weighted routing distributes traffic by weights; geographic routing directs based on user location.
  3. Final Answer:

    Performance routing -> Option A
  4. Quick Check:

    Lowest latency = Performance routing [OK]
Hint: Lowest latency means Performance routing [OK]
Common Mistakes:
  • Confusing Priority routing with Performance routing
  • Thinking Weighted routing balances by speed
  • Assuming Geographic routing uses latency
2. Which routing method syntax correctly assigns 70% traffic to endpoint A and 30% to endpoint B in Azure Traffic Manager?
easy
A. weighted: endpointA=70, endpointB=30
B. priority: endpointA=70, endpointB=30
C. performance: endpointA=70, endpointB=30
D. geographic: endpointA=70, endpointB=30

Solution

  1. Step 1: Identify routing method for traffic distribution

    Weighted routing uses weights (percentages) to distribute traffic among endpoints.
  2. Step 2: Match syntax with method

    Only weighted routing uses weight values like 70 and 30; others do not use weights.
  3. Final Answer:

    weighted: endpointA=70, endpointB=30 -> Option A
  4. Quick Check:

    Weights = Weighted routing syntax [OK]
Hint: Weights mean Weighted routing method [OK]
Common Mistakes:
  • Using Priority routing with weights
  • Assuming Performance routing uses weights
  • Confusing Geographic routing with weights
3. Given a Traffic Manager profile with Priority routing where endpoint1 has priority 1 and endpoint2 has priority 2, what happens if endpoint1 becomes unhealthy?
medium
A. Traffic is split evenly between endpoint1 and endpoint2
B. Traffic stops until endpoint1 recovers
C. Traffic is routed to endpoint2
D. Traffic is routed based on geographic location

Solution

  1. Step 1: Understand Priority routing behavior

    Priority routing sends all traffic to the highest priority healthy endpoint.
  2. Step 2: Analyze endpoint health impact

    If endpoint1 (priority 1) is unhealthy, Traffic Manager routes traffic to the next priority endpoint, endpoint2.
  3. Final Answer:

    Traffic is routed to endpoint2 -> Option C
  4. Quick Check:

    Unhealthy primary = failover to next priority [OK]
Hint: Failover sends traffic to next priority endpoint [OK]
Common Mistakes:
  • Thinking traffic stops when primary is down
  • Assuming traffic splits evenly in Priority routing
  • Confusing geographic routing with priority failover
4. You configured Geographic routing but users from Europe are still routed to the US endpoint. What is the most likely cause?
medium
A. Endpoint monitoring is disabled
B. DNS TTL is set too low
C. Weighted routing is overriding Geographic routing
D. Geographic regions are overlapping or misconfigured

Solution

  1. Step 1: Understand Geographic routing setup

    Geographic routing directs users based on their location mapped to specific endpoints.
  2. Step 2: Identify misconfiguration impact

    If regions overlap or are misconfigured, users may be routed incorrectly, like Europe users going to US endpoint.
  3. Final Answer:

    Geographic regions are overlapping or misconfigured -> Option D
  4. Quick Check:

    Misconfigured regions cause wrong routing [OK]
Hint: Check region mappings for overlaps or errors [OK]
Common Mistakes:
  • Assuming monitoring affects geographic routing directly
  • Confusing weighted routing with geographic routing
  • Thinking DNS TTL causes wrong region routing
5. You want to ensure users in Asia always use a specific endpoint, but if it fails, traffic should go to the fastest available endpoint anywhere. Which routing method combination should you use?
hard
A. Weighted routing with Geographic fallback to Priority routing
B. Geographic routing with Priority fallback to Performance routing
C. Priority routing with Weighted fallback to Geographic routing
D. Performance routing with Priority fallback to Weighted routing

Solution

  1. Step 1: Identify requirement for fixed region routing

    Geographic routing ensures users in Asia use the specific endpoint assigned to that region.
  2. Step 2: Identify fallback for endpoint failure

    If the Asia endpoint fails, fallback should route to the fastest available endpoint globally, which is Performance routing.
  3. Step 3: Combine routing methods

    Use Geographic routing as primary, with Priority routing configured to fallback to Performance routing for failover.
  4. Final Answer:

    Geographic routing with Priority fallback to Performance routing -> Option B
  5. Quick Check:

    Fixed region + failover to fastest endpoint = Geographic + Priority + Performance [OK]
Hint: Use Geographic for region, Performance for speed fallback [OK]
Common Mistakes:
  • Mixing Weighted routing for fixed region needs
  • Using Priority routing alone without geographic control
  • Confusing fallback order and methods