我们创建了一个 Web 服务端点,并使用以下代码和 POSTMAN 对其进行了测试。
我们将该服务部署到与 AML 资源相同的资源组和订阅中的 AKS。
更新:附加的 AKS 具有自定义网络配置并拒绝外部连接。
import numpy
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.authentication import AzureCliAuthentication
cli_auth = AzureCliAuthentication()
# Get workspace
ws = Workspace.from_config(auth=cli_auth)
# Get the AKS Details
try:
with open("../aml_config/aks_webservice.json") as f:
config = json.load(f)
except:
print("No new model, thus no deployment on AKS")
# raise Exception('No new model to register as production model perform better')
sys.exit(0)
service_name = config["aks_service_name"]
# Get the hosted web service
service = Webservice(workspace=ws, name=service_name)
# Input for Model with all features
input_j = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]
print(input_j)
test_sample = json.dumps({"data": input_j})
test_sample = bytes(test_sample, encoding="utf8")
try:
prediction = service.run(input_data=test_sample)
print(prediction)
except Exception as e:
result = str(e)
print(result)
raise Exception("AKS service is not working as expected")
在 AML Studio 中,部署状态为“正常”。
测试时出现以下错误:
Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond'
部署 AKS Web 服务后立即记录 here .
运行测试脚本后登录here .
我们如何知道导致此问题的原因并解决它?
最佳答案
您尝试过service.get_logs()吗?还请先尝试本地部署。 https://learn.microsoft.com/en-us/azure/machine-learning/how-to-deploy-local-container-notebook-vm
关于azure-machine-learning-service - AML - Web 服务超时错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62457880/