【发布时间】:2021-04-11 16:01:03
【问题描述】:
简介
我在本地创建了自己的模型,然后将其注册并部署到 azure 并且可以正常工作。
部署的模型输出:
我的方法
我使用了this tutorial,我想在 Azure Function 中使用我的模型,我可以做到:
def main(req: func.HttpRequest, msg: func.Out[func.QueueMessage]) -> str:
name = req.params.get('name')
scoring_uri = 'http://1f72b1bf-5ca9-42d9-bedd-f41773591a4f.francecentral.azurecontainer.io/score'
headers = {'Content-Type':'application/json'}
test_data = json.dumps({'text': 'Today is a great day!'})
response = requests.post(scoring_uri, data=test_data, headers=headers)
if not name:
try:
req_body = req.get_json()
except ValueError:
pass
else:
name = req_body.get('name')
if name:
msg.set(name)
return func.HttpResponse(f"Hello {name}! Najlepszy wynik: {response.json()}")
else:
return func.HttpResponse(
"Please pass a name on the query string or in the request body",
status_code=400
)
问题
- 我的用法正确吗?
- 是否可以使用 Azure 存储进行模型存储以及如何使用?
- 还有其他方法可以在 Azure Function 中使用模型吗?
我想知道,因为我在要求中指定了我应该使用 azure 函数和 azure 存储。我不明白为什么。
【问题讨论】:
标签: azure azure-functions azure-storage azure-machine-learning-service