Skip to content

Commit 144b61c

Browse files
authored
Update how-to-authenticate-batch-endpoint.md
1 parent e03ccc7 commit 144b61c

File tree

1 file changed

+30
-14
lines changed

1 file changed

+30
-14
lines changed

articles/machine-learning/batch-inference/how-to-authenticate-batch-endpoint.md

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ You can either use one of the [built-in security roles](../../role-based-access-
4141

4242
The following examples show different ways to start batch deployment jobs using different types of credentials:
4343

44+
> [!IMPORTANT]
45+
> When working on a private link-enabled workspaces, batch endpoints can't be invoked from the UI in Azure ML studio. Please use the Azure ML CLI v2 instead for job creation.
46+
4447
### Running jobs using user's credentials
4548

4649
In this case, we want to execute a batch endpoint using the identity of the user currenly logged in. Follow these steps:
4750

48-
> [!IMPORTANT]
49-
> When working on a private link-enabled workspaces, batch endpoints can't be invoked from the UI in Azure ML studio. Please use the Azure ML CLI v2 instead for job creation.
50-
5151
> [!NOTE]
5252
> When working on Azure ML studio, batch endpoints/deployments are always executed using the identity of the current user logged in.
5353
@@ -89,6 +89,10 @@ In this case, we want to execute a batch endpoint using the identity of the user
8989
)
9090
```
9191
92+
# [REST](#tab/rest)
93+
94+
When working with REST APIs, we recommend to use either a service principal or a managed identity to interact with the API.
95+
9296
---
9397
9498
### Running jobs using a service principal
@@ -97,7 +101,7 @@ In this case, we want to execute a batch endpoint using a service princpal alrea
97101
98102
# [Azure ML CLI](#tab/cli)
99103
100-
1. Create a secret to use for authentication as explained at [Option 2: Create a new application secret](../../active-directory/develop/howto-create-service-principal-portal#option-2-create-a-new-application-secret).
104+
1. Create a secret to use for authentication as explained at [Option 2: Create a new application secret](../../active-directory/develop/howto-create-service-principal-portal.md#option-2-create-a-new-application-secret).
101105
1. For more details see [Sign in with Azure CLI](/cli/azure/authenticate-azure-cli).
102106
103107
```bash
@@ -112,7 +116,7 @@ In this case, we want to execute a batch endpoint using a service princpal alrea
112116
113117
# [Azure ML SDK for Python](#tab/sdk)
114118
115-
1. Create a secret to use for authentication as explained at [Option 2: Create a new application secret](../../active-directory/develop/howto-create-service-principal-portal#option-2-create-a-new-application-secret).
119+
1. Create a secret to use for authentication as explained at [Option 2: Create a new application secret](../../active-directory/develop/howto-create-service-principal-portal.md#option-2-create-a-new-application-secret).
116120
1. To authenticate using a service principal, indicate the tenant ID, client ID and client secret of the service principal using environment variables as demonstrated:
117121
118122
```python
@@ -145,8 +149,11 @@ You can use the REST API of Azure Machine Learning to start a batch endpoints jo
145149
146150
1. Use the login service from Azure to get an authorization token. Authorization tokens are issued to a particular scope. The resource type for Azure Machine learning is `https://ml.azure.com`. The request would look as follows:
147151
148-
__POST__: https://login.microsoftonline.com/<TENANT_ID>/oauth2/token
152+
__Request__:
153+
149154
```Body
155+
POST /{TENANT_ID}/oauth2/token
156+
Host:https://login.microsoftonline.com
150157
grant_type=client_credentials&client_id=<CLIENT_ID>&client_secret=<CLIENT_SECRET>&resource=https://ml.azure.com
151158
```
152159
@@ -155,8 +162,16 @@ You can use the REST API of Azure Machine Learning to start a batch endpoints jo
155162
156163
3. Once authenticated, use the query to run a batch deployment job:
157164
158-
__POST__: <ENDPOINT_URI>
165+
__Request__:
159166
167+
```http
168+
POST jobs HTTP/1.1
169+
Host: <ENDPOINT_URI>
170+
Authorization: Bearer <TOKEN>
171+
Content-Type: application/json
172+
```
173+
__Body:__
174+
160175
```json
161176
{
162177
"properties": {
@@ -169,13 +184,6 @@ You can use the REST API of Azure Machine Learning to start a batch endpoints jo
169184
}
170185
}
171186
```
172-
173-
The following headers need to be included:
174-
175-
| Header | Value |
176-
|---------------|------------------|
177-
| Authorization | Bearer <TOKEN> |
178-
| Content-Type | application/json |
179187
180188
---
181189
@@ -216,6 +224,14 @@ job = ml_client.batch_endpoints.invoke(
216224
)
217225
```
218226

227+
# [REST](#tab/rest)
228+
229+
You can use the REST API of Azure Machine Learning to start a batch endpoints job using a managed identity. The steps vary depending on the underlying service being used. Some examples include (but are not limitted to):
230+
231+
* [Managed identity for Azure Data Factory](../../data-factory/data-factory-service-identity.md)
232+
* [How to use managed identities for App Service and Azure Functions](../../app-service/overview-managed-identity.md).
233+
* [How to use managed identities for Azure resources on an Azure VM to acquire an access token](../../active-directory/managed-identities-azure-resources/how-to-use-vm-token.md).
234+
219235
---
220236

221237
## Next steps

0 commit comments

Comments
 (0)