Search code examples
azureazure-devopsazure-machine-learning-service

How to trigger an AzureML Pipeline from Azure DevOps?


If we have an AzureML Pipeline published, how can we trigger it from Azure DevOps without using Python Script Step or Azure CLI Step?

The AzureML Steps supported natively in Azure DevOps include Model_Deployment and Model_Profiling.

Is there any step in Azure DevOps which can be used to directly trigger a published Azure Machine Learning Pipeline while maintaining capabilities like using Service Connections and passing environmental variables, Gated Release (Deployment)?

Edit: This process can then be used to run as an agentless job.


Solution

  • Assumptions:

    1. An AzureML Pipeline is published and the REST endpoint is ready- To be referred to in this answer as <AML_PIPELINE_REST_URI>. And Published Pipeline ID is also ready- To be referred to in this answer as <AML_PIPELINE_ID>
    2. You have the Azure Machine Learning Extension installed: Azure Machine Learning Extension

    To Invoke the Azure Machine Learning Pipeline we use the Invoke ML Pipeline step available in Azure DevOps. It is available when running an Agentless Job.

    To trigger it the workflow is as follows:

    1. Create a New Pipeline. Using the Classic Editor, delete the default Agent Job 1 stage. enter image description here

    enter image description here

    1. Add an agentless job: enter image description here

    2. Add a task to this Agentless Job: enter image description here

    3. Use AzureML Published Pipeline Task: enter image description here

    4. Use the Service Connection Mapped to the AML Workspace. You can find more on this at the official documentation enter image description here

    5. Choose the Pipeline to trigger using the <AML_PIPELINE_ID>: enter image description here

    6. Give The experiment name and Pipeline Parameters if any: enter image description here

    7. That's it, you can Save and Queue: enter image description here

    Alternatively, you can simply use the following jobs:

    - job: Job_2
      displayName: Agentless job
      pool: server
      steps:
      - task: MLPublishedPipelineRestAPITask@0
        displayName: Invoke ML pipeline
        inputs:
          connectedServiceName: <REDACTED-AML-WS-Level-Service_Connection-ID>
          PipelineId: <AML_PIPELINE_ID>
          ExperimentName: experimentname
          PipelineParameters: ''