You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/machine-learning/service/how-to-consume-web-service.md
+13-11Lines changed: 13 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ ms.topic: conceptual
9
9
ms.author: aashishb
10
10
author: aashishb
11
11
ms.reviewer: larryfr
12
-
ms.date: 07/10/2019
12
+
ms.date: 08/15/2019
13
13
ms.custom: seodec18
14
14
15
15
@@ -20,7 +20,7 @@ ms.custom: seodec18
20
20
21
21
Deploying an Azure Machine Learning model as a web service creates a REST API. You can send data to this API and receive the prediction returned by the model. In this document, learn how to create clients for the web service by using C#, Go, Java, and Python.
22
22
23
-
You create a web service when you deploy an image to Azure Container Instances, Azure Kubernetes Service, or field-programmable gate arrays (FPGA). You create images from registered models and scoring files. You retrieve the URI used to access a web service by using the [Azure Machine Learning SDK](https://aka.ms/aml-sdk). If authentication is enabled, you can also use the SDK to get the authentication keys.
23
+
You create a web service when you deploy an image to Azure Container Instances, Azure Kubernetes Service, or field-programmable gate arrays (FPGA). You create images from registered models and scoring files. You retrieve the URI used to access a web service by using the [Azure Machine Learning SDK](https://aka.ms/aml-sdk). If authentication is enabled, you can also use the SDK to get the authentication keys or tokens.
24
24
25
25
The general workflow for creating a client that uses a machine learning web service is:
26
26
@@ -79,6 +79,8 @@ Azure Machine Learning provides two ways to control access to your web services.
79
79
|Key|Disabled by default| Enabled by default|
80
80
|Token| Not Available| Disabled by default |
81
81
82
+
When sending a request to a service that is secured with a key or token, use the __Authorization__ header to pass the key or token. The key or token must be formatted as`Bearer <key-or-token>`, where `<key-or-token>`is your key or token value.
83
+
82
84
#### Authentication with keys
83
85
84
86
When you enable authentication for a deployment, you automatically create authentication keys.
@@ -110,7 +112,7 @@ To control token authentication, use the `token_auth_enabled` parameter when you
110
112
If token authentication is enabled, you can use the `get_token` method to retrieve a bearer token and that tokens expiration time:
111
113
112
114
```python
113
-
token, refresh_by = service.get_tokens()
115
+
token, refresh_by = service.get_token()
114
116
print(token)
115
117
```
116
118
@@ -191,9 +193,9 @@ namespace MLWebServiceClient
191
193
{
192
194
static void Main(string[] args)
193
195
{
194
-
// Set the scoring URIand authentication key
196
+
// Set the scoring URIand authentication keyor token
195
197
string scoringUri = "<your web service URI>";
196
-
string authKey = "<your key>";
198
+
string authKey = "<your key or token>";
197
199
198
200
// Set the data to be sent to the service.
199
201
// In this case, we are sending two sets of data to be scored.
@@ -307,8 +309,8 @@ var exampleData = []Features{
307
309
308
310
// Set to the URIfor your service
309
311
var serviceUri string="<your web service URI>"
310
-
// Set to the authentication key (ifany) for your service
311
-
var authKey string="<your key>"
312
+
// Set to the authentication key or token (ifany) for your service
313
+
var authKey string="<your key or token>"
312
314
313
315
func main() {
314
316
// Create the input data from example data
@@ -362,8 +364,8 @@ public class App {
362
364
public static void sendRequest(String data) {
363
365
// Replace with the scoring_uri of your service
364
366
String uri = "<your web service URI>";
365
-
// If using authentication, replace with the auth key
366
-
String key = "<your key>";
367
+
// If using authentication, replace with the auth keyor token
368
+
String key = "<your key or token>";
367
369
try {
368
370
// Create the request
369
371
Content content = Request.Post(uri)
@@ -436,8 +438,8 @@ import json
436
438
437
439
# URL for the web service
438
440
scoring_uri = '<your web service URI>'
439
-
# If the service is authenticated, set the key
440
-
key = '<your key>'
441
+
# If the service is authenticated, set the key or token
442
+
key = '<your key or token>'
441
443
442
444
# Two sets of data to score, so we get two results back
0 commit comments