0
# Azure Media Services Management Library
1
2
Microsoft Azure Media Services Client Library for Python - A comprehensive management library for Azure Media Services that provides programmatic access to media processing and streaming capabilities in Azure's cloud platform. This library enables developers to manage media assets, encoding transforms, live streaming events, streaming endpoints, content protection policies, and streaming locators.
3
4
**Important**: This package has been deprecated and will no longer be maintained after June 30, 2024. Azure Media Services is being retired. Please refer to the [Azure Media Services retirement guide](https://learn.microsoft.com/azure/media-services/latest/azure-media-services-retirement) for migration details.
5
6
## Package Information
7
8
- **Package Name**: azure-mgmt-media
9
- **Package Type**: pypi
10
- **Language**: Python
11
- **Installation**: `pip install azure-mgmt-media azure-identity`
12
- **Python Requirements**: >=3.7
13
- **Status**: Deprecated (no longer maintained after June 30, 2024)
14
15
## Core Imports
16
17
```python
18
from azure.mgmt.media import AzureMediaServices
19
from azure.identity import DefaultAzureCredential
20
```
21
22
## Basic Usage
23
24
```python
25
import os
26
from azure.identity import DefaultAzureCredential
27
from azure.mgmt.media import AzureMediaServices
28
29
# Set up authentication
30
credential = DefaultAzureCredential()
31
subscription_id = os.getenv("AZURE_SUBSCRIPTION_ID")
32
33
# Create the client
34
client = AzureMediaServices(
35
credential=credential,
36
subscription_id=subscription_id
37
)
38
39
# Example: List media services in a resource group
40
resource_group_name = "my-resource-group"
41
media_services = client.mediaservices.list(resource_group_name)
42
43
for service in media_services:
44
print(f"Media Service: {service.name}")
45
print(f"Location: {service.location}")
46
print(f"Resource Group: {service.resource_group}")
47
```
48
49
## Architecture
50
51
The Azure Media Services Management library is built around a main client class that provides access to 19 specialized operation groups, each managing a specific aspect of media services:
52
53
- **Core Resources**: Media Services accounts, assets, transforms, and jobs
54
- **Live Streaming**: Live events and live outputs for real-time streaming
55
- **Content Delivery**: Streaming endpoints, locators, and policies
56
- **Content Protection**: Content key policies and encryption configurations
57
- **Asset Management**: Asset filters, tracks, and container operations
58
- **Operations Management**: Long-running operation status and results
59
- **Network Security**: Private endpoints and private link resources
60
61
This design follows Azure Resource Manager (ARM) patterns and provides both synchronous and asynchronous operation support with comprehensive error handling and long-running operation (LRO) management.
62
63
## Capabilities
64
65
### Media Services Account Management
66
67
Manage Azure Media Services accounts including creation, configuration, storage key synchronization, and edge policies. Essential for setting up and maintaining the foundational media processing infrastructure.
68
69
```python { .api }
70
def list(resource_group_name: str) -> Iterable[MediaService]:
71
"""List media services in resource group."""
72
73
def get(resource_group_name: str, account_name: str) -> MediaService:
74
"""Get specific media service account."""
75
76
def begin_create_or_update(resource_group_name: str, account_name: str, parameters: MediaService) -> LROPoller[MediaService]:
77
"""Create or update media service account."""
78
79
def delete(resource_group_name: str, account_name: str) -> None:
80
"""Delete media service account."""
81
82
def sync_storage_keys(resource_group_name: str, account_name: str, parameters: SyncStorageKeysInput) -> None:
83
"""Synchronize storage account keys."""
84
```
85
86
[Media Services Account Management](./media-services-management.md)
87
88
### Asset Management
89
90
Manage media assets - the containers for audio and video files in Azure Storage. Includes asset creation, metadata management, container SAS URL generation, encryption key handling, and streaming locator associations.
91
92
```python { .api }
93
def list(resource_group_name: str, account_name: str) -> Iterable[Asset]:
94
"""List all assets in media service account."""
95
96
def get(resource_group_name: str, account_name: str, asset_name: str) -> Asset:
97
"""Get specific asset."""
98
99
def create_or_update(resource_group_name: str, account_name: str, asset_name: str, parameters: Asset) -> Asset:
100
"""Create or update asset."""
101
102
def list_container_sas(resource_group_name: str, account_name: str, asset_name: str, parameters: ListContainerSasInput) -> AssetContainerSas:
103
"""Get asset container SAS URLs for upload/download."""
104
105
def get_encryption_key(resource_group_name: str, account_name: str, asset_name: str) -> StorageEncryptedAssetDecryptionData:
106
"""Get asset encryption key information."""
107
```
108
109
[Asset Management](./asset-management.md)
110
111
### Encoding and Transforms
112
113
Manage encoding transforms (job templates) and processing jobs for media transcoding, analysis, and content preparation. Includes custom and built-in encoding presets, job monitoring, and error handling.
114
115
```python { .api }
116
def list(resource_group_name: str, account_name: str) -> Iterable[Transform]:
117
"""List encoding transforms."""
118
119
def create_or_update(resource_group_name: str, account_name: str, transform_name: str, parameters: Transform) -> Transform:
120
"""Create or update encoding transform."""
121
122
def create(resource_group_name: str, account_name: str, transform_name: str, job_name: str, parameters: Job) -> Job:
123
"""Create encoding job from transform."""
124
125
def cancel_job(resource_group_name: str, account_name: str, transform_name: str, job_name: str) -> None:
126
"""Cancel running encoding job."""
127
```
128
129
[Encoding and Transforms](./encoding-transforms.md)
130
131
### Live Streaming
132
133
Manage live streaming events and outputs for real-time content delivery. Includes live event lifecycle management, input configuration, preview settings, and output publishing with long-running operation support.
134
135
```python { .api }
136
def begin_create(resource_group_name: str, account_name: str, live_event_name: str, parameters: LiveEvent) -> LROPoller[LiveEvent]:
137
"""Create live streaming event."""
138
139
def begin_start(resource_group_name: str, account_name: str, live_event_name: str) -> LROPoller[None]:
140
"""Start live streaming event."""
141
142
def begin_stop(resource_group_name: str, account_name: str, live_event_name: str, parameters: LiveEventActionInput) -> LROPoller[None]:
143
"""Stop live streaming event."""
144
145
def begin_create(resource_group_name: str, account_name: str, live_event_name: str, live_output_name: str, parameters: LiveOutput) -> LROPoller[LiveOutput]:
146
"""Create live output for archiving."""
147
```
148
149
[Live Streaming](./live-streaming.md)
150
151
### Content Delivery and Streaming
152
153
Manage streaming endpoints, locators, and policies for content delivery to end users. Includes streaming endpoint scaling, content publishing, path generation, and multi-protocol streaming support.
154
155
```python { .api }
156
def begin_create(resource_group_name: str, account_name: str, streaming_endpoint_name: str, parameters: StreamingEndpoint) -> LROPoller[StreamingEndpoint]:
157
"""Create streaming endpoint."""
158
159
def begin_start(resource_group_name: str, account_name: str, streaming_endpoint_name: str) -> LROPoller[None]:
160
"""Start streaming endpoint."""
161
162
def create(resource_group_name: str, account_name: str, streaming_locator_name: str, parameters: StreamingLocator) -> StreamingLocator:
163
"""Create streaming locator for asset publishing."""
164
165
def list_paths(resource_group_name: str, account_name: str, streaming_locator_name: str) -> ListPathsResponse:
166
"""Get streaming URLs and paths."""
167
```
168
169
[Content Delivery and Streaming](./content-delivery-streaming.md)
170
171
### Content Protection
172
173
Manage content protection through content key policies, encryption configurations, and DRM integration. Supports PlayReady, Widevine, FairPlay, and AES encryption with token-based access control.
174
175
```python { .api }
176
def create_or_update(resource_group_name: str, account_name: str, content_key_policy_name: str, parameters: ContentKeyPolicy) -> ContentKeyPolicy:
177
"""Create or update content key policy."""
178
179
def get_policy_properties_with_secrets(resource_group_name: str, account_name: str, content_key_policy_name: str) -> ContentKeyPolicyProperties:
180
"""Get policy configuration with secrets."""
181
182
def list_content_keys(resource_group_name: str, account_name: str, streaming_locator_name: str) -> ListContentKeysResponse:
183
"""List content keys for streaming locator."""
184
```
185
186
[Content Protection](./content-protection.md)
187
188
### Media Filters
189
190
Manage account-level and asset-level filters for dynamic content filtering, including presentation time ranges, track filtering, and bitrate constraints for adaptive streaming scenarios.
191
192
```python { .api }
193
def create_or_update(resource_group_name: str, account_name: str, filter_name: str, parameters: AccountFilter) -> AccountFilter:
194
"""Create or update account filter."""
195
196
def create_or_update(resource_group_name: str, account_name: str, asset_name: str, filter_name: str, parameters: AssetFilter) -> AssetFilter:
197
"""Create or update asset filter."""
198
```
199
200
[Media Filters](./media-filters.md)
201
202
### Asset Tracks Management
203
204
Manage individual tracks within assets, including audio, video, and text tracks. Supports track metadata, track data updates, and long-running track operations.
205
206
```python { .api }
207
def begin_create_or_update(resource_group_name: str, account_name: str, asset_name: str, track_name: str, parameters: AssetTrack) -> LROPoller[AssetTrack]:
208
"""Create or update asset track."""
209
210
def begin_update_track_data(resource_group_name: str, account_name: str, asset_name: str, track_name: str) -> LROPoller[None]:
211
"""Update track data."""
212
```
213
214
[Asset Tracks Management](./asset-tracks.md)
215
216
### Operations and Monitoring
217
218
Monitor operation status and results for long-running operations, including media service operations, asset track operations, and streaming endpoint operations with comprehensive error reporting.
219
220
```python { .api }
221
def list() -> OperationCollection:
222
"""List all available API operations."""
223
224
def get(location_name: str, operation_id: str) -> MediaServiceOperationStatus:
225
"""Get media service operation status."""
226
227
def get(location_name: str, operation_id: str) -> Optional[MediaService]:
228
"""Get media service operation result."""
229
```
230
231
[Operations and Monitoring](./operations-monitoring.md)
232
233
### Network Security
234
235
Manage private endpoints and private link resources for secure network connectivity to media services, enabling access through private networks without exposure to the public internet.
236
237
```python { .api }
238
def create_or_update(resource_group_name: str, account_name: str, name: str, parameters: PrivateEndpointConnection) -> PrivateEndpointConnection:
239
"""Create or update private endpoint connection."""
240
241
def list(resource_group_name: str, account_name: str) -> PrivateLinkResourceListResult:
242
"""List available private link resources."""
243
```
244
245
[Network Security](./network-security.md)
246
247
### Resource Location Management
248
249
Manage Azure resource location validation and name availability checking for Media Services resources across Azure regions.
250
251
```python { .api }
252
def check_name_availability(location_name: str, parameters: CheckNameAvailabilityInput) -> EntityNameAvailabilityCheckOutput:
253
"""Check if a Media Services account name is available in a specific Azure region."""
254
```
255
256
[Resource Location Management](./location-management.md)
257
258
## Authentication and Configuration
259
260
```python { .api }
261
class AzureMediaServices:
262
"""Main client for Azure Media Services management operations."""
263
264
def __init__(
265
self,
266
credential: TokenCredential,
267
subscription_id: str,
268
base_url: str = "https://management.azure.com",
269
**kwargs: Any
270
) -> None:
271
"""
272
Initialize Azure Media Services client.
273
274
Parameters:
275
- credential: Azure authentication credential (TokenCredential)
276
- subscription_id: Azure subscription identifier (str)
277
- base_url: Service URL, defaults to Azure Resource Manager (str)
278
- polling_interval: Default polling interval for LRO operations (int)
279
"""
280
281
def close(self) -> None:
282
"""Clean up client resources."""
283
284
def __enter__(self) -> "AzureMediaServices":
285
"""Context manager entry."""
286
287
def __exit__(self, *exc_details) -> None:
288
"""Context manager exit."""
289
```
290
291
## Common Data Types
292
293
```python { .api }
294
class MediaService:
295
"""Azure Media Services account resource."""
296
297
class Asset:
298
"""Media asset container for audio/video files."""
299
300
class Transform:
301
"""Encoding transform template."""
302
303
class Job:
304
"""Encoding or analysis job instance."""
305
306
class LiveEvent:
307
"""Live streaming event resource."""
308
309
class LiveOutput:
310
"""Live stream output configuration."""
311
312
class StreamingEndpoint:
313
"""Streaming endpoint for content delivery."""
314
315
class StreamingLocator:
316
"""Asset streaming configuration."""
317
318
class StreamingPolicy:
319
"""Streaming access policy."""
320
321
class ContentKeyPolicy:
322
"""Content protection policy."""
323
324
class AccountFilter:
325
"""Account-level media filter."""
326
327
class AssetFilter:
328
"""Asset-level media filter."""
329
330
class AssetTrack:
331
"""Individual track within an asset."""
332
333
class CheckNameAvailabilityInput:
334
"""Input for checking Media Services account name availability."""
335
336
class EntityNameAvailabilityCheckOutput:
337
"""Output containing name availability check results."""
338
339
class ListContainerSasInput:
340
"""Input parameters for generating asset container SAS URLs."""
341
342
class AssetContainerSas:
343
"""Response containing asset container SAS URLs for upload/download."""
344
345
class SyncStorageKeysInput:
346
"""Input parameters for synchronizing storage account keys."""
347
348
class LiveEventActionInput:
349
"""Input parameters for live event lifecycle actions."""
350
351
class ListPathsResponse:
352
"""Response containing streaming URLs and paths."""
353
354
class ListContentKeysResponse:
355
"""Response containing content keys for streaming locator."""
356
357
class ListStreamingLocatorsResponse:
358
"""Response containing streaming locators associated with an asset."""
359
360
class StorageEncryptedAssetDecryptionData:
361
"""Asset decryption information for storage-encrypted assets."""
362
```
363
364
## Error Handling
365
366
The library raises standard Azure exceptions for error conditions:
367
368
- `ResourceNotFoundError` - Resource not found (404)
369
- `ResourceExistsError` - Resource already exists (409)
370
- `ClientAuthenticationError` - Authentication failure (401/403)
371
- `HttpResponseError` - General HTTP errors with detailed error information
372
373
All long-running operations return `LROPoller` objects that can be used to monitor operation progress and handle failures gracefully.