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 network security capabilities through private endpoints and private link resources for secure connectivity to media services. Enables access through private networks without exposure to the public internet, supporting Azure virtual network integration and secure media workflows.
Manage private endpoint connections that provide secure, private connectivity to media services from virtual networks.
def list(
resource_group_name: str,
account_name: str
) -> PrivateEndpointConnectionListResult:
"""
List all private endpoint connections for a media service account.
Parameters:
- resource_group_name: Name of the resource group (str)
- account_name: Name of the media service account (str)
Returns:
PrivateEndpointConnectionListResult containing all private endpoint connections
"""
def get(
resource_group_name: str,
account_name: str,
name: str
) -> PrivateEndpointConnection:
"""
Get a specific private endpoint connection with complete configuration.
Parameters:
- resource_group_name: Name of the resource group (str)
- account_name: Name of the media service account (str)
- name: Name of the private endpoint connection (str)
Returns:
PrivateEndpointConnection object with connection details and status
"""
def create_or_update(
resource_group_name: str,
account_name: str,
name: str,
parameters: PrivateEndpointConnection
) -> PrivateEndpointConnection:
"""
Create or update a private endpoint connection.
Parameters:
- resource_group_name: Name of the resource group (str)
- account_name: Name of the media service account (str)
- name: Name for the private endpoint connection (str)
- parameters: Private endpoint connection configuration (PrivateEndpointConnection)
Returns:
Created or updated PrivateEndpointConnection object
"""
def delete(resource_group_name: str, account_name: str, name: str) -> None:
"""
Delete a private endpoint connection.
Parameters:
- resource_group_name: Name of the resource group (str)
- account_name: Name of the media service account (str)
- name: Name of the private endpoint connection (str)
Returns:
None
"""Manage private link resources that define the sub-resources available for private endpoint connections.
def list(
resource_group_name: str,
account_name: str
) -> PrivateLinkResourceListResult:
"""
List all private link resources for a media service account.
Parameters:
- resource_group_name: Name of the resource group (str)
- account_name: Name of the media service account (str)
Returns:
PrivateLinkResourceListResult containing available private link resources
"""
def get(
resource_group_name: str,
account_name: str,
name: str
) -> PrivateLinkResource:
"""
Get a specific private link resource with configuration details.
Parameters:
- resource_group_name: Name of the resource group (str)
- account_name: Name of the media service account (str)
- name: Name of the private link resource (str)
Returns:
PrivateLinkResource object with resource details and supported sub-resources
"""class PrivateEndpointConnection:
"""Private endpoint connection configuration."""
name: str
id: str
type: str
private_endpoint: PrivateEndpoint
private_link_service_connection_state: PrivateLinkServiceConnectionState
provisioning_state: str # PrivateEndpointConnectionProvisioningState enum
class PrivateEndpoint:
"""Private endpoint reference."""
id: str
class PrivateLinkServiceConnectionState:
"""Connection state for private link service."""
status: str # PrivateEndpointServiceConnectionStatus enum (Pending, Approved, Rejected)
description: str
actions_required: str
class PrivateEndpointConnectionListResult:
"""List of private endpoint connections."""
value: List[PrivateEndpointConnection]
class PrivateLinkResource:
"""Private link resource definition."""
name: str
id: str
type: str
group_id: str
required_members: List[str]
required_zone_names: List[str]
class PrivateLinkResourceListResult:
"""List of private link resources."""
value: List[PrivateLinkResource]from azure.mgmt.media import AzureMediaServices
from azure.identity import DefaultAzureCredential
client = AzureMediaServices(
credential=DefaultAzureCredential(),
subscription_id="your-subscription-id"
)
# List available private link resources
private_link_resources = client.private_link_resources.list(
resource_group_name="my-resource-group",
account_name="my-media-service"
)
print("Available private link resources:")
for resource in private_link_resources.value:
print(f"Name: {resource.name}")
print(f"Group ID: {resource.group_id}")
print(f"Required members: {', '.join(resource.required_members)}")
if resource.required_zone_names:
print(f"Required DNS zones: {', '.join(resource.required_zone_names)}")
print()from azure.mgmt.media.models import (
PrivateEndpointConnection, PrivateLinkServiceConnectionState,
PrivateEndpointServiceConnectionStatus
)
# List existing private endpoint connections
connections = client.private_endpoint_connections.list(
resource_group_name="my-resource-group",
account_name="my-media-service"
)
print("Existing private endpoint connections:")
for connection in connections.value:
print(f"Name: {connection.name}")
print(f"Status: {connection.private_link_service_connection_state.status}")
print(f"Description: {connection.private_link_service_connection_state.description}")
print(f"Provisioning state: {connection.provisioning_state}")
print()
# Approve a pending private endpoint connection
if connections.value:
connection = connections.value[0]
if connection.private_link_service_connection_state.status == "Pending":
# Update connection state to approved
connection.private_link_service_connection_state = PrivateLinkServiceConnectionState(
status=PrivateEndpointServiceConnectionStatus.APPROVED,
description="Connection approved for secure media access"
)
updated_connection = client.private_endpoint_connections.create_or_update(
resource_group_name="my-resource-group",
account_name="my-media-service",
name=connection.name,
parameters=connection
)
print(f"Connection approved: {updated_connection.name}")Since private endpoint creation typically happens from the client side (virtual network), here's an example of the configuration that would be used:
# This would typically be done via ARM template or Azure CLI
# Here's the conceptual configuration for reference
private_endpoint_config = {
"type": "Microsoft.Network/privateEndpoints",
"name": "media-service-private-endpoint",
"location": "East US",
"properties": {
"subnet": {
"id": "/subscriptions/sub-id/resourceGroups/network-rg/providers/Microsoft.Network/virtualNetworks/my-vnet/subnets/media-subnet"
},
"privateLinkServiceConnections": [
{
"name": "media-service-connection",
"properties": {
"privateLinkServiceId": "/subscriptions/sub-id/resourceGroups/my-resource-group/providers/Microsoft.Media/mediaservices/my-media-service",
"groupIds": ["keydelivery"] # or "streamingendpoint"
}
}
]
}
}
print("Private endpoint would be created with this configuration in the virtual network")
print("The media service will then show the connection as pending for approval")import time
def monitor_private_endpoint_connection(
client,
resource_group_name: str,
account_name: str,
connection_name: str
):
"""Monitor private endpoint connection status."""
while True:
connection = client.private_endpoint_connections.get(
resource_group_name=resource_group_name,
account_name=account_name,
name=connection_name
)
status = connection.private_link_service_connection_state.status
provisioning_state = connection.provisioning_state
print(f"Connection status: {status}")
print(f"Provisioning state: {provisioning_state}")
if status == "Approved" and provisioning_state == "Succeeded":
print("Private endpoint connection is ready")
break
elif status == "Rejected":
print("Private endpoint connection was rejected")
break
elif provisioning_state == "Failed":
print("Private endpoint connection provisioning failed")
break
time.sleep(10)
# Example usage
# monitor_private_endpoint_connection(
# client,
# "my-resource-group",
# "my-media-service",
# "media-private-endpoint-connection"
# )# Example DNS configuration for private endpoint resolution
dns_config_example = {
"private_dns_zone": "privatelink.media.azure.net",
"dns_records": [
{
"name": "my-media-service",
"type": "A",
"value": "10.0.1.4" # Private IP of the private endpoint
}
],
"virtual_network_links": [
{
"vnet_id": "/subscriptions/sub-id/resourceGroups/network-rg/providers/Microsoft.Network/virtualNetworks/my-vnet",
"registration_enabled": False
}
]
}
print("DNS configuration for private endpoint resolution:")
print(f"Private DNS Zone: {dns_config_example['private_dns_zone']}")
print("This would typically be configured via Azure Private DNS zones")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