CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-azure-mgmt-trafficmanager

Microsoft Azure Traffic Manager Management Client Library for Python

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

endpoints.mddocs/

Endpoint Management

Management of Traffic Manager endpoints including Azure endpoints, external endpoints, and nested endpoints with full CRUD operations. Endpoints represent the actual services that receive traffic and can be configured with weights, priorities, geographic mappings, and health monitoring settings.

Capabilities

Create or Update Endpoint

Creates a new Traffic Manager endpoint or updates an existing one with complete configuration including target, routing settings, and health monitoring parameters.

def create_or_update(
    resource_group_name: str,
    profile_name: str,
    endpoint_type: Union[str, EndpointType],
    endpoint_name: str,
    parameters: Union[Endpoint, IO]
) -> Endpoint:
    """
    Creates or updates a Traffic Manager endpoint.

    Args:
        resource_group_name (str): Name of the resource group
        profile_name (str): Name of the Traffic Manager profile
        endpoint_type (Union[str, EndpointType]): Type of endpoint
        endpoint_name (str): Name of the endpoint
        parameters (Endpoint): Endpoint configuration

    Returns:
        Endpoint: The created or updated endpoint
    """

Usage Examples:

from azure.mgmt.trafficmanager.models import Endpoint, EndpointType

# Azure endpoint (points to Azure resource)
azure_endpoint = Endpoint(
    target_resource_id="/subscriptions/12345/resourceGroups/my-rg/providers/Microsoft.Web/sites/my-web-app",
    endpoint_status="Enabled",
    weight=100,
    priority=1,
    endpoint_location="East US",  # For performance routing
    custom_headers=[
        {"name": "X-Forwarded-Host", "value": "original.example.com"}
    ]
)

endpoint = client.endpoints.create_or_update(
    resource_group_name="my-rg",
    profile_name="my-profile",
    endpoint_type=EndpointType.AZURE_ENDPOINTS,
    endpoint_name="web-app-east",
    parameters=azure_endpoint
)

# External endpoint (points to external FQDN/IP)
external_endpoint = Endpoint(
    target="external-service.example.com",
    endpoint_status="Enabled",
    weight=50,
    priority=2,
    endpoint_location="West Europe",
    geo_mapping=["FR", "DE", "ES"],  # For geographic routing
    subnets=[  # For subnet routing
        {"first": "192.168.1.0", "scope": 24},
        {"first": "10.0.0.0", "last": "10.0.0.255"}
    ]
)

external_ep = client.endpoints.create_or_update(
    resource_group_name="my-rg",
    profile_name="my-profile",
    endpoint_type="ExternalEndpoints",
    endpoint_name="external-service",
    parameters=external_endpoint
)

# Nested endpoint (points to another Traffic Manager profile)
nested_endpoint = Endpoint(
    target_resource_id="/subscriptions/12345/resourceGroups/nested-rg/providers/Microsoft.Network/trafficManagerProfiles/nested-profile",
    endpoint_status="Enabled",
    weight=75,
    priority=1,
    min_child_endpoints=2,        # Minimum healthy child endpoints
    min_child_endpoints_i_pv4=1,  # Minimum IPv4 endpoints
    min_child_endpoints_i_pv6=1,  # Minimum IPv6 endpoints
    endpoint_location="Global"
)

nested_ep = client.endpoints.create_or_update(
    resource_group_name="my-rg",
    profile_name="my-profile",
    endpoint_type="NestedEndpoints",
    endpoint_name="nested-profile",
    parameters=nested_endpoint
)

Get Endpoint

Retrieves a specific Traffic Manager endpoint with complete configuration details and current health status.

def get(
    resource_group_name: str,
    profile_name: str,
    endpoint_type: Union[str, EndpointType],
    endpoint_name: str
) -> Endpoint:
    """
    Gets a Traffic Manager endpoint.

    Args:
        resource_group_name (str): Name of the resource group
        profile_name (str): Name of the Traffic Manager profile
        endpoint_type (Union[str, EndpointType]): Type of endpoint
        endpoint_name (str): Name of the endpoint

    Returns:
        Endpoint: The Traffic Manager endpoint
    """

