mlflow.azureml

The mlflow.azureml module provides an API for deploying MLflow models to Azure Machine Learning.

mlflow.azureml.build_image(model_uri, workspace, image_name=None, model_name=None, mlflow_home=None, description=None, tags=None, synchronous=True)

Note

Experimental: This method may change or be removed in a future release without warning.

Register an MLflow model with Azure ML and build an Azure ML ContainerImage for deployment. The resulting image can be deployed as a web service to Azure Container Instances (ACI) or Azure Kubernetes Service (AKS).

The resulting Azure ML ContainerImage will contain a webserver that processes model queries. For information about the input data formats accepted by this webserver, see the MLflow deployment tools documentation.

Parameters
Returns

A tuple containing the following elements in order: - An azureml.core.image.ContainerImage object containing metadata for the new image. - An azureml.core.model.Model object containing metadata for the new model.

>>> import mlflow.azureml
>>> from azureml.core import Workspace
>>> from azureml.core.webservice import AciWebservice, Webservice
>>>
>>> # Load or create an Azure ML Workspace
>>> workspace_name = "<Name of your Azure ML workspace>"
>>> subscription_id = "<Your Azure subscription ID>"
>>> resource_group = "<Name of the Azure resource group in which to create Azure ML resources>"
>>> location = "<Name of the Azure location (region) in which to create Azure ML resources>"
>>> azure_workspace = Workspace.create(name=workspace_name,
>>>                                    subscription_id=subscription_id,
>>>                                    resource_group=resource_group,
>>>                                    location=location,
>>>                                    create_resource_group=True,
>>>                                    exist_okay=True)
>>>
>>> # Build an Azure ML Container Image for an MLflow model
>>> azure_image, azure_model = mlflow.azureml.build_image(
>>>                                 model_uri="<model_uri>",
>>>                                 workspace=azure_workspace,
>>>                                 synchronous=True)
>>> # If your image build failed, you can access build logs at the following URI:
>>> print("Access the following URI for build logs: {}".format(azure_image.image_build_log_uri))
>>>
>>> # Deploy the image to Azure Container Instances (ACI) for real-time serving
>>> webservice_deployment_config = AciWebservice.deploy_configuration()
>>> webservice = Webservice.deploy_from_image(
>>>                    image=azure_image, workspace=azure_workspace, name="<deployment-name>")
>>> webservice.wait_for_deployment()