or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

analytics.mdclient.mdendpoints.mdgeographic.mdindex.mdprofiles.md
tile.json

tessl/pypi-azure-mgmt-trafficmanager

Microsoft Azure Traffic Manager Management Client Library for Python

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/azure-mgmt-trafficmanager@1.1.x

To install, run

npx @tessl/cli install tessl/pypi-azure-mgmt-trafficmanager@1.1.0

index.mddocs/

Azure Traffic Manager Management Client Library

A comprehensive Python client library for managing Azure Traffic Manager services through the Azure Resource Manager API. This library enables developers to programmatically create, configure, and manage Traffic Manager profiles, endpoints, and geographic hierarchies for load balancing and traffic routing across Azure regions.

Package Information

  • Package Name: azure-mgmt-trafficmanager
  • Language: Python
  • Installation: pip install azure-mgmt-trafficmanager
  • Azure SDK Type: Management library for Azure Resource Manager
  • API Version: 2022-04-01

Core Imports

from azure.mgmt.trafficmanager import TrafficManagerManagementClient
from azure.identity import DefaultAzureCredential
from azure.core.credentials import TokenCredential

For async operations:

from azure.mgmt.trafficmanager.aio import TrafficManagerManagementClient
from azure.identity.aio import DefaultAzureCredential

For models and enums:

from azure.mgmt.trafficmanager.models import (
    Profile, Endpoint, DnsConfig, MonitorConfig,
    TrafficRoutingMethod, EndpointType, ProfileStatus
)

Basic Usage

from azure.mgmt.trafficmanager import TrafficManagerManagementClient
from azure.identity import DefaultAzureCredential

# Initialize client
credential = DefaultAzureCredential()
subscription_id = "your-subscription-id"
client = TrafficManagerManagementClient(credential, subscription_id)

# Create a basic Traffic Manager profile
profile = client.profiles.create_or_update(
    resource_group_name="my-rg",
    profile_name="my-profile",
    parameters={
        "location": "global",
        "tags": {"environment": "production"},
        "profile_status": "Enabled",
        "traffic_routing_method": "Performance",
        "dns_config": {
            "relative_name": "my-app-tm",
            "ttl": 60
        },
        "monitor_config": {
            "protocol": "HTTPS",
            "port": 443,
            "path": "/health",
            "interval_in_seconds": 30,
            "timeout_in_seconds": 10,
            "tolerated_number_of_failures": 3
        }
    }
)

# Add an Azure endpoint
endpoint = client.endpoints.create_or_update(
    resource_group_name="my-rg",
    profile_name="my-profile",
    endpoint_type="AzureEndpoints",
    endpoint_name="my-endpoint",
    parameters={
        "target_resource_id": "/subscriptions/.../resourceGroups/.../providers/Microsoft.Web/sites/my-app",
        "endpoint_status": "Enabled",
        "weight": 100,
        "priority": 1
    }
)

print(f"Profile FQDN: {profile.dns_config.fqdn}")

Architecture

The Azure Traffic Manager Management Client follows Azure SDK patterns and provides:

  • TrafficManagerManagementClient: Main client class for all operations
  • Operations Groups: Specialized classes for different resource types
    • profiles: Traffic Manager profile management
    • endpoints: Traffic Manager endpoint management
    • geographic_hierarchies: Geographic routing configuration
    • heat_map: Performance analytics and heat maps
    • traffic_manager_user_metrics_keys: Real user metrics configuration
  • Models: Strongly-typed data classes for all API resources
  • Enums: Constants for configuration options
  • Authentication: Integration with azure-identity for unified credential handling
  • Async Support: Full async/await support through aio module

Capabilities

Traffic Manager Client

Primary client class for managing all Traffic Manager resources with Azure authentication and subscription-based operations.

class TrafficManagerManagementClient:
    def __init__(
        self,
        credential: TokenCredential,
        subscription_id: str,
        base_url: str = "https://management.azure.com",
        **kwargs
    ): ...
    
    def close(self) -> None: ...
    def __enter__(self) -> "TrafficManagerManagementClient": ...
    def __exit__(self, *exc_details) -> None: ...

Traffic Manager Client

Profile Management

Complete lifecycle management of Traffic Manager profiles including creation, configuration, updating, deletion, and listing operations.