Update Endpoint

Updates an existing Traffic Manager endpoint with partial configuration changes while preserving unchanged settings.

def update(
    resource_group_name: str,
    profile_name: str,
    endpoint_type: Union[str, EndpointType],
    endpoint_name: str,
    parameters: Union[Endpoint, IO]
) -> Endpoint:
    """
    Updates a Traffic Manager endpoint.

    Args:
        resource_group_name (str): Name of the resource group
        profile_name (str): Name of the Traffic Manager profile
        endpoint_type (Union[str, EndpointType]): Type of endpoint
        endpoint_name (str): Name of the endpoint
        parameters (Endpoint): Updated endpoint configuration

    Returns:
        Endpoint: The updated endpoint
    """

Usage Example:

# Update endpoint weight for traffic shifting
endpoint = client.endpoints.get(
    resource_group_name="my-rg",
    profile_name="my-profile",
    endpoint_type="AzureEndpoints",
    endpoint_name="web-app-east"
)

# Reduce traffic to this endpoint
endpoint.weight = 25
endpoint.custom_headers.append({"name": "X-Canary", "value": "true"})

updated_endpoint = client.endpoints.update(
    resource_group_name="my-rg",
    profile_name="my-profile",
    endpoint_type="AzureEndpoints",
    endpoint_name="web-app-east",
    parameters=endpoint
)

Delete Endpoint

Deletes a Traffic Manager endpoint permanently, removing it from the traffic routing configuration.

def delete(
    resource_group_name: str,
    profile_name: str,
    endpoint_type: Union[str, EndpointType],
    endpoint_name: str
) -> Optional[DeleteOperationResult]:
    """
    Deletes a Traffic Manager endpoint.

    Args:
        resource_group_name (str): Name of the resource group
        profile_name (str): Name of the Traffic Manager profile
        endpoint_type (Union[str, EndpointType]): Type of endpoint
        endpoint_name (str): Name of the endpoint

    Returns:
        Optional[DeleteOperationResult]: Operation result or None
    """

Endpoint Configuration Types

Endpoint Types

class EndpointType(str, Enum):
    """Types of Traffic Manager endpoints."""
    AZURE_ENDPOINTS = "AzureEndpoints"        # Azure resources
    EXTERNAL_ENDPOINTS = "ExternalEndpoints"  # External services
    NESTED_ENDPOINTS = "NestedEndpoints"      # Nested Traffic Manager profiles

Endpoint Configuration

class Endpoint:
    """Traffic Manager endpoint configuration."""
    # Target configuration
    target_resource_id: str                                # Azure Resource URI (for Azure/Nested endpoints)
    target: str                                           # FQDN or IP (for External endpoints)
    
    # Status and routing
    endpoint_status: EndpointStatus                       # Enabled or Disabled
    endpoint_monitor_status: EndpointMonitorStatus        # Health status (read-only)
    
    # Routing weights and priorities
    weight: int                                           # Weight for Weighted routing (1-1000)
    priority: int                                         # Priority for Priority routing (1-1000)
    
    # Location and geographic mapping
    endpoint_location: str                                # Location for Performance routing
    geo_mapping: List[str]                               # Geographic codes for Geographic routing
    
    # Subnet routing
    subnets: List[EndpointPropertiesSubnetsItem]         # Subnet mappings for Subnet routing
    
    # Nested endpoint configuration
    min_child_endpoints: int                             # Minimum healthy child endpoints
    min_child_endpoints_i_pv4: int                       # Minimum IPv4 child endpoints
    min_child_endpoints_i_pv6: int                       # Minimum IPv6 child endpoints
    
    # Custom headers and advanced options
    custom_headers: List[EndpointPropertiesCustomHeadersItem]  # Custom HTTP headers
    always_serve: AlwaysServe                            # Always serve configuration

