Skip to content

Commit 8ffca20

Browse files
authored
Merge pull request #3486 from Blackmist/402372-fresh
updating date and removing un-maintained example clients
2 parents 4bbe637 + 7952a8f commit 8ffca20

File tree

2 files changed

+8
-188
lines changed

2 files changed

+8
-188
lines changed

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

Lines changed: 4 additions & 4 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
@@ -113,9 +113,9 @@ print(token)
113113
>
114114
> We strongly recommend that you create your Azure Machine Learning workspace in the same region as your Azure Kubernetes Service cluster.
115115
>
116-
> To authenticate with a token, the web service will make a call to the region in which your Azure Machine Learning workspace is created. If your workspace region is unavailable, you won't be able to fetch a token for your web service, even if your cluster is in a different region from your workspace. The result is that Microsoft Entra authentication is unavailable until your workspace region is available again.
116+
> To authenticate with a token, the web service makes a call to the region in which your Azure Machine Learning workspace is created. If your workspace region is unavailable, you aren't able to fetch a token for your web service, even if your cluster is in a different region from your workspace. The result is that Microsoft Entra authentication is unavailable until your workspace region is available again.
117117
>
118-
> Also, the greater the distance between your cluster's region and your workspace region, the longer it will take to fetch a token.
118+
> Also, the greater the distance between your cluster's region and your workspace region, the longer it takes to fetch a token.
119119
120120
## Next steps
121121

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

Lines changed: 4 additions & 184 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
@@ -104,7 +104,7 @@ The following table shows what these URIs look like:
104104
| Swagger URI | `http://104.214.29.152/api/v1/service/<service-name>/swagger.json` |
105105

106106
> [!TIP]
107-
> The IP address will be different for your deployment. Each AKS cluster will have its own IP address that is shared by deployments to that cluster.
107+
> The IP address is different for your deployment. Each AKS cluster has its own IP address that is shared by deployments to that cluster.
108108

109109
### Secured web service
110110

@@ -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
@@ -680,14 +508,6 @@ For a utility that can create client libraries from the specification, see [swag
680508
> [!TIP]
681509
> You can retrieve the schema JSON document after you deploy the service. Use the [swagger_uri property](/python/api/azureml-core/azureml.core.webservice.local.localwebservice#swagger-uri) from the deployed web service (for example, `service.swagger_uri`) to get the URI to the local web service's Swagger file.
682510

683-
## Consume the service from Power BI
684-
685-
Power BI supports consumption of Azure Machine Learning web services to enrich the data in Power BI with predictions.
686-
687-
To generate a web service that's supported for consumption in Power BI, the schema must support the format that's required by Power BI. [Learn how to create a Power BI-supported schema](./how-to-deploy-advanced-entry-script.md#power-bi-compatible-endpoint).
688-
689-
Once the web service is deployed, it's consumable from Power BI dataflows. [Learn how to consume an Azure Machine Learning web service from Power BI](/power-bi/service-machine-learning-integration).
690-
691511
## Next steps
692512

693513
To view a reference architecture for real-time scoring of Python and deep learning models, go to the [Azure architecture center](/azure/architecture/reference-architectures/ai/realtime-scoring-python).

0 commit comments

Comments
 (0)