0
# Azure Traffic Manager Management Client Library
1
2
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.
3
4
## Package Information
5
6
- **Package Name**: azure-mgmt-trafficmanager
7
- **Language**: Python
8
- **Installation**: `pip install azure-mgmt-trafficmanager`
9
- **Azure SDK Type**: Management library for Azure Resource Manager
10
- **API Version**: 2022-04-01
11
12
## Core Imports
13
14
```python
15
from azure.mgmt.trafficmanager import TrafficManagerManagementClient
16
from azure.identity import DefaultAzureCredential
17
from azure.core.credentials import TokenCredential
18
```
19
20
For async operations:
21
22
```python
23
from azure.mgmt.trafficmanager.aio import TrafficManagerManagementClient
24
from azure.identity.aio import DefaultAzureCredential
25
```
26
27
For models and enums:
28
29
```python
30
from azure.mgmt.trafficmanager.models import (
31
Profile, Endpoint, DnsConfig, MonitorConfig,
32
TrafficRoutingMethod, EndpointType, ProfileStatus
33
)
34
```
35
36
## Basic Usage
37
38
```python
39
from azure.mgmt.trafficmanager import TrafficManagerManagementClient
40
from azure.identity import DefaultAzureCredential
41
42
# Initialize client
43
credential = DefaultAzureCredential()
44
subscription_id = "your-subscription-id"
45
client = TrafficManagerManagementClient(credential, subscription_id)
46
47
# Create a basic Traffic Manager profile
48
profile = client.profiles.create_or_update(
49
resource_group_name="my-rg",
50
profile_name="my-profile",
51
parameters={
52
"location": "global",
53
"tags": {"environment": "production"},
54
"profile_status": "Enabled",
55
"traffic_routing_method": "Performance",
56
"dns_config": {
57
"relative_name": "my-app-tm",
58
"ttl": 60
59
},
60
"monitor_config": {
61
"protocol": "HTTPS",
62
"port": 443,
63
"path": "/health",
64
"interval_in_seconds": 30,
65
"timeout_in_seconds": 10,
66
"tolerated_number_of_failures": 3
67
}
68
}
69
)
70
71
# Add an Azure endpoint
72
endpoint = client.endpoints.create_or_update(
73
resource_group_name="my-rg",
74
profile_name="my-profile",
75
endpoint_type="AzureEndpoints",
76
endpoint_name="my-endpoint",
77
parameters={
78
"target_resource_id": "/subscriptions/.../resourceGroups/.../providers/Microsoft.Web/sites/my-app",
79
"endpoint_status": "Enabled",
80
"weight": 100,
81
"priority": 1
82
}
83
)
84
85
print(f"Profile FQDN: {profile.dns_config.fqdn}")
86
```
87
88
## Architecture
89
90
The Azure Traffic Manager Management Client follows Azure SDK patterns and provides:
91
92
- **TrafficManagerManagementClient**: Main client class for all operations
93
- **Operations Groups**: Specialized classes for different resource types
94
- `profiles`: Traffic Manager profile management
95
- `endpoints`: Traffic Manager endpoint management
96
- `geographic_hierarchies`: Geographic routing configuration
97
- `heat_map`: Performance analytics and heat maps
98
- `traffic_manager_user_metrics_keys`: Real user metrics configuration
99
- **Models**: Strongly-typed data classes for all API resources
100
- **Enums**: Constants for configuration options
101
- **Authentication**: Integration with azure-identity for unified credential handling
102
- **Async Support**: Full async/await support through aio module
103
104
## Capabilities
105
106
### Traffic Manager Client
107
108
Primary client class for managing all Traffic Manager resources with Azure authentication and subscription-based operations.
109
110
```python { .api }
111
class TrafficManagerManagementClient:
112
def __init__(
113
self,
114
credential: TokenCredential,
115
subscription_id: str,
116
base_url: str = "https://management.azure.com",
117
**kwargs
118
): ...
119
120
def close(self) -> None: ...
121
def __enter__(self) -> "TrafficManagerManagementClient": ...
122
def __exit__(self, *exc_details) -> None: ...
123
```
124
125
[Traffic Manager Client](./client.md)
126
127
### Profile Management
128
129
Complete lifecycle management of Traffic Manager profiles including creation, configuration, updating, deletion, and listing operations.
130
131
```python { .api }
132
def create_or_update(
133
resource_group_name: str,
134
profile_name: str,
135
parameters: Profile
136
) -> Profile: ...
137
138
def get(resource_group_name: str, profile_name: str) -> Profile: ...
139
def update(resource_group_name: str, profile_name: str, parameters: Profile) -> Profile: ...
140
def delete(resource_group_name: str, profile_name: str) -> Optional[DeleteOperationResult]: ...
141
def list_by_resource_group(resource_group_name: str) -> Iterable[Profile]: ...
142
def list_by_subscription() -> Iterable[Profile]: ...
143
```
144
145
[Profile Management](./profiles.md)
146
147
### Endpoint Management
148
149
Management of Traffic Manager endpoints including Azure endpoints, external endpoints, and nested endpoints with full CRUD operations.
150
151
```python { .api }
152
def create_or_update(
153
resource_group_name: str,
154
profile_name: str,
155
endpoint_type: Union[str, EndpointType],
156
endpoint_name: str,
157
parameters: Endpoint
158
) -> Endpoint: ...
159
160
def get(
161
resource_group_name: str,
162
profile_name: str,
163
endpoint_type: Union[str, EndpointType],
164
endpoint_name: str
165
) -> Endpoint: ...
166
```
167
168
[Endpoint Management](./endpoints.md)
169
170
### Analytics and Monitoring
171
172
Traffic analytics through heat maps, health monitoring configuration, and real user metrics for performance optimization.
173
174
```python { .api }
175
def get(
176
resource_group_name: str,
177
profile_name: str,
178
top_left: Optional[List[float]] = None,
179
bot_right: Optional[List[float]] = None
180
) -> HeatMapModel: ...
181
182
def create_or_update() -> UserMetricsModel: ...
183
def get() -> UserMetricsModel: ...
184
def delete() -> DeleteOperationResult: ...
185
```
186
187
[Analytics and Monitoring](./analytics.md)
188
189
### Geographic Routing
190
191
Geographic hierarchy management for geographic-based traffic routing including region codes and hierarchical geographic mappings.
192
193
```python { .api }
194
def get_default_geographic_hierarchy() -> TrafficManagerGeographicHierarchy: ...
195
```
196
197
[Geographic Routing](./geographic.md)
198
199
## Core Types
200
201
```python { .api }
202
class Profile:
203
"""Traffic Manager profile configuration."""
204
profile_status: ProfileStatus
205
traffic_routing_method: TrafficRoutingMethod
206
dns_config: DnsConfig
207
monitor_config: MonitorConfig
208
endpoints: List[Endpoint]
209
traffic_view_enrollment_status: TrafficViewEnrollmentStatus
210
allowed_endpoint_record_types: List[AllowedEndpointRecordType]
211
max_return: int
212
213
class Endpoint:
214
"""Traffic Manager endpoint configuration."""
215
target_resource_id: str
216
target: str
217
endpoint_status: EndpointStatus
218
weight: int
219
priority: int
220
endpoint_location: str
221
endpoint_monitor_status: EndpointMonitorStatus
222
min_child_endpoints: int
223
geo_mapping: List[str]
224
subnets: List[EndpointPropertiesSubnetsItem]
225
custom_headers: List[EndpointPropertiesCustomHeadersItem]
226
227
class DnsConfig:
228
"""DNS configuration for Traffic Manager profiles."""
229
relative_name: str
230
fqdn: str # read-only
231
ttl: int
232
233
class MonitorConfig:
234
"""Health monitoring configuration."""
235
profile_monitor_status: ProfileMonitorStatus
236
protocol: MonitorProtocol
237
port: int
238
path: str
239
interval_in_seconds: int
240
timeout_in_seconds: int
241
tolerated_number_of_failures: int
242
custom_headers: List[MonitorConfigCustomHeadersItem]
243
expected_status_code_ranges: List[MonitorConfigExpectedStatusCodeRangesItem]
244
```
245
246
## Enumerations
247
248
```python { .api }
249
class TrafficRoutingMethod(str, Enum):
250
PERFORMANCE = "Performance"
251
PRIORITY = "Priority"
252
WEIGHTED = "Weighted"
253
GEOGRAPHIC = "Geographic"
254
MULTI_VALUE = "MultiValue"
255
SUBNET = "Subnet"
256
257
class EndpointType(str, Enum):
258
AZURE_ENDPOINTS = "AzureEndpoints"
259
EXTERNAL_ENDPOINTS = "ExternalEndpoints"
260
NESTED_ENDPOINTS = "NestedEndpoints"
261
262
class ProfileStatus(str, Enum):
263
ENABLED = "Enabled"
264
DISABLED = "Disabled"
265
266
class EndpointStatus(str, Enum):
267
ENABLED = "Enabled"
268
DISABLED = "Disabled"
269
270
class MonitorProtocol(str, Enum):
271
HTTP = "HTTP"
272
HTTPS = "HTTPS"
273
TCP = "TCP"
274
275
class AlwaysServe(str, Enum):
276
ENABLED = "Enabled"
277
DISABLED = "Disabled"
278
```