def create_or_update(
    resource_group_name: str,
    profile_name: str,
    parameters: Profile
) -> Profile: ...

def get(resource_group_name: str, profile_name: str) -> Profile: ...
def update(resource_group_name: str, profile_name: str, parameters: Profile) -> Profile: ...
def delete(resource_group_name: str, profile_name: str) -> Optional[DeleteOperationResult]: ...
def list_by_resource_group(resource_group_name: str) -> Iterable[Profile]: ...
def list_by_subscription() -> Iterable[Profile]: ...

Profile Management

Endpoint Management

Management of Traffic Manager endpoints including Azure endpoints, external endpoints, and nested endpoints with full CRUD operations.

def create_or_update(
    resource_group_name: str,
    profile_name: str,
    endpoint_type: Union[str, EndpointType],
    endpoint_name: str,
    parameters: Endpoint
) -> Endpoint: ...

def get(
    resource_group_name: str,
    profile_name: str,
    endpoint_type: Union[str, EndpointType],
    endpoint_name: str
) -> Endpoint: ...

Endpoint Management

Analytics and Monitoring

Traffic analytics through heat maps, health monitoring configuration, and real user metrics for performance optimization.

def get(
    resource_group_name: str,
    profile_name: str,
    top_left: Optional[List[float]] = None,
    bot_right: Optional[List[float]] = None
) -> HeatMapModel: ...

def create_or_update() -> UserMetricsModel: ...
def get() -> UserMetricsModel: ...
def delete() -> DeleteOperationResult: ...

Analytics and Monitoring

Geographic Routing

Geographic hierarchy management for geographic-based traffic routing including region codes and hierarchical geographic mappings.

def get_default_geographic_hierarchy() -> TrafficManagerGeographicHierarchy: ...

Geographic Routing

Core Types

class Profile:
    """Traffic Manager profile configuration."""
    profile_status: ProfileStatus
    traffic_routing_method: TrafficRoutingMethod
    dns_config: DnsConfig
    monitor_config: MonitorConfig
    endpoints: List[Endpoint]
    traffic_view_enrollment_status: TrafficViewEnrollmentStatus
    allowed_endpoint_record_types: List[AllowedEndpointRecordType]
    max_return: int

class Endpoint:
    """Traffic Manager endpoint configuration."""
    target_resource_id: str
    target: str
    endpoint_status: EndpointStatus
    weight: int
    priority: int
    endpoint_location: str
    endpoint_monitor_status: EndpointMonitorStatus
    min_child_endpoints: int
    geo_mapping: List[str]
    subnets: List[EndpointPropertiesSubnetsItem]
    custom_headers: List[EndpointPropertiesCustomHeadersItem]

class DnsConfig:
    """DNS configuration for Traffic Manager profiles."""
    relative_name: str
    fqdn: str  # read-only
    ttl: int

class MonitorConfig:
    """Health monitoring configuration."""
    profile_monitor_status: ProfileMonitorStatus
    protocol: MonitorProtocol
    port: int
    path: str
    interval_in_seconds: int
    timeout_in_seconds: int
    tolerated_number_of_failures: int
    custom_headers: List[MonitorConfigCustomHeadersItem]
    expected_status_code_ranges: List[MonitorConfigExpectedStatusCodeRangesItem]

Enumerations

class TrafficRoutingMethod(str, Enum):
    PERFORMANCE = "Performance"
    PRIORITY = "Priority"  
    WEIGHTED = "Weighted"
    GEOGRAPHIC = "Geographic"
    MULTI_VALUE = "MultiValue"
    SUBNET = "Subnet"

class EndpointType(str, Enum):
    AZURE_ENDPOINTS = "AzureEndpoints"
    EXTERNAL_ENDPOINTS = "ExternalEndpoints"
    NESTED_ENDPOINTS = "NestedEndpoints"

class ProfileStatus(str, Enum):
    ENABLED = "Enabled"
    DISABLED = "Disabled"

class EndpointStatus(str, Enum):
    ENABLED = "Enabled"
    DISABLED = "Disabled"

class MonitorProtocol(str, Enum):
    HTTP = "HTTP"
    HTTPS = "HTTPS"
    TCP = "TCP"

class AlwaysServe(str, Enum):
    ENABLED = "Enabled"
    DISABLED = "Disabled"