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/service/how-to-deploy-azure-kubernetes-service.md
+45-1Lines changed: 45 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -207,13 +207,57 @@ az ml model deploy -ct myaks -m mymodel:1 -n myservice -ic inferenceconfig.json
207
207
208
208
For more information, see the [az ml model deploy](https://docs.microsoft.com/cli/azure/ext/azure-cli-ml/ml/model?view=azure-cli-latest#ext-azure-cli-ml-az-ml-model-deploy) reference.
209
209
210
-
## Using VS Code
210
+
###Using VS Code
211
211
212
212
For information on using VS Code, see [deploy to AKS via the VS Code extension](how-to-vscode-tools.md#deploy-and-manage-models).
213
213
214
214
> [!IMPORTANT]
215
215
> Deploying through VS Code requires the AKS cluster to be created or attached to your workspace in advance.
216
216
217
+
## Web service authentication
218
+
219
+
When deploying to Azure Kubernetes Service, __key-based__ authentication is enabled by default. You can also enable __token__ authentication. Token authentication requires clients to use an Azure Active Directory account to request an authentication token, which is used to make requests to the deployed service.
220
+
221
+
To __disable__ authentication, set the `auth_enabled=False` parameter when creating the deployment configuration. The following example disables authentication using the SDK:
For information on authenticating from a client application, see the [Consume an Azure Machine Learning model deployed as a web service](how-to-consume-web-service.md).
228
+
229
+
### Authentication with keys
230
+
231
+
If key authentication is enabled, you can use the `get_keys` method to retrieve a primary and secondary authentication key:
232
+
233
+
```python
234
+
primary, secondary = service.get_keys()
235
+
print(primary)
236
+
```
237
+
238
+
> [!IMPORTANT]
239
+
> If you need to regenerate a key, use [`service.regen_key`](https://docs.microsoft.com/python/api/azureml-core/azureml.core.webservice(class)?view=azure-ml-py)
240
+
241
+
### Authentication with tokens
242
+
243
+
To enable token authentication, set the `token_auth_enabled=True` parameter when you are creating or updating a deployment. The following example enables token authentication using the SDK:
If token authentication is enabled, you can use the `get_token` method to retrieve a JWT token and that token's expiration time:
250
+
251
+
```python
252
+
token, refresh_by = service.get_token()
253
+
print(token)
254
+
```
255
+
256
+
> [!IMPORTANT]
257
+
> You will need to request a new token after the token's `refresh_by` time.
258
+
>
259
+
> Microsoft strongly recommends that you create your Azure Machine Learning workspace in the same region as your Azure Kubernetes Service cluster. To authenticate with a token, the web service will make a call to the region in which your Azure Machine Learning workspace is created. If your workspace's region is unavailable, then you will not be able to fetch a token for your web service even, if your cluster is in a different region than your workspace. This effectively results in Azure AD Authentication being unavailable until your workspace's region is available again. In addition, the greater the distance between your cluster's region and your workspace's region, the longer it will take to fetch a token.
0 commit comments