Мы создали конечную точку веб-службы и протестировали ее с помощью следующего кода, а также с помощью POSTMAN.
Мы развернули службу в AKS в той же группе ресурсов и подписке, что и ресурс AML.
ОБНОВЛЕНИЕ: подключенный 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 состояние развертывания - «Исправно».
![Endpoint attributes](https://i.stack.imgur.com/RTB10.png)
При тестировании мы получаем следующую ошибку:
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 здесь .
Журнал после запуска тестового скрипта здесь .
Как мы можем узнать, что вызывает эту проблему, и исправить ее?