Azure ML workspace: how to publish pipeline to existing endpoint instead of creating new

Viewed 1433

I'm working on deploying an inference pipeline in Azure machine learning workspace.

I have created a pipeline using a couple of PythonScriptSteps and want to automate the pipeline publishing using CI/CD.

Reference: https://docs.microsoft.com/en-us/azure/machine-learning/how-to-deploy-pipelines#publish-a-pipeline

pipeline = Pipeline(workspace=workspace, steps=[step1, step2])
pipeline_endpoint = pipeline.publish(name='deployment-test', version=1)

Every time I publish, it is creating new endpoints but I want to deploy to existing so that nothing has to be changed in the consumer end.

2 Answers

PipelineEndpoint can be used to update a published pipeline while maintaining the same endpoint. PipelineEndpoint provides a way to keep track of PublishedPipelines using versions. PipelineEndpoint uses endpoint with version information to trigger an underlying published pipeline. Pipeline endpoints are uniquely named within a workspace.

I had the same problem as you and managed to get it to work by doing the following:

First initialize the endpoint:

pipeline = Pipeline(workspace=ws, steps=steps)
published = pipeline.publish(
            name="name"
        )
pipeline_endpoint = PipelineEndpoint.publish(
            workspace=ws,
            name="My endpoint name",
            pipeline=published,
            description="Endpoint to my pipeline",
       )
pipeline_endpoint.add_default(published)

The next time you run this you instead run:

pipeline = Pipeline(workspace=ws, steps=steps)
published = pipeline.publish(
            name="name"
)
pipeline_endpoint = PipelineEndpoint.get(
     workspace=ws, name="My endpoint name"
)
pipeline_endpoint.add_default(published)

add_default makes sure that the latest version of the pipeline is used in the endpoint.

Related