For a windows based build agent use call activate <env_name>:
- script: |
conda install --yes --quiet --name myEnvironment ruff
call activate myEnvironment
ruff format .
displayName: Activate environment and run ruff
It's the equivalent to mentioned source activate myEnvironment for unix.