Microsoft Azure API Management Client Library for Python providing comprehensive SDK functionality for managing Azure API Management services.
npx @tessl/cli install tessl/pypi-azure-mgmt-apimanagement@5.0.00
# Azure API Management Client Library
1
2
Microsoft Azure API Management Client Library for Python provides comprehensive SDK functionality for programmatically managing and configuring Azure API Management instances. This library enables developers to automate API lifecycle management, implement governance policies, configure authentication systems, manage developer portals, and monitor API usage through Python applications.
3
4
## Package Information
5
6
- **Package Name**: azure-mgmt-apimanagement
7
- **Package Type**: pip
8
- **Language**: Python
9
- **Installation**: `pip install azure-mgmt-apimanagement`
10
- **Dependencies**: `isodate>=0.6.1`, `typing-extensions>=4.6.0`, `azure-common>=1.1`, `azure-mgmt-core>=1.3.2`, `azure-identity` (for authentication)
11
12
## Core Imports
13
14
```python
15
from azure.mgmt.apimanagement import ApiManagementClient
16
from azure.identity import DefaultAzureCredential
17
```
18
19
## Basic Usage
20
21
```python
22
from azure.mgmt.apimanagement import ApiManagementClient
23
from azure.identity import DefaultAzureCredential
24
25
# Create client with authentication
26
credential = DefaultAzureCredential()
27
client = ApiManagementClient(
28
credential=credential,
29
subscription_id="your-subscription-id"
30
)
31
32
# List API Management services
33
services = list(client.api_management_service.list_by_subscription())
34
for service in services:
35
print(f"Service: {service.name}, Location: {service.location}")
36
37
# Get a specific API Management service
38
service = client.api_management_service.get(
39
resource_group_name="my-resource-group",
40
service_name="my-apim-service"
41
)
42
43
# List APIs in the service
44
apis = list(client.api.list_by_service(
45
resource_group_name="my-resource-group",
46
service_name="my-apim-service"
47
))
48
for api in apis:
49
print(f"API: {api.name}, Path: {api.path}")
50
```
51
52
## Architecture
53
54
The Azure API Management Client Library follows Azure SDK design principles:
55
56
- **Client**: `ApiManagementClient` serves as the main entry point providing access to all operation groups
57
- **Operations**: Specialized operation classes for different API Management resources (APIs, products, users, policies, etc.)
58
- **Models**: Data transfer objects representing Azure API Management resources and their properties
59
- **Authentication**: Integration with Azure Identity library for secure credential management
60
- **Long-Running Operations**: Support for async operations with polling and result retrieval
61
62
The library provides both synchronous and asynchronous clients, comprehensive error handling, automatic retries, logging integration, and follows Azure ARM (Azure Resource Manager) patterns for consistent resource management across Azure services.
63
64
## Capabilities
65
66
### Service Management
67
68
Core API Management service lifecycle operations including creating, updating, configuring, and monitoring API Management instances. Includes service-level settings, SKU management, network configuration, and backup/restore capabilities.
69
70
```python { .api }
71
class ApiManagementServiceOperations:
72
def get(self, resource_group_name: str, service_name: str, **kwargs) -> ApiManagementServiceResource: ...
73
def begin_create_or_update(self, resource_group_name: str, service_name: str, parameters: ApiManagementServiceResource, **kwargs) -> LROPoller[ApiManagementServiceResource]: ...
74
def begin_update(self, resource_group_name: str, service_name: str, parameters: ApiManagementServiceUpdateParameters, **kwargs) -> LROPoller[ApiManagementServiceResource]: ...
75
def begin_delete(self, resource_group_name: str, service_name: str, **kwargs) -> LROPoller[None]: ...
76
def list_by_subscription(self, **kwargs) -> ItemPaged[ApiManagementServiceResource]: ...
77
def list_by_resource_group(self, resource_group_name: str, **kwargs) -> ItemPaged[ApiManagementServiceResource]: ...
78
```
79
80
[Service Management](./service-management.md)
81
82
### API Management
83
84
Comprehensive API lifecycle management including API creation, versioning, revisions, operations, schemas, policies, and export/import capabilities. Supports REST, SOAP, GraphQL, and WebSocket APIs.
85
86
```python { .api }
87
class ApiOperations:
88
def get(self, resource_group_name: str, service_name: str, api_id: str, **kwargs) -> ApiContract: ...
89
def begin_create_or_update(self, resource_group_name: str, service_name: str, api_id: str, parameters: ApiCreateOrUpdateParameter, **kwargs) -> LROPoller[ApiContract]: ...
90
def begin_update(self, resource_group_name: str, service_name: str, api_id: str, parameters: ApiUpdateContract, **kwargs) -> LROPoller[ApiContract]: ...
91
def delete(self, resource_group_name: str, service_name: str, api_id: str, **kwargs) -> None: ...
92
def list_by_service(self, resource_group_name: str, service_name: str, **kwargs) -> ItemPaged[ApiContract]: ...
93
```
94
95
[API Management](./api-management.md)
96
97
### Additional Operations
98
99
The library provides extensive additional operations for comprehensive API Management functionality:
100
101
- **Product Management**: Product lifecycle, API associations, access policies, and subscription management
102
- **User and Group Management**: User accounts, group administration, permissions, and developer portal access
103
- **Gateway Management**: Self-hosted gateways, hybrid deployments, and gateway configuration
104
- **Authentication and Authorization**: Identity providers, OAuth servers, JWT validation, and access policies
105
- **Backend Configuration**: Backend services, load balancing, health monitoring, and service discovery
106
- **Monitoring and Analytics**: Diagnostics, logging, reporting, and integration with Azure Monitor
107
- **Developer Portal**: Portal configuration, customization, content management, and publishing
108
- **Workspace Management**: Multi-workspace organization, resource isolation, and cross-workspace sharing
109
- **Certificate Management**: SSL/TLS certificates, client certificates, and certificate authorities
110
- **Named Values**: Key-value pairs, secrets management, and configuration variables
111
- **Subscription Management**: API subscriptions, access keys, and usage quotas
112
- **Tag Management**: Resource tagging, organization, and metadata management
113
- **Content Management**: Documentation, email templates, and portal content
114
- **Network Configuration**: Virtual networks, private endpoints, and connectivity settings
115
116
These operations follow the same patterns as the core capabilities documented above, with comprehensive CRUD operations, entity tag support, and long-running operation handling where applicable.
117
118
### Policy Management
119
120
Comprehensive policy system for implementing cross-cutting concerns including authentication, rate limiting, transformation, caching, and routing. Supports policies at global, product, API, and operation levels.
121
122
```python { .api }
123
class PolicyOperations:
124
def get(self, resource_group_name: str, service_name: str, policy_id: str, **kwargs) -> PolicyContract: ...
125
def create_or_update(self, resource_group_name: str, service_name: str, policy_id: str, parameters: PolicyContract, **kwargs) -> PolicyContract: ...
126
def delete(self, resource_group_name: str, service_name: str, policy_id: str, **kwargs) -> None: ...
127
def list_by_service(self, resource_group_name: str, service_name: str, **kwargs) -> ItemPaged[PolicyContract]: ...
128
129
class PolicyFragmentOperations:
130
def get(self, resource_group_name: str, service_name: str, policy_fragment_id: str, **kwargs) -> PolicyFragmentContract: ...
131
def begin_create_or_update(self, resource_group_name: str, service_name: str, policy_fragment_id: str, parameters: PolicyFragmentContract, **kwargs) -> LROPoller[PolicyFragmentContract]: ...
132
def delete(self, resource_group_name: str, service_name: str, policy_fragment_id: str, **kwargs) -> None: ...
133
def list_by_service(self, resource_group_name: str, service_name: str, **kwargs) -> ItemPaged[PolicyFragmentContract]: ...
134
```
135
136
[Policy Management](./policy-management.md)
137
138
139
## Asynchronous Client
140
141
The library provides full async/await support through the `aio` module:
142
143
```python
144
from azure.mgmt.apimanagement.aio import ApiManagementClient
145
from azure.identity.aio import DefaultAzureCredential
146
147
async def manage_apis():
148
credential = DefaultAzureCredential()
149
async with ApiManagementClient(credential, "subscription-id") as client:
150
# Async operations
151
async for service in client.api_management_service.list_by_subscription():
152
print(f"Service: {service.name}")
153
```
154
155
## Error Handling
156
157
The library uses Azure Core exceptions for consistent error handling:
158
159
```python
160
from azure.core.exceptions import HttpResponseError, ResourceNotFoundError
161
162
try:
163
service = client.api_management_service.get("rg", "service-name")
164
except ResourceNotFoundError:
165
print("Service not found")
166
except HttpResponseError as e:
167
print(f"HTTP error: {e.status_code} - {e.message}")
168
```
169
170
## Types
171
172
All data models, enums, and type definitions are available through the models module:
173
174
```python
175
from azure.mgmt.apimanagement.models import (
176
ApiManagementServiceResource,
177
ApiContract,
178
ApiCreateOrUpdateParameter,
179
ProductContract,
180
UserContract,
181
GroupContract,
182
PolicyContract,
183
PolicyFragmentContract,
184
BackendContract,
185
OperationContract,
186
SchemaContract,
187
# ... and 470+ other model classes
188
)
189
190
# For long-running operations and paging
191
from azure.core.polling import LROPoller
192
from azure.core.paging import ItemPaged
193
```