Search code examples
pythonpython-3.xazureazure-machine-learning-service

AzureML: Automatically update deployment when new version of model is available


I have an AzureML pipeline that trains and registers a model regularly. Each run creates a new version of the registered model. My goal is to re-deploy the model whenever there is a new version available.

In another script I deploy the registered model and overwrite any existing deployments:

service = Model.deploy(
    workspace=ws,
    name=service_name,
    models=[model],
    inference_config=inference_config,
    deployment_config=deployment_config,
    deployment_target=compute_target,
    overwrite=True
)

Initially, I thought it would make sense to include the deployment in the pipeline, but I cannot figure out how to refer to the workspace within the pipeline step.

Thanks for helping me out!


Solution

  • Within a pipeline step, you can access the Workspace via:

    run = Run.get_context()
    ws = run.experiment.workspace