Microsoft Azure Media Services Client Library for Python - A management library for Azure Media Services that provides programmatic access to media processing and streaming capabilities in the cloud.
83
Quality
Pending
Does it follow best practices?
Impact
83%
1.09xAverage score across 10 eval scenarios
Comprehensive monitoring and status tracking for long-running operations including media service operations, asset track operations, and streaming endpoint operations with detailed error reporting and operation result retrieval.
Discover available API operations and capabilities within the Media Services management plane.
def list() -> OperationCollection:
"""
List all available API operations in Azure Media Services.
Returns:
OperationCollection containing all available management operations
"""Monitor long-running media service account operations with status tracking and result retrieval.
def get(location_name: str, operation_id: str) -> MediaServiceOperationStatus:
"""
Get the status of a media service operation.
Parameters:
- location_name: Azure region name where operation is running (str)
- operation_id: Identifier of the operation to monitor (str)
Returns:
MediaServiceOperationStatus with current operation state and progress
"""
def get(location_name: str, operation_id: str) -> Optional[MediaService]:
"""
Get the result of a completed media service operation.
Parameters:
- location_name: Azure region name where operation ran (str)
- operation_id: Identifier of the completed operation (str)
Returns:
MediaService object if operation completed successfully, None otherwise
"""Monitor long-running asset track operations with specialized status tracking.
def get(
location_name: str,
account_name: str,
operation_id: str
) -> AssetTrackOperationStatus:
"""
Get the status of an asset track operation.
Parameters:
- location_name: Azure region name where operation is running (str)
- account_name: Name of the media service account (str)
- operation_id: Identifier of the track operation to monitor (str)
Returns:
AssetTrackOperationStatus with current operation state and details
"""
def get(
location_name: str,
account_name: str,
operation_id: str
) -> Optional[AssetTrack]:
"""
Get the result of a completed asset track operation.
Parameters:
- location_name: Azure region name where operation ran (str)
- account_name: Name of the media service account (str)
- operation_id: Identifier of the completed operation (str)
Returns:
AssetTrack object if operation completed successfully, None otherwise
"""Retrieve results from asynchronous operations with comprehensive status information.
def async_operation(
resource_group_name: str,
account_name: str,
operation_id: str
) -> AsyncOperationResult:
"""
Get the result of an asynchronous operation.
Parameters:
- resource_group_name: Name of the resource group (str)
- account_name: Name of the media service account (str)
- operation_id: Identifier of the async operation (str)
Returns:
AsyncOperationResult with operation status and result data
"""Check resource name availability in specific Azure regions.
def check_name_availability(
location_name: str,
parameters: CheckNameAvailabilityInput
) -> EntityNameAvailabilityCheckOutput:
"""
Check if a resource name is available in the specified location.
Parameters:
- location_name: Azure region name to check (str)
- parameters: Name availability check parameters (CheckNameAvailabilityInput)
Returns:
EntityNameAvailabilityCheckOutput with availability status and reason
"""class OperationCollection:
"""Collection of available API operations."""
value: List[Operation]
class Operation:
"""Individual API operation definition."""
name: str
display: OperationDisplay
origin: str
is_data_action: bool
action_type: str
class OperationDisplay:
"""Display information for an API operation."""
provider: str
resource: str
operation: str
description: str
class MediaServiceOperationStatus:
"""Status of a media service operation."""
name: str
id: str
start_time: str
end_time: str
status: str # AsyncOperationStatus enum
error: dict
class AssetTrackOperationStatus:
"""Status of an asset track operation."""
name: str
id: str
start_time: str
end_time: str
status: str # AsyncOperationStatus enum
error: dict
class AsyncOperationResult:
"""Result of an asynchronous operation."""
name: str
status: str # AsyncOperationStatus enum
properties: dict
error: dict
class CheckNameAvailabilityInput:
"""Parameters for checking name availability."""
name: str
type: str
class EntityNameAvailabilityCheckOutput:
"""Result of name availability check."""
name_available: bool
reason: str # NameUnavailabilityReason enum
message: strfrom azure.mgmt.media import AzureMediaServices
from azure.identity import DefaultAzureCredential
import time
client = AzureMediaServices(
credential=DefaultAzureCredential(),
subscription_id="your-subscription-id"
)
# Start a long-running operation (e.g., create media service)
operation = client.mediaservices.begin_create_or_update(
resource_group_name="my-resource-group",
account_name="my-media-service",
parameters=media_service_config
)
# Get operation ID from the polling URL
operation_id = operation.id.split('/')[-1]
location = "eastus"
# Monitor operation status
while True:
status = client.media_services_operation_statuses.get(
location_name=location,
operation_id=operation_id
)
print(f"Operation status: {status.status}")
print(f"Start time: {status.start_time}")
if status.status == "Succeeded":
print("Operation completed successfully")
# Get the result
result = client.media_services_operation_results.get(
location_name=location,
operation_id=operation_id
)
if result:
print(f"Created media service: {result.name}")
break
elif status.status == "Failed":
print("Operation failed")
if status.error:
print(f"Error: {status.error}")
break
elif status.status == "InProgress":
print("Operation still in progress...")
time.sleep(10) # Wait 10 seconds before checking again
else:
print(f"Unknown status: {status.status}")
breakfrom azure.mgmt.media.models import CheckNameAvailabilityInput
# Check if media service name is available
name_check = CheckNameAvailabilityInput(
name="my-new-media-service",
type="Microsoft.Media/mediaservices"
)
availability_result = client.locations.check_name_availability(
location_name="eastus",
parameters=name_check
)
if availability_result.name_available:
print("Name is available")
else:
print(f"Name not available: {availability_result.reason}")
print(f"Message: {availability_result.message}")# Discover all available operations
operations = client.operations.list()
print("Available Azure Media Services operations:")
for operation in operations.value:
print(f"Name: {operation.name}")
print(f"Description: {operation.display.description}")
print(f"Resource: {operation.display.resource}")
print(f"Operation: {operation.display.operation}")
print()# Example: Create asset track and monitor the operation
track_operation = client.tracks.begin_create_or_update(
resource_group_name="my-resource-group",
account_name="my-media-service",
asset_name="my-asset",
track_name="subtitle-track",
parameters=track_config
)
# Extract operation details for monitoring
operation_id = track_operation.id.split('/')[-1]
location = "eastus"
account_name = "my-media-service"
# Monitor track operation
while True:
track_status = client.operation_statuses.get(
location_name=location,
account_name=account_name,
operation_id=operation_id
)
print(f"Track operation status: {track_status.status}")
if track_status.status == "Succeeded":
# Get the completed track
track_result = client.operation_results.get(
location_name=location,
account_name=account_name,
operation_id=operation_id
)
if track_result:
print(f"Track created: {track_result.name}")
break
elif track_status.status == "Failed":
print("Track operation failed")
if track_status.error:
print(f"Error: {track_status.error}")
break
time.sleep(5)Install with Tessl CLI
npx tessl i tessl/pypi-azure-mgmt-mediadocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10