Update an account filter 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 (
AccountFilter,
FirstQuality,
AssetFilter
)
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)
# Update the properties of the account filter.
# For this sample, you are updating the first quality bitrate for the account filter.
first_quality = FirstQuality(bitrate=28000)
account_filter = AccountFilter(first_quality=first_quality)
# From SDK:
# update(resource_group_name: str, account_name: str, filter_name: str, parameters: azure.mgmt.media.models._models_py3.AccountFilter, **kwargs: Any) -> azure.mgmt.media.models._models_py3.AccountFilter
def update_account_filter(resource_group_name, account_name, filter_name, parameters):
client.account_filters.update(resource_group_name, account_name, filter_name, parameters)
update_account_filter(resource_group_name, account_name, filter_name, parameters=account_filter)