Skip to content

Commit 0a4eed0

Browse files
Merge pull request #216789 from santiagxf/santiagxf/azureml-batch-patchinvoke
Update how-to-authenticate-batch-endpoint.md
2 parents d9fb763 + f19d129 commit 0a4eed0

File tree

1 file changed

+27
-16
lines changed

1 file changed

+27
-16
lines changed

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

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ ms.custom: devplatv2
1515

1616
# Authentication on batch endpoints
1717

18-
Batch endpoints support Azure Active Directory authentication, or `aad_token`. That means that in order to invoke a batch endpoint, the user must present a valid Azure Active Directory authentication token to the batch endpoint URI. Authorization is enforced at the endpoint level. The following article explains how to correctly interact with batch endpoints and the security requirements for it.
18+
Batch endpoints support Azure Active Directory authentication, or `aad_token`. That means that in order to invoke a batch endpoint, the user must present a valid Azure Active Directory authentication token to the batch endpoint URI. Authorization is enforced at the endpoint level. The following article explains how to correctly interact with batch endpoints and the security requirements for it.
1919

2020
## Prerequisites
2121

2222
* This example assumes that you have a model correctly deployed as a batch endpoint. Particularly, we are using the *heart condition classifier* created in the tutorial [Using MLflow models in batch deployments](how-to-mlflow-batch.md).
2323

2424
## How authentication works
2525

26-
To invoke a batch endpoint, the user must present a valid Azure Active Directory token representing a security principal. This principal can be a __user principal__ or a __service principal__. In any case, once an endpoint is invoked, a batch deployment job is created under the identity associated with the token. The identity needs the following permissions in order to successfully create a job:
26+
To invoke a batch endpoint, the user must present a valid Azure Active Directory token representing a __security principal__. This principal can be a __user principal__ or a __service principal__. In any case, once an endpoint is invoked, a batch deployment job is created under the identity associated with the token. The identity needs the following permissions in order to successfully create a job:
2727

