Registry / azure / azure-mgmt-media

azure-mgmt-media

JSON →
library10.2.1pypypi✓ verified 22d ago

The azure-mgmt-media library is the Microsoft Azure Media Services Client Library for Python. It provides classes and methods for programmatically managing Azure Media Services resources, such as Media Services accounts, assets, transforms, and jobs. The current version is 10.2.1. Like other Azure SDKs, it follows a regular release cadence with updates aligning with Azure service API versions and general SDK improvements.

pip install azure-mgmt-media
INSTALL
IMPORT
SIG · AZURE-MGMT-MEDIA
A
azure-mgmt-media
azurepythonv10.2.1
Install
3.4s avg
Import
Disk
28MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v10.2.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 29.3MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.4s · import 0.000s · 30MB
28MB installed
● package 28MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

MediaServicesClient
from azure.mgmt.media import MediaServicesClient
from azure.mgmt.media import MediaServicesClient

This quickstart demonstrates how to authenticate with Azure using `DefaultAzureCredential` and interact with Azure Media Services to list existing accounts or create a new one. It assumes you have Azure credentials configured (e.g., via environment variables, Azure CLI, or Visual Studio Code) and a resource group ready. Note that creating a Media Services account requires a linked storage account, which must be created separately and referenced by its full resource ID.

import os from azure.identity import DefaultAzureCredential from azure.mgmt.media import MediaServicesClient # Set your Azure subscription ID and resource group name in environment variables # AZURE_SUBSCRIPTION_ID, AZURE_RESOURCE_GROUP # Also ensure AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, AZURE_TENANT_ID are set for DefaultAzureCredential subscription_id = os.environ.get('AZURE_SUBSCRIPTION_ID', 'YOUR_SUBSCRIPTION_ID') resource_group_name = os.environ.get('AZURE_RESOURCE_GROUP', 'YOUR_RESOURCE_GROUP_NAME') media_account_name = os.environ.get('AZURE_MEDIA_ACCOUNT_NAME', 'mytestmediaaccount') location = os.environ.get('AZURE_LOCATION', 'westus2') # Or your preferred Azure region def main(): # Authenticate to Azure using DefaultAzureCredential # This credential will attempt to authenticate via various mechanisms: # environment variables, managed identity, VS Code, Azure CLI, etc. credential = DefaultAzureCredential() # Create a Media Services client media_client = MediaServicesClient(credential, subscription_id) print(f"Created MediaServicesClient for subscription: {subscription_id}") # Check if Media Services account exists try: account = media_client.mediaservices.get(resource_group_name, media_account_name) print(f"Media Services account '{media_account_name}' already exists.") except Exception as e: print(f"Media Services account '{media_account_name}' does not exist or error: {e}. Creating...") # Create a new Media Services account (requires a storage account to be linked) # For a real scenario, you would first create a storage account and link it. # This example assumes a default storage account is handled or will fail if not configured. # In a real application, you'd define primary_storage_account: StorageAccount # and related properties. media_account_properties = { "location": location, "storage_accounts": [ { "id": f"/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.Storage/storageAccounts/youruniquestorageaccountname", "type": "Primary" } ] } # NOTE: 'youruniquestorageaccountname' must be replaced with an actual, globally unique storage account name # that exists in the same resource group and subscription. print(f"Creating Media Services account '{media_account_name}' in '{resource_group_name}'...") media_client.mediaservices.begin_create_or_update( resource_group_name, media_account_name, media_account_properties ).result() print(f"Media Services account '{media_account_name}' created successfully.") # List all Media Services accounts in the resource group print(f"Listing Media Services accounts in resource group '{resource_group_name}':") for media_account in media_client.mediaservices.list_by_resource_group(resource_group_name): print(f"- {media_account.name} (Location: {media_account.location})") if __name__ == '__main__': # Replace 'youruniquestorageaccountname' with an actual, globally unique storage account name # that exists in your subscription and resource group. # This quickstart is illustrative and requires a pre-existing storage account. # For a fully runnable example, ensure the storage account is created first. # os.environ['AZURE_STORAGE_ACCOUNT_ID'] = "..." main()
Debug
Known issues
gotchaAzure Management SDKs, including `azure-mgmt-media`, require proper authentication and authorization. Common issues include insufficient permissions for the authenticated identity (e.g., Service Principal, Managed Identity) or incorrect Azure AD application configuration. Ensure your identity has 'Contributor' or 'Media Services Contributor' role on the relevant resource group or subscription.
fix
Verify IAM roles and permissions in the Azure portal for the identity used. Ensure `DefaultAzureCredential` can successfully authenticate and that environment variables (AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, AZURE_TENANT_ID for Service Principals) are correctly set.
affects: All versions
gotchaWhen creating an Azure Media Services account, it *must* be linked to an existing Azure Storage account. If the specified storage account does not exist, is in a different region, or is not accessible by the identity creating the Media Services account, the creation will fail. Ensure the storage account name is globally unique and the full resource ID is correct.
fix
Before creating a Media Services account, create a General-purpose v2 storage account in the same region and resource group. Provide its full resource ID in the `storage_accounts` property during Media Services account creation. E.g., `/subscriptions/{subId}/resourceGroups/{rgName}/providers/Microsoft.Storage/storageAccounts/{storageAccountName}`.
affects: All versions
breakingThe Azure SDKs for Python undergo significant changes between major versions, often aligning with new Azure REST API versions. While specific breaking changes from v9 to v10 for `azure-mgmt-media` might vary, general patterns include changes in class names, method signatures (e.g., parameters), and the structure of returned objects. Always consult the official migration guide for the specific service.
fix
Refer to the official Azure SDK for Python migration guides for `azure-mgmt-media` (if available) or the changelog for specific API changes. Update code to use new class names, parameter order, or object access patterns.
affects: Potentially v9.x to v10.x
Upgrade
Version history
10.2.1latest on PyPI · released Jun 3, 2025
Audit
Dependencies
azure-corerequiredCore utilities for Azure SDK client libraries.
azure-identityrequiredProvides Azure Active Directory authentication support.
Agent activity
26 hits · last 30 days
node
24
OpenAI (training)
1
Resources