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
Copy file name to clipboardExpand all lines: articles/machine-learning/batch-inference/how-to-authenticate-batch-endpoint.md
+27-16Lines changed: 27 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,15 +15,15 @@ ms.custom: devplatv2
15
15
16
16
# Authentication on batch endpoints
17
17
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.
19
19
20
20
## Prerequisites
21
21
22
22
* 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).
23
23
24
24
## How authentication works
25
25
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:
27
27
28
28
> [!div class="checklist"]
29
29
> * Read batch endpoints/deployments.
@@ -62,7 +62,7 @@ In this case, we want to execute a batch endpoint using the identity of the user
62
62
1. Once authenticated, use the following command to run a batch deployment job:
63
63
64
64
```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
66
66
```
67
67
68
68
# [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
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.
95
95
96
96
---
97
97
@@ -101,8 +101,8 @@ In this case, we want to execute a batch endpoint using a service principal alre
101
101
102
102
# [Azure ML CLI](#tab/cli)
103
103
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).
106
106
107
107
```bash
108
108
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
111
111
1. Once authenticated, use the following command to run a batch deployment job:
112
112
113
113
```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/
115
115
```
116
116
117
117
# [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
@@ -189,15 +194,21 @@ You can use the REST API of Azure Machine Learning to start a batch endpoints jo
189
194
190
195
### Running jobs using a managed identity
191
196
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
+
192
199
# [Azure ML CLI](#tab/cli)
193
200
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).
195
202
196
203
```bash
197
204
az login --identity
198
205
```
199
206
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
+
```
201
212
202
213
# [Azure ML SDK for Python](#tab/sdk)
203
214
@@ -220,7 +231,7 @@ Once authenticated, use the following command to run a batch deployment job:
0 commit comments