2828
> [!div class="checklist"]
2929
> * Read batch endpoints/deployments.
@@ -62,7 +62,7 @@ In this case, we want to execute a batch endpoint using the identity of the user
6262
1. Once authenticated, use the following command to run a batch deployment job:
6363
6464
```azurecli
65-
az ml batch-endpoint invoke --name $ENDPOINT_NAME --input https://azuremlexampledata.blob.core.windows.net/data/heart-disease-uci/data
65+
az ml batch-endpoint invoke --name $ENDPOINT_NAME --input https://azuremlexampledata.blob.core.windows.net/data/heart-disease-uci
6666
```
6767
6868
# [Azure ML SDK for Python](#tab/sdk)
@@ -85,13 +85,13 @@ In this case, we want to execute a batch endpoint using the identity of the user
8585
```python
8686
job = ml_client.batch_endpoints.invoke(
8787
endpoint_name,
88-
input=Input(path="https://azuremlexampledata.blob.core.windows.net/data/heart-disease-uci/data")
88+
input=Input(path="https://azuremlexampledata.blob.core.windows.net/data/heart-disease-uci")
8989
)
9090
```
9191
9292
# [REST](#tab/rest)
9393
94-
When working with REST APIs, we recommend to using either a service principal or a managed identity to interact with the API.
94+
When working with REST APIs, we recommend to using either a [service principal](#running-jobs-using-a-service-principal) or a [managed identity](#running-jobs-using-a-managed-identity) to interact with the API.
9595
9696
---
9797
@@ -101,8 +101,8 @@ In this case, we want to execute a batch endpoint using a service principal alre
101101
102102
# [Azure ML CLI](#tab/cli)
103103
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).
105-
1. For more details see [Sign in with Azure CLI](/cli/azure/authenticate-azure-cli).
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).
105+
1. To authenticate using a service principal, use the following command. For more details see [Sign in with Azure CLI](/cli/azure/authenticate-azure-cli).
106106
107107
```bash
108108
az login --service-principal -u <app-id> -p <password-or-cert> --tenant <tenant>
@@ -111,7 +111,7 @@ In this case, we want to execute a batch endpoint using a service principal alre
111111
1. Once authenticated, use the following command to run a batch deployment job:
112112
113113
```azurecli
114-
az ml batch-endpoint invoke --name $ENDPOINT_NAME --input https://azuremlexampledata.blob.core.windows.net/data/heart-disease-uci/data
114+
az ml batch-endpoint invoke --name $ENDPOINT_NAME --input https://azuremlexampledata.blob.core.windows.net/data/heart-disease-uci/
115115
```
116116
117117
# [Azure ML SDK for Python](#tab/sdk)
@@ -139,7 +139,7 @@ In this case, we want to execute a batch endpoint using a service principal alre
139139
```python
140140
job = ml_client.batch_endpoints.invoke(
141141
endpoint_name,
142-
input=Input(path="https://azuremlexampledata.blob.core.windows.net/data/heart-disease-uci/data")
142+
input=Input(path="https://azuremlexampledata.blob.core.windows.net/data/heart-disease-uci")
143143
)
144144
```
145145
@@ -151,9 +151,14 @@ You can use the REST API of Azure Machine Learning to start a batch endpoints jo
151151
152152
__Request__:
153153
154-
```Body
155-
POST /{TENANT_ID}/oauth2/token
156-
Host:https://login.microsoftonline.com
154+
```http
155+
POST /{TENANT_ID}/oauth2/token HTTP/1.1
156+
Host: login.microsoftonline.com
157+
```
158+
159+
__Body__:
160+
161+
```
157162
grant_type=client_credentials&client_id=<CLIENT_ID>&client_secret=<CLIENT_SECRET>&resource=https://ml.azure.com
158163
```
159164
@@ -178,7 +183,7 @@ You can use the REST API of Azure Machine Learning to start a batch endpoints jo
178183
"InputData": {
179184
"mnistinput": {
180185
"JobInputType" : "UriFolder",
181-
"Uri": "https://pipelinedata.blob.core.windows.net/sampledata/mnist"
186+
"Uri": "https://azuremlexampledata.blob.core.windows.net/data/heart-disease-uci"
182187
}
183188
}
184189
}
@@ -189,15 +194,21 @@ You can use the REST API of Azure Machine Learning to start a batch endpoints jo
189194
190195
### Running jobs using a managed identity
191196
197+
You can use managed identities to invoke batch endpoint and deployments. Please notice that this manage identity doesn't belong to the batch endpoint, but it is the identity used to execute the endpoint and hence create a batch job. Both user assigned and system assigned identities can be use in this scenario.
198+
192199
# [Azure ML CLI](#tab/cli)
193200
194-
On resources configured for managed identities for Azure resources, you can sign in using the managed identity. Signing in with the resource's identity is done through the `--identity` flag.
201+
On resources configured for managed identities for Azure resources, you can sign in using the managed identity. Signing in with the resource's identity is done through the `--identity` flag. For more details see [Sign in with Azure CLI](/cli/azure/authenticate-azure-cli).
195202
196203
```bash
197204
az login --identity
198205
```
199206

200-
For more details see [Sign in with Azure CLI](/cli/azure/authenticate-azure-cli).
207+
Once authenticated, use the following command to run a batch deployment job:
208+
209+
```azurecli
210+
az ml batch-endpoint invoke --name $ENDPOINT_NAME --input https://azuremlexampledata.blob.core.windows.net/data/heart-disease-uci
211+
```
201212

202213
# [Azure ML SDK for Python](#tab/sdk)
203214

@@ -220,7 +231,7 @@ Once authenticated, use the following command to run a batch deployment job:
220231
```python
221232
job = ml_client.batch_endpoints.invoke(
222233
endpoint_name,
223-
input=Input(path="https://azuremlexampledata.blob.core.windows.net/data/heart-disease-uci/data")
234+
input=Input(path="https://azuremlexampledata.blob.core.windows.net/data/heart-disease-uci")
224235
)
225236
```
226237

0 commit comments

Comments
 (0)