How to Build a Custom Azure ML Environment¶
This guide shows how to create and register an Azure ML environment that contains your project's dependencies, so that remote pipeline steps have everything they need.
Prerequisites¶
- The Kedro AzureML Pipeline plugin installed and configured (see Getting Started)
- The Azure CLI with the
mlextension (az extension add -n ml)
Create a Dockerfile¶
Create a Dockerfile in your project root (or a docker/ subdirectory):
FROM mcr.microsoft.com/azureml/openmpi4.1.0-ubuntu22.04:latest
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
If you use uv, export your requirements first:
Use a conda specification instead¶
If you prefer conda over pip, create an environment.yml:
name: my-kedro-env
channels:
- defaults
- conda-forge
dependencies:
- python=3.11
- pip
- pip:
- kedro>=1.0.0
- kedro-azureml-pipeline
- pandas
# ... your other dependencies
Register the environment in Azure ML¶
After registration, verify the environment:
az ml environment show --name my-kedro-env --version latest \
--workspace-name <workspace> --resource-group <rg>
Reference the environment in azureml.yml¶
Use @latest to always pick the newest version, or pin a specific version with :3 (e.g. my-kedro-env:3).
Keep local and remote dependencies in sync¶
A common pain point is packages that work locally but are missing in the Azure ML environment. To avoid this:
-
Generate
requirements.txtfrom your lock file before building: -
Rebuild and re-register the environment whenever dependencies change.
-
Test the environment by running a quick job:
Check the step logs in Azure ML Studio for import errors.
See also¶
- Configuration reference for the
execution.environmentfield - Azure ML environments documentation for full environment management options