# COMMAND ---------- aks_target.wait_for_completion(show_output=True) # COMMAND ---------- # MAGIC %md ### Deploy the model's image to the specified AKS cluster # COMMAND ---------- from azureml.core.webservice import Webservice, AksWebservice from azureml.core.image import Image # Get Model model_image = Image(aksml_workspace, id=model_image_id) # Get Webservice prod_webservice_name = "drinks-quality-aks" # COMMAND ---------- from azureml.core.webservice import Webservice, AksWebservice from azureml.core.image import Image # Get Model model_image = Image(aksml_workspace, id=model_image_id) # Get Webservice prod_webservice_name = "drinks-quality-aks" try: prod_webservice = Webservice(aksml_workspace, prod_webservice_name)
# MAGIC %md ## Deploy the model to "dev" using [Azure Container Instances (ACI)](https://docs.microsoft.com/en-us/azure/container-instances/) # MAGIC # MAGIC The [ACI platform](https://docs.microsoft.com/en-us/azure/container-instances/) is the recommended environment for staging and developmental model deployments. # COMMAND ---------- # MAGIC %md ### Create an ACI webservice deployment using the model's Container Image # MAGIC # MAGIC Using the Azure ML SDK, deploy the Container Image for the trained MLflow model to ACI. # COMMAND ---------- from azureml.core.webservice import AciWebservice, Webservice from azureml.core.image import Image model_image = Image(workspace, id=model_image_id) dev_webservice_name = "wine-quality-aci" dev_webservice_deployment_config = AciWebservice.deploy_configuration() dev_webservice = Webservice.deploy_from_image(name=dev_webservice_name, image=model_image, deployment_config=dev_webservice_deployment_config, workspace=workspace, deployment_target=None, overwrite=True) dev_webservice.wait_for_deployment() # COMMAND ---------- # MAGIC %md ## Query the deployed model in "dev" # COMMAND ---------- # MAGIC %md ### Load dataset
import os, json, datetime, sys from operator import attrgetter from azureml.core import Workspace from azureml.core.model import Model from azureml.core.image import Image from azureml.core.webservice import Webservice from azureml.core.webservice import AciWebservice from azureml.core.authentication import AzureCliAuthentication cli_auth = AzureCliAuthentication() # Get workspace ws = Workspace.from_config(auth=cli_auth) # Get the Image to deploy details image = Image(workspace=ws, name="myonnxmodelimage") print(image) aciconfig = AciWebservice.deploy_configuration( cpu_cores=1, memory_gb=1, tags={ "area": "MNIST", "type": "DNN" }, description="Description", ) aci_service_name = "aciwebservice" service = Webservice.deploy_from_image(deployment_config=aciconfig, image=image, name=aci_service_name,