如何使用 Azure 机器学习服务上的新 docker 图像更新现有 Web 服务?

How to update the existing web service with a new docker image on Azure Machine Learning Services?

我目前正在使用 Azure 机器学习服务进行机器学习项目。但是我发现无法将新的 docker 图像更新到现有 Web 服务的问题(我希望 url 与我们服务的 运行 相同)。

我已经阅读了文档,但它并没有真正告诉我如何更新(文档 link:https://docs.microsoft.com/en-us/azure/machine-learning/service/how-to-deploy-and-where)。 文档说我们必须使用 update() with image = new-image。

from azureml.core.webservice import Webservice

service_name = 'aci-mnist-3

# Retrieve existing service
service = Webservice(name = service_name, workspace = ws)

# Update the image used by the service
service.update(image = new-image)

print(service.state)

但是 new-image 没有描述它的来源。

有谁知道如何解决这个问题?

谢谢

文档在这部分可以更清楚一点,我同意。 new-image 是一个图像对象,您应该将其传递给 update() 函数。如果您刚刚创建了图像,您可能已经在变量中拥有该对象,那么只需传递它即可。如果没有,那么您可以使用

从您的工作区获取它
from azureml.core.image.image import Image
new_image = Image(ws, image_name)

其中 ws 是您的工作区对象,image_name 是一个字符串,其中包含您要获取的图像的名称。然后你继续调用 update() 作为

from azureml.core.webservice import Webservice

service_name = 'aci-mnist-3'

# Retrieve existing service
service = Webservice(name = service_name, workspace = ws)

# Update the image used by the service
service.update(image = new_image) # Note that dash isn't supported in variable names

print(service.state)

您可以在 SDK documentation

中找到更多信息

编辑: 上面的ImageWebservice类都是abstract parent类.

对于 Image 对象,您确实应该使用其中之一 类,具体取决于您的情况:

  • ContainerImage
  • UnknownImage

(请参阅文档中的 Image package)。

对于 Webservice 对象,您应该使用其中之一 类,具体取决于您的情况:

  • AciWebservice
  • AksWebservice
  • UnknownWebservice

(请参阅文档中的 Webservice package)。