我可以使用语法在工作区ws
中部署Azure机器学习预测服务
aciconfig = AciWebservice.deploy_configuration(cpu_cores=1,
memory_gb=8,
tags={"method" : "some method"},
description='Predict something')
然后
service = Webservice.deploy_from_image(deployment_config = aciconfig,
image = image,
name = service_name,
workspace = ws)
,如documentation中所述。
但是,这会公开地公开服务,这并不是最佳选择。
屏蔽ACI服务最简单的方法是什么?我知道可以通过传递auth_enabled=True
参数来完成这项工作,但是随后如何指示客户(例如,使用curl
或Postman)使用该服务?
答案 0 :(得分:2)
有关示例,请参见here(在C#中)。启用身份验证后,您需要在HTTP请求的“授权”标头中发送API密钥:
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", authKey);
请参见here如何检索密钥。
答案 1 :(得分:0)
首先,使用类似
的语法检索主键和辅助键service.get_keys()
如果您使用的是curl
,则语法可能如下所示:
curl -H "Content-Type:application/json" -H "Authorization: Bearer <authKey>" -X POST -d '{"data": [some data]}' http://<url>:<port>/<method>
其中<authKey>
是上面检索到的键之一。