Skip to content

Commit f2edf0c

Browse files
committed
updating date and removing un-maintained example clients
1 parent 48cf507 commit f2edf0c

File tree

2 files changed

+5
-177
lines changed

2 files changed

+5
-177
lines changed

articles/machine-learning/v1/how-to-authenticate-web-service.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ms.author: larryfr
88
ms.reviewer: sehan
99
ms.service: azure-machine-learning
1010
ms.subservice: inferencing
11-
ms.date: 11/16/2022
11+
ms.date: 03/11/2025
1212
ms.topic: how-to
1313
ms.custom: UpdateFrequency5, sdkv1
1414
---
@@ -31,7 +31,7 @@ The model deployments created by Azure Machine Learning can be configured to use
3131

3232
Web-services deployed on Azure Kubernetes Service (AKS) have key-based auth *enabled* by default.
3333

34-
Azure Container Instances (ACI) deployed services have key-based auth *disabled* by default, but you can enable it by setting `auth_enabled=True`when creating the ACI web-service. The following code is an example of creating an ACI deployment configuration with key-based auth enabled.
34+
Azure Container Instances (ACI) deployed services have key-based auth *disabled* by default, but you can enable it by setting `auth_enabled=True` when creating the ACI web-service. The following code is an example of creating an ACI deployment configuration with key-based auth enabled.
3535

