Update a streaming endpoint with Python
The functions in the Python code snippets assume that you have:
- Imported the necessary modules. You may not need all of the modules shown here. If the code below doesn't use the module, you can omit it.
- Created and edited an .env file that contains your authentication values. You can get a sample.env file from the Media Services Python samples.
- Read and instantiated environment variables by using load_env() as below. Depending on what you are doing, you may or may not need some of the variables.
- Created a Media Services client as below.
from dotenv import load_dotenv
from azure.identity import DefaultAzureCredential
from azure.mgmt.media import AzureMediaServices
from azure.mgmt.media.models import (StreamingEndpoint, StreamingEntityScaleUnit)
import os
# Get environment variables
load_dotenv()
subscription_id = os.getenv("SUBSCRIPTIONID")
account_name=os.getenv("ACCOUNTNAME")
resource_group_name=os.getenv("RESOURCEGROUP")
client_id = os.getenv("AZURE_CLIENT_ID")
storage_account_name=os.getenv("STORAGEACCOUNTNAME")
# Create the Media Services client and authenticate using the DefaultAzureCredential
default_credential = DefaultAzureCredential()
client = AzureMediaServices(default_credential, subscription_id)
# Get the media services account.
media_account = client.mediaservices.get(resource_group_name, account_name)
# Update the properties of a streaming endpoint.
# For this sample, you are updating the CDN profile to Premium Verizon
streaming_endpoint = StreamingEndpoint(
location=media_account.location,
cdn_profile="AzureMediaStreamingPlatformCdnProfile-PremiumVerizon",
cdn_provider="PremiumVerizon"
)
# From SDK:
# begin_update(resource_group_name: str, account_name: str, streaming_endpoint_name: str, parameters: azure.mgmt.media.models._models_py3.StreamingEndpoint, **kwargs: Any) -> azure.core.polling._poller.LROPoller[azure.mgmt.media.models._models_py3.StreamingEndpoint]
def begin_update_streaming_endpoint(resource_group_name, account_name, streaming_endpoint_name, parameters):
client.streaming_endpoints.begin_update(resource_group_name, account_name, streaming_endpoint_name, parameters)
begin_update_streaming_endpoint(resource_group_name, account_name, streaming_endpoint_name, parameters=streaming_endpoint)