Search code examples
azureazure-pipelinesazure-climlops

Using Azure CLI v2 ML-extension in DevOps pipeline ("az" command)


I am trying to install "ml" extension for Azure CLI (az extension add -n ml -y --debug) in an Azure DevOps pipeline and getting an error because the extension is incompatible with that az version included into the "mcr.microsoft.com/mlops/python:latest" image (that is used by the pipeline runner):

Skipping 'ml-2.0.0a1-py3-none-any.whl' as not compatible with this version of the CLI.

So I apparently need to update the az command, but how that can be done in the pipeline code? "az upgrade" did not work:

az: 'upgrade' is not in the 'az' command group

Or alternatively, is there an mlops image that would have the new version of az command already included?


Solution

  • As @misha130 suggested, changing the default container image mcr.microsoft.com/mlops:latest defined in the Azure DevOps pipeline into another one having a more recent Azure CLI (az) solved the problem:

    resources:
      containers:
      - container: my-mlops
        image: mcr.microsoft.com/azure-dev-cli-apps:latest
    

    However, that image did not have azureml Python components pre-installed, so I also needed to add these installation commands into the pipeline:

      pip3 install azureml
      pip3 install azureml-core
      pip3 install azureml-pipeline
    

    After that, I was able to run az ml commands (after az extension add -n ml -y) and also run python3 code with azureml imports from my Azure DevOps pipeline.