3636
```python
3737
from azureml.core.webservice import AciWebservice

articles/machine-learning/v1/how-to-consume-web-service.md

Lines changed: 3 additions & 175 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ms.subservice: inferencing
88
ms.author: larryfr
99
author: Blackmist
1010
ms.reviewer: aashishb
11-
ms.date: 11/16/2022
11+
ms.date: 03/11/2025
1212
ms.topic: how-to
1313
ms.devlang: csharp
1414
# ms.devlang: csharp, golang, java, python
@@ -214,7 +214,7 @@ For information on enabling CORS support in your service, see [Cross-origin reso
214214

215215
## Call the service (C#)
216216

217-
This example demonstrates how to use C# to call the web service created from the [Train within notebook](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/notebook_runner/training_notebook.ipynb) example:
217+
This example demonstrates how to use C# to call a web service:
218218

219219
```csharp
220220
using System;
@@ -301,181 +301,9 @@ The results returned are similar to the following JSON document:
301301
[217.67978776218715, 224.78937091757172]
302302
```
303303

304-
## Call the service (Go)
305-
306-
This example demonstrates how to use Go to call the web service created from the [Train within notebook](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/notebook_runner/training_notebook.ipynb) example:
307-
308-
```go
309-
package main
310-
311-
import (
312-
"bytes"
313-
"encoding/json"
314-
"fmt"
315-
"io/ioutil"
316-
"net/http"
317-
)
318-
319-
// Features for this model are an array of decimal values
320-
type Features []float64
321-
322-
// The web service input can accept multiple sets of values for scoring
323-
type InputData struct {
324-
Data []Features `json:"data",omitempty`
325-
}
326-
327-
// Define some example data
328-
var exampleData = []Features{
329-
[]float64{
330-
0.0199132141783263,
331-
0.0506801187398187,
332-
0.104808689473925,
333-
0.0700725447072635,
334-
-0.0359677812752396,
335-
-0.0266789028311707,
336-
-0.0249926566315915,
337-
-0.00259226199818282,
338-
0.00371173823343597,
339-
0.0403433716478807,
340-
},
341-
[]float64{
342-
-0.0127796318808497,
343-
-0.044641636506989,
344-
0.0606183944448076,
345-
0.0528581912385822,
346-
0.0479653430750293,
347-
0.0293746718291555,
348-
-0.0176293810234174,
349-
0.0343088588777263,
350-
0.0702112981933102,
351-
0.00720651632920303,
352-
},
353-
}
354-
355-
// Set to the URI for your service
356-
var serviceUri string = "<your web service URI>"
357-
// Set to the authentication key or token (if any) for your service
358-
var authKey string = "<your key or token>"
359-
360-
func main() {
361-
// Create the input data from example data
362-
jsonData := InputData{
363-
Data: exampleData,
364-
}
365-
// Create JSON from it and create the body for the HTTP request
366-
jsonValue, _ := json.Marshal(jsonData)
367-
body := bytes.NewBuffer(jsonValue)
368-
369-
// Create the HTTP request
370-
client := &http.Client{}
371-
request, err := http.NewRequest("POST", serviceUri, body)
372-
request.Header.Add("Content-Type", "application/json")
373-
374-
// These next two are only needed if using an authentication key
375-
bearer := fmt.Sprintf("Bearer %v", authKey)
376-
request.Header.Add("Authorization", bearer)
377-
378-
// Send the request to the web service
379-
resp, err := client.Do(request)
380-
if err != nil {
381-
fmt.Println("Failure: ", err)
382-
}
383-
384-
// Display the response received
385-
respBody, _ := ioutil.ReadAll(resp.Body)
386-
fmt.Println(string(respBody))
387-
}
388-
```
389-
390-
The results returned are similar to the following JSON document:
391-
392-
```json
393-
[217.67978776218715, 224.78937091757172]
394-
```
395-
396-
## Call the service (Java)
397-
398-
This example demonstrates how to use Java to call the web service created from the [Train within notebook](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/notebook_runner/training_notebook.ipynb) example:
399-
400-
```java
401-
import java.io.IOException;
402-
import org.apache.http.client.fluent.*;
403-
import org.apache.http.entity.ContentType;
404-
import org.json.simple.JSONArray;
405-
import org.json.simple.JSONObject;
406-
407-
public class App {
408-
// Handle making the request
409-
public static void sendRequest(String data) {
410-
// Replace with the scoring_uri of your service
411-
String uri = "<your web service URI>";
412-
// If using authentication, replace with the auth key or token
413-
String key = "<your key or token>";
414-
try {
415-
// Create the request
416-
Content content = Request.Post(uri)
417-
.addHeader("Content-Type", "application/json")
418-
// Only needed if using authentication
419-
.addHeader("Authorization", "Bearer " + key)
420-
// Set the JSON data as the body
421-
.bodyString(data, ContentType.APPLICATION_JSON)
422-
// Make the request and display the response.
423-
.execute().returnContent();
424-
System.out.println(content);
425-
}
426-
catch (IOException e) {
427-
System.out.println(e);
428-
}
429-
}
430-
public static void main(String[] args) {
431-
// Create the data to send to the service
432-
JSONObject obj = new JSONObject();
433-
// In this case, it's an array of arrays
434-
JSONArray dataItems = new JSONArray();
435-
// Inner array has 10 elements
436-
JSONArray item1 = new JSONArray();
437-
item1.add(0.0199132141783263);
438-
item1.add(0.0506801187398187);
439-
item1.add(0.104808689473925);
440-
item1.add(0.0700725447072635);
441-
item1.add(-0.0359677812752396);
442-
item1.add(-0.0266789028311707);
443-
item1.add(-0.0249926566315915);
444-
item1.add(-0.00259226199818282);
445-
item1.add(0.00371173823343597);
446-
item1.add(0.0403433716478807);
447-
// Add the first set of data to be scored
448-
dataItems.add(item1);
449-
// Create and add the second set
450-
JSONArray item2 = new JSONArray();
451-
item2.add(-0.0127796318808497);
452-
item2.add(-0.044641636506989);
453-
item2.add(0.0606183944448076);
454-
item2.add(0.0528581912385822);
455-
item2.add(0.0479653430750293);
456-
item2.add(0.0293746718291555);
457-
item2.add(-0.0176293810234174);
458-
item2.add(0.0343088588777263);
459-
item2.add(0.0702112981933102);
460-
item2.add(0.00720651632920303);
461-
dataItems.add(item2);
462-
obj.put("data", dataItems);
463-
464-
// Make the request using the JSON document string
465-
sendRequest(obj.toJSONString());
466-
}
467-
}
468-
```
469-
470-
The results returned are similar to the following JSON document:
471-
472-
```json
473-
[217.67978776218715, 224.78937091757172]
474-
```
475-
476304
## Call the service (Python)
477305

478-
This example demonstrates how to use Python to call the web service created from the [Train within notebook](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/notebook_runner/training_notebook.ipynb) example:
306+
This example demonstrates how to use Python to call a web service:
479307

480308
```python
481309
import requests

0 commit comments

Comments
 (0)