Hello Ben !
Thank you for posting on Microsoft Learn.
You're right in AzureML), when using the Python SDK, you can directly set environment_variables
. But when you're defining components using YAML, it's a bit different.
You can define environment variables inside the environment section of your YAML component definition using the environment_variables
field.
$schema: https://azuremlschemas.azureedge.net/latest/commandComponent.schema.json
name: my_component
version: 1
type: command
inputs:
input_path:
type: uri_file
outputs:
output_path:
type: uri_folder
environment:
docker:
image: mcr.microsoft.com/azureml/base:latest
environment_variables:
MY_ENV_VAR_1: "hello"
MY_ENV_VAR_2: "world"
code: ./src
command: >
python main.py --input_path ${{inputs.input_path}} --output_path ${{outputs.output_path}}
If you're using a registered AzureML environment, you can define the environment variables in the environment YAML file when registering the environment.
name: my-env
version: 1
image: mcr.microsoft.com/azureml/base:latest
environment_variables:
MY_ENV_VAR_1: "hello"
MY_ENV_VAR_2: "world"
Then in your component YAML, just reference this environment:
environment: azureml:my-env:1