class EndpointPropertiesCustomHeadersItem:
    """Custom header for endpoint requests."""
    name: str                                            # Header name
    value: str                                           # Header value

class EndpointPropertiesSubnetsItem:
    """Subnet configuration for subnet routing."""
    first: str                                           # First IP address in range
    last: str                                            # Last IP address in range (optional)
    scope: int                                           # Subnet mask bits (optional)

Endpoint Status Types

class EndpointStatus(str, Enum):
    """Endpoint operational status."""
    ENABLED = "Enabled"                                  # Endpoint accepts traffic
    DISABLED = "Disabled"                                # Endpoint does not accept traffic

class EndpointMonitorStatus(str, Enum):
    """Endpoint health monitoring status."""
    CHECKING_ENDPOINT = "CheckingEndpoint"               # Health check in progress
    ONLINE = "Online"                                    # Endpoint is healthy
    DEGRADED = "Degraded"                                # Endpoint has issues
    DISABLED = "Disabled"                                # Monitoring disabled
    INACTIVE = "Inactive"                                # Endpoint inactive
    STOPPED = "Stopped"                                  # Endpoint stopped
    UNMONITORED = "Unmonitored"                          # Not monitored

class AlwaysServe(str, Enum):
    """Always serve configuration."""
    ENABLED = "Enabled"                                  # Always serve endpoint
    DISABLED = "Disabled"                                # Standard serving logic

Routing Configuration Guidelines

Performance Routing

For performance-based routing, configure endpoint_location to match the Azure region or geographic location of the endpoint:

endpoint.endpoint_location = "East US"        # Azure region
endpoint.endpoint_location = "North America"  # Geographic region

Weighted Routing

For weighted routing, assign weights (1-1000) to distribute traffic proportionally:

endpoint_a.weight = 80  # 80% of traffic
endpoint_b.weight = 20  # 20% of traffic

Priority Routing

For failover routing, assign priorities (1=highest, higher numbers=lower priority):

primary_endpoint.priority = 1    # Primary
secondary_endpoint.priority = 2  # Failover

Geographic Routing

For geographic routing, specify region codes in geo_mapping:

# European traffic
endpoint.geo_mapping = ["FR", "DE", "IT", "ES", "WORLD-EUR"]

# North American traffic  
endpoint.geo_mapping = ["US", "CA", "MX"]

Subnet Routing

For subnet-based routing, configure IP ranges:

endpoint.subnets = [
    {"first": "192.168.1.0", "scope": 24},           # CIDR notation
    {"first": "10.0.0.1", "last": "10.0.0.100"}     # Range notation
]

MultiValue Routing

For MultiValue routing, endpoints return multiple healthy endpoints (no special configuration needed on endpoints, configure max_return on profile).

Advanced Endpoint Configurations

Custom Headers

Add custom headers for endpoint requests:

endpoint.custom_headers = [
    {"name": "X-Forwarded-Host", "value": "original.example.com"},
    {"name": "Authorization", "value": "Bearer token123"},
    {"name": "X-Custom-Header", "value": "custom-value"}
]

Nested Endpoint Configuration

For nested endpoints pointing to child Traffic Manager profiles:

nested_endpoint = Endpoint(
    target_resource_id="/subscriptions/.../providers/Microsoft.Network/trafficManagerProfiles/child-profile",
    endpoint_status="Enabled",
    min_child_endpoints=2,        # Require at least 2 healthy children
    min_child_endpoints_i_pv4=1,  # At least 1 IPv4 endpoint
    min_child_endpoints_i_pv6=0,  # No IPv6 requirement
    endpoint_location="Global"    # For performance routing
)

Install with Tessl CLI

npx tessl i tessl/pypi-azure-mgmt-trafficmanager

docs

analytics.md

client.md

endpoints.md

geographic.md

index.md

profiles.md

tile.json