page_type | languages | products | name | description | urlFragment | lastModified | |||
---|---|---|---|---|---|---|---|---|---|
sample |
|
|
Azure Media Services v3 Python Samples |
This repository contains samples showing how to use Azure Media Services v3 API using Python |
media-services-v3-python |
3/1/2023 |
The samples in this repo are part of Azure Media Services. Use this set of samples to get started with the Azure Media Service v3 API and Python client SDK.
NOTE Owned and maintained by Microsoft. Please do not push changes directly to this repo. Please fork the repo and set it as upstream and your own fork as origin. See the CONTRIBUTING.md file for more details.
- If you don't have an Azure subscription, create a free account before you begin.
- Create a resource group to use with these samples.
- Install Python 3.x
For every sample, we recommend that you always create and activate a virtual environment using the following steps:
- Open the sample folder in VSCode or other editor
- Create the virtual environment
# py -3 uses the global python interpreter. You can also use python -m venv .venv.
py -3 -m venv .venv
This command runs the Python venv module and creates a virtual environment in a folder named .venv.
- Activate the virtual environment:
.venv\scripts\activate
A virtual environment is a folder within a project that isolates a copy of a specific Python interpreter. Once you activate that environment (which Visual Studio Code does automatically), running pip install installs a library into that environment only. When you then run your Python code, it runs in the environment's exact context with specific versions of every library. And when you run pip freeze, you get the exact list of the those libraries. (In many of the samples, you create a requirements.txt file for the libraries you need, then use pip install -r requirements.txt. A requirements file is generally needed when you deploy code to Azure.)
Set up and configure your local Python dev environment for Azure
Install the azure-identity library for Python. This module is needed for Azure Active Directory authentication. See the details at Azure Identity client library for Python
pip install azure-identity
Install the Python SDK for Azure Media Services
The Pypi page for the Media Services Python SDK with latest version details is located at - azure-mgmt-media
pip install azure-mgmt-media
Install the Azure Storage SDK for Python
pip install azure-storage-blob
pip install azure-mgmt-storage
You can optionally install ALL of the requirements for a given samples by using the "requirements.txt" file in the samples folder
pip install -r requirements.txt
You can also use pip to uninstall libraries and install specific versions, including preview versions. For more information, see How to install Azure library packages for Python.
Copy the contents from the sample.env file that is in your forked repo in the root folder. Then, create your own .env file by clicking on Add file -> Create new file. Name the file .env and fill in the variables.
Do not allow this .env file to be checked into your fork of the GitHub repository! This is disallowed in the .gitignore file, but be extra careful not to allow the credentials to leak into your source control for this file.
All samples will load the root ".env" file first, and some of the samples add additional .env variables needed for the samples to work inside each sample folder. Make sure to check each sample for additional environment settings that are required.
- See the Azure Media Services management API.
- Learn how to use the Storage APIs with Python
- Learn more about the Azure Identity client library for Python
- Learn more about Azure Media Services v3.
- Learn about the Azure Python SDKs
- Learn more about usage patterns for Azure Python SDKs
- Find more Azure Python SDKs in the Azure Python SDK index
- Azure Storage Blob Python SDK reference