Skip to content

Commit 4208c14

Browse files
authored
Merge pull request #281816 from GitHubber17/271044-c
Freshness - Azure Machine Learning (271044)
2 parents 187f4ba + 878ac3c commit 4208c14

File tree

1 file changed

+54
-54
lines changed

1 file changed

+54
-54
lines changed
Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,103 @@
11
---
2-
title: "Deploy models using online endpoints with REST APIs"
2+
title: Deploy models by using online endpoints with REST APIs
33
titleSuffix: Azure Machine Learning
4-
description: Learn how to deploy models using online endpoints with REST APIs.
4+
description: Learn how to deploy models by using online endpoints with REST APIs, including creation of assets, training jobs, and hyperparameter tuning sweep jobs.
55
services: machine-learning
66
ms.service: machine-learning
77
ms.subservice: inferencing
88
ms.topic: how-to
99
author: msakande
1010
ms.author: mopeakande
1111
ms.reviewer: sehan
12-
ms.date: 06/15/2022
12+
ms.date: 07/29/2024
1313
ms.custom: devplatv2
14+
15+
#customer intent: As a developer, I want to use the Azure Machine Learning REST APIs so that I can deploy models by using online endpoints.
1416
---
1517

1618
# Deploy models with REST
1719

18-
Learn how to use the Azure Machine Learning REST API to deploy models.
19-
20-
The REST API uses standard HTTP verbs to create, retrieve, update, and delete resources. The REST API works with any language or tool that can make HTTP requests. REST's straightforward structure makes it a good choice in scripting environments and for MLOps automation.
21-
22-
In this article, you learn how to use the new REST APIs to:
20+
This article describes how to use the Azure Machine Learning REST API to deploy models by using online endpoints. Online endpoints allow you to deploy your model without having to create and manage the underlying infrastructure and Kubernetes clusters. The following procedures demonstrate how to create an online endpoint and deployment and validate the endpoint by invoking it.
2321

24-
> [!div class="checklist"]
25-
> * Create machine learning assets
26-
> * Create a basic training job
27-
> * Create a hyperparameter tuning sweep job
22+
There are many ways to create an Azure Machine Learning online endpoint. You can use [the Azure CLI](how-to-deploy-online-endpoints.md), the [Azure Machine Learning studio](how-to-deploy-online-endpoints.md), or the REST API. The REST API uses standard HTTP verbs to create, retrieve, update, and delete resources. It works with any language or tool that can make HTTP requests. The straightforward structure of the REST API makes it a good choice in scripting environments and for machine learning operations automation.
2823

2924
## Prerequisites
3025

