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
Management operations for Azure Media Services accounts including account lifecycle, configuration, storage integration, and edge policies. These operations provide the foundational infrastructure management capabilities for media processing services.
List and retrieve media service accounts within resource groups and subscriptions.
def list(resource_group_name: str) -> Iterable[MediaService]:
"""
List all media services in a resource group.
Parameters:
- resource_group_name: Name of the resource group (str)
Returns:
Iterable of MediaService objects
"""
def get(resource_group_name: str, account_name: str) -> MediaService:
"""
Get a specific media service account.
Parameters:
- resource_group_name: Name of the resource group (str)
- account_name: Name of the media service account (str)
Returns:
MediaService object containing account details
"""
def list_by_subscription() -> Iterable[MediaService]:
"""
List all media services in the current subscription.
Returns:
Iterable of MediaService objects across all resource groups
"""Create new media service accounts and update existing account configurations with long-running operation support.
def begin_create_or_update(
resource_group_name: str,
account_name: str,
parameters: MediaService
) -> LROPoller[MediaService]:
"""
Create or update a media service account.
Parameters:
- resource_group_name: Name of the resource group (str)
- account_name: Name of the media service account (str)
- parameters: Media service configuration (MediaService)
Returns:
LROPoller for long-running operation tracking
"""
def begin_update(
resource_group_name: str,
account_name: str,
parameters: MediaService
) -> LROPoller[MediaService]:
"""
Update an existing media service account.
Parameters:
- resource_group_name: Name of the resource group (str)
- account_name: Name of the media service account (str)
- parameters: Updated media service configuration (MediaService)
Returns:
LROPoller for long-running operation tracking
"""Remove media service accounts and associated resources.
def delete(resource_group_name: str, account_name: str) -> None:
"""
Delete a media service account.
Parameters:
- resource_group_name: Name of the resource group (str)
- account_name: Name of the media service account (str)
Returns:
None
"""Synchronize storage account keys for media service accounts.
def sync_storage_keys(
resource_group_name: str,
account_name: str,
parameters: SyncStorageKeysInput
) -> None:
"""
Synchronize storage account keys with the media service.
Parameters:
- resource_group_name: Name of the resource group (str)
- account_name: Name of the media service account (str)
- parameters: Storage key synchronization parameters (SyncStorageKeysInput)
Returns:
None
"""Manage edge policies for content delivery network integration.
def list_edge_policies(
resource_group_name: str,
account_name: str,
parameters: ListEdgePoliciesInput
) -> EdgePolicies:
"""
List edge policies for the media service account.
Parameters:
- resource_group_name: Name of the resource group (str)
- account_name: Name of the media service account (str)
- parameters: Edge policy listing parameters (ListEdgePoliciesInput)
Returns:
EdgePolicies containing policy configurations
"""class MediaService:
"""Azure Media Services account resource."""
name: str
location: str
resource_group: str
tags: dict
storage_accounts: List[StorageAccount]
encryption: MediaServiceEncryption
key_delivery: KeyDelivery
public_network_access: str
provisioning_state: str
class StorageAccount:
"""Storage account configuration for media service."""
type: str # Primary or Secondary
id: str
identity: MediaServiceIdentity
class SyncStorageKeysInput:
"""Parameters for storage key synchronization."""
id: str
class ListEdgePoliciesInput:
"""Parameters for listing edge policies."""
device_id: str
class EdgePolicies:
"""Edge policies configuration."""
usage_data_collection_policy: EdgeUsageDataCollectionPolicyfrom azure.mgmt.media import AzureMediaServices
from azure.mgmt.media.models import MediaService, StorageAccount
from azure.identity import DefaultAzureCredential
client = AzureMediaServices(
credential=DefaultAzureCredential(),
subscription_id="your-subscription-id"
)
# Configure storage account
storage_account = StorageAccount(
type="Primary",
id="/subscriptions/sub-id/resourceGroups/rg/providers/Microsoft.Storage/storageAccounts/storage"
)
# Create media service
media_service = MediaService(
location="East US",
storage_accounts=[storage_account]
)
# Start creation (long-running operation)
operation = client.mediaservices.begin_create_or_update(
resource_group_name="my-resource-group",
account_name="my-media-service",
parameters=media_service
)
# Wait for completion
result = operation.result()
print(f"Media Service created: {result.name}")# List all media services in a resource group
media_services = client.mediaservices.list("my-resource-group")
for service in media_services:
print(f"Service: {service.name}")
print(f"Location: {service.location}")
print(f"Storage Accounts: {len(service.storage_accounts)}")
# Sync storage keys if needed
if service.storage_accounts:
storage_id = service.storage_accounts[0].id
sync_input = SyncStorageKeysInput(id=storage_id)
client.mediaservices.sync_storage_keys(
resource_group_name="my-resource-group",
account_name=service.name,
parameters=sync_input
)
print(f"Storage keys synchronized for {service.name}")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