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
title: "Deploy models using online endpoints with REST APIs"
2
+
title: Deploy models by using online endpoints with REST APIs
3
3
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.
5
5
services: machine-learning
6
6
ms.service: machine-learning
7
7
ms.subservice: inferencing
8
8
ms.topic: how-to
9
9
author: msakande
10
10
ms.author: mopeakande
11
11
ms.reviewer: sehan
12
-
ms.date: 06/15/2022
12
+
ms.date: 07/29/2024
13
13
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.
14
16
---
15
17
16
18
# Deploy models with REST
17
19
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.
23
21
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.
28
23
29
24
## Prerequisites
30
25
31
26
- 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
+
32
28
- An [Azure Machine Learning workspace](quickstart-create-resources.md).
29
+
33
30
- 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`.
36
31
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).
38
33
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.
- 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`.
43
37
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.
45
39
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
47
41
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.
49
43
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`:
51
45
52
-
First, set up your Azure Machine Learning assets to configure your job.
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
55
49
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:
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:
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.
67
68
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:
> 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/).
80
81
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:
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`.
97
97
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:
0 commit comments