3126
- An **Azure subscription** for which you have administrative rights. If you don't have such a subscription, try the [free or paid personal subscription](https://azure.microsoft.com/free/).
27+
3228
- An [Azure Machine Learning workspace](quickstart-create-resources.md).
29+
3330
- A service principal in your workspace. Administrative REST requests use [service principal authentication](how-to-setup-authentication.md#use-service-principal-authentication).
34-
- A service principal authentication token. Follow the steps in [Retrieve a service principal authentication token](./how-to-manage-rest.md#retrieve-a-service-principal-authentication-token) to retrieve this token.
35-
- The **curl** utility. The **curl** program is available in the [Windows Subsystem for Linux](/windows/wsl/install-win10) or any UNIX distribution. In PowerShell, **curl** is an alias for **Invoke-WebRequest** and `curl -d "key=val" -X POST uri` becomes `Invoke-WebRequest -Body "key=val" -Method POST -Uri uri`.
3631

37-
## Set endpoint name
32+
- A service principal authentication token. You can get the token by following the steps in [Retrieve a service principal authentication token](./how-to-manage-rest.md#retrieve-a-service-principal-authentication-token).
3833

39-
> [!NOTE]
40-
> Endpoint names need to be unique at the Azure region level. For example, there can be only one endpoint with the name my-endpoint in westus2.
34+
- The **curl** utility.
4135

42-
:::code language="rest-api" source="~/azureml-examples-main/cli/deploy-rest.sh" id="set_endpoint_name":::
36+
- All installations of Microsoft Windows 10 and Windows 11 have curl installed by default. In PowerShell, curl is an alias for **Invoke-WebRequest** and `curl -d "key=val" -X POST uri` becomes `Invoke-WebRequest -Body "key=val" -Method POST -Uri uri`.
4337

44-
## Azure Machine Learning online endpoints
38+
- For UNIX platforms, the curl program is available in the [Windows Subsystem for Linux](/windows/wsl/install) or any UNIX distribution.
4539

46-
Online endpoints allow you to deploy your model without having to create and manage the underlying infrastructure as well as Kubernetes clusters. In this article, you'll create an online endpoint and deployment, and validate it by invoking it. But first you'll have to register the assets needed for deployment, including model, code, and environment.
40+
## Set endpoint name
4741

48-
There are many ways to create an Azure Machine Learning online endpoint [including the Azure CLI](how-to-deploy-online-endpoints.md), and visually with [the studio](how-to-use-managed-online-endpoint-studio.md). The following example an online endpoint with the REST API.
42+
Endpoint names must be unique at the Azure region level. An endpoint name such as _my-endpoint_ must be the only endpoint with that name within a specified region.
4943

50-
## Create machine learning assets
44+
Create a unique endpoint name by calling the `RANDOM` utility, which adds a random number as a suffix to the value `endpt-rest`:
5145

52-
First, set up your Azure Machine Learning assets to configure your job.
46+
:::code language="rest-api" source="~/azureml-examples-main/cli/deploy-rest.sh" id="set_endpoint_name":::
5347

54-
In the following REST API calls, we use `SUBSCRIPTION_ID`, `RESOURCE_GROUP`, `LOCATION`, and `WORKSPACE` as placeholders. Replace the placeholders with your own values.
48+
## Create machine learning assets
5549

56-
Administrative REST requests a [service principal authentication token](how-to-manage-rest.md#retrieve-a-service-principal-authentication-token). Replace `TOKEN` with your own value. You can retrieve this token with the following command:
50+
To prepare for the deployment, set up your Azure Machine Learning assets and configure your job. You register the assets required for deployment, including the model, code, and environment.
51+
52+
> [!TIP]
53+
> The REST API calls in the following procedures use `$SUBSCRIPTION_ID`, `$RESOURCE_GROUP`, `$LOCATION` (region), and Azure Machine Learning `$WORKSPACE` as placeholders for some arguments. When you implement the code for your deployment, replace the argument placeholders with your specific deployment values.
54+
55+
Administrative REST requests a [service principal authentication token](how-to-manage-rest.md#retrieve-a-service-principal-authentication-token). When you implement the code for your deployment, replace instances of the `$TOKEN` placeholder with the service principal token for your deployment. You can retrieve this token with the following command:
5756

5857
:::code language="rest-api" source="~/azureml-examples-main/cli/deploy-rest.sh" id="get_access_token":::
5958

60-
The service provider uses the `api-version` argument to ensure compatibility. The `api-version` argument varies from service to service. Set the API version as a variable to accommodate future versions:
59+
The service provider uses the `api-version` argument to ensure compatibility. The `api-version` argument varies from service to service.
60+
61+
Set the `API_version` variable to accommodate future versions:
6162

6263
:::code language="rest-api" source="~/azureml-examples-main/cli/deploy-rest.sh" id="api_version":::
6364

6465
### Get storage account details
6566

66-
To register the model and code, first they need to be uploaded to a storage account. The details of the storage account are available in the data store. In this example, you get the default datastore and Azure Storage account for your workspace. Query your workspace with a GET request to get a JSON file with the information.
67+
To register the model and code, you need to first upload these items to an Azure Storage account. The details of the Azure Storage account are available in the data store. In this example, you get the default data store and Azure Storage account for your workspace. Query your workspace with a GET request to get a JSON file with the information.
6768

68-
You can use the tool [jq](https://stedolan.github.io/jq/) to parse the JSON result and get the required values. You can also use the Azure portal to find the same information:
69+
You can use the [jq](https://jqlang.github.io/jq/) tool to parse the JSON result and get the required values. You can also use the Azure portal to find the same information:
6970

7071
:::code language="rest-api" source="~/azureml-examples-main/cli/deploy-rest.sh" id="get_storage_details":::
7172

72-
### Upload & register code
73+
### Upload and register code
7374

74-
Now that you have the datastore, you can upload the scoring script. Use the Azure Storage CLI to upload a blob into your default container:
75+
Now that you have the data store, you can upload the scoring script. Use the Azure Storage CLI to upload a blob into your default container:
7576

7677
:::code language="rest-api" source="~/azureml-examples-main/cli/deploy-rest.sh" id="upload_code":::
7778

7879
> [!TIP]
79-
> You can also use other methods to upload, such as the Azure portal or [Azure Storage Explorer](https://azure.microsoft.com/features/storage-explorer/).
80+
> You can use other methods to complete the upload, such as the Azure portal or [Azure Storage Explorer](https://azure.microsoft.com/features/storage-explorer/).
8081
81-
Once you upload your code, you can specify your code with a PUT request and refer to the datastore with `datastoreId`:
82+
After you upload your code, you can specify your code with a PUT request and refer to the data store with the `datastoreId` identifier:
8283

8384
:::code language="rest-api" source="~/azureml-examples-main/cli/deploy-rest.sh" id="create_code":::
8485

8586
### Upload and register model
8687

87-
Similar to the code, Upload the model files:
88+
Upload the model files with a similar REST API call:
8889

8990
:::code language="rest-api" source="~/azureml-examples-main/cli/deploy-rest.sh" id="upload_model":::
9091

91-
Now, register the model:
92+
After the upload completes, register the model:
9293

9394
:::code language="rest-api" source="~/azureml-examples-main/cli/deploy-rest.sh" id="create_model":::
9495

9596
### Create environment
96-
The deployment needs to run in an environment that has the required dependencies. Create the environment with a PUT request. Use a docker image from Microsoft Container Registry. You can configure the docker image with `Docker` and add conda dependencies with `condaFile`.
9797

98-
In the following snippet, the contents of a Conda environment (YAML file) has been read into an environment variable:
98+
The deployment needs to run in an environment that has the required dependencies. Create the environment with a PUT request. Use a Docker image from Microsoft Container Registry. You can configure the Docker image with the `docker` command and add conda dependencies with the `condaFile` command.
99+
100+
The following code reads the contents of a Conda environment (YAML file) into an environment variable:
99101

100102
:::code language="rest-api" source="~/azureml-examples-main/cli/deploy-rest.sh" id="create_environment":::
101103

@@ -111,40 +113,38 @@ Create a deployment under the endpoint:
111113

112114
:::code language="rest-api" source="~/azureml-examples-main/cli/deploy-rest.sh" id="create_deployment":::
113115

114-
### Invoke the endpoint to score data with your model
116+
### Invoke endpoint to score data with model
117+
118+
You need the scoring URI and access token to invoke the deployment endpoint.
115119

116-
We need the scoring uri and access token to invoke the endpoint. First get the scoring uri:
120+
First, get the scoring URI:
117121

118122
:::code language="rest-api" source="~/azureml-examples-main/cli/deploy-rest.sh" id="get_endpoint":::
119123

120-
Get the endpoint access token:
124+
Next, get the endpoint access token:
121125

122126
:::code language="rest-api" source="~/azureml-examples-main/cli/deploy-rest.sh" id="get_access_token":::
123127

124-
Now, invoke the endpoint using curl:
128+
Finally, invoke the endpoint by using the curl utility:
125129

126130
:::code language="rest-api" source="~/azureml-examples-main/cli/deploy-rest.sh" id="score_endpoint":::
127131

128-
### Check the logs
132+
### Check deployment logs
129133

130134
Check the deployment logs:
131135

132136
:::code language="rest-api" source="~/azureml-examples-main/cli/deploy-rest.sh" id="get_deployment_logs":::
133137

134-
### Delete the endpoint
138+
### Delete endpoint
135139

136-
If you aren't going use the deployment, you should delete it with the below command (it deletes the endpoint and all the underlying deployments):
140+
If you aren't going to use the deployment further, delete the resources.
141+
142+
Run the following command, which deletes the endpoint and all underlying deployments:
137143

138144
:::code language="rest-api" source="~/azureml-examples-main/cli/deploy-rest.sh" id="delete_endpoint":::
139145

140-
## Next steps
141-
142-
* Learn how to deploy your model [using the Azure CLI](how-to-deploy-online-endpoints.md).
143-
* Learn how to deploy your model [using studio](how-to-use-managed-online-endpoint-studio.md).
144-
* Learn to [Troubleshoot online endpoints deployment and scoring](how-to-troubleshoot-managed-online-endpoints.md)
145-
* Learn how to [Access Azure resources with a online endpoint and managed identity](how-to-access-resources-from-endpoints-managed-identities.md)
146-
* Learn how to [monitor online endpoints](how-to-monitor-online-endpoints.md).
147-
* Learn [safe rollout for online endpoints](how-to-safely-rollout-online-endpoints.md).
148-
* [View costs for an Azure Machine Learning managed online endpoint](how-to-view-online-endpoints-costs.md).
149-
* [Managed online endpoints SKU list](reference-managed-online-endpoints-vm-sku-list.md).
150-
* Learn about [limits for online endpoints](how-to-manage-quotas.md#azure-machine-learning-online-endpoints-and-batch-endpoints).
146+
## Related content
147+
148+
- [Deploy and score a model by using an online endpoint](how-to-deploy-online-endpoints.md)
149+
- [Troubleshoot online endpoints deployment and scoring](how-to-troubleshoot-online-endpoints.md)
150+
- [Monitor online endpoints](how-to-monitor-online-endpoints.md)

0 commit comments

Comments
 (0)