Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This section assumes you have knowledge of Docker and Azure Machine Learning environments.
Step 1: Prepare the Docker context
Create image_build folder
In your local environment, create a folder that contains the following files. The folder structure should look like this:
|--image_build
| |--requirements.txt
| |--Dockerfile
| |--environment.yaml
Define your required packages in requirements.txt
Optional: Add packages in private PyPI repository.
Use the following command to download your packages to local: pip wheel <package_name> --index-url=<private pypi> --wheel-dir <local path to save packages>
Open the requirements.txt file and add your extra packages and their specific versions. For example:
###### Requirements with Version Specifiers ######
requests == 2.32.3 # Version Matching. Must be version 2.32.3
numpy >= 1.26.0 # Minimum version 1.26.0
coverage != 3.5 # Version Exclusion. Anything except version 3.5
pillow ~= 11.0 # Compatible release. Same as >= 11.0, == 11.*
<path_to_local_package> # reference to local pip wheel package
For more information about structuring the requirements.txt file, see Requirements file format in the pip documentation.
Define the Dockerfile
Create a Dockerfile and add the following content, then save the file:
FROM <Base_image>
COPY ./* ./
RUN pip install -r requirements.txt
Note
Build this Docker image from the prompt flow base image mcr.microsoft.com/azureml/promptflow/promptflow-runtime:<newest_version>. If possible, use the latest version of the base image.
Step 2: Create custom Azure Machine Learning environment
Define your environment in environment.yaml
On your local computer, use the CLI (v2) to create a customized environment based on your Docker image.
Note
- Make sure to meet the prerequisites for creating environment.
- Ensure you have connected to your workspace.
az login # if not already authenticated
az account set --subscription <subscription ID>
az configure --defaults workspace=<Azure Machine Learning workspace name> group=<resource group>
Open the environment.yaml file and add the following content. Replace the <environment_name> placeholder with your desired environment name.
$schema: https://azuremlschemas.azureedge.net/latest/environment.schema.json
name: <environment_name>
build:
path: .
Create an environment
cd image_build
az ml environment create -f environment.yaml --subscription <sub-id> -g <resource-group> -w <workspace>
Note
Building the environment image might take several minutes.
Go to your workspace UI page, then go to the environment page, and locate the custom environment you created.
You can also find the image in the environment detail page and use it as base image for compute session of prompt flow. This image is also used to build environment for flow deployment from UI. To learn more, see how to specify base image in compute session.
To learn more about environment CLI, see Manage environments.