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
-[Azure ML Python SDK (v2)](https://aka.ms/sdk-v2-install)
89
+
90
+
For more information, see the guide on [how to prepare your system to deploy managed online endpoints](how-to-deploy-managed-online-endpoints.md#prepare-your-system).
91
+
92
+
The examples in this article are based on code samples contained in the [azureml-examples](https://github.com/azure/azureml-examples) repository. To run the commands locally without having to copy/paste YAML and other files, clone the repo and then change directories to the `cli` directory in the repo:
If you haven't already set the defaults for the Azure CLI, save your default settings. To avoid passing in the values for your subscription, workspace, and resource group multiple times, use the following commands. Replace the following parameters with values for your specific configuration:
101
+
102
+
* Replace `<subscription>` with your Azure subscription ID.
103
+
* Replace `<workspace>` with your Azure Machine Learning workspace name.
104
+
* Replace `<resource-group>` with the Azure resource group that contains your workspace.
105
+
* Replace `<location>` with the Azure region that contains your workspace.
106
+
107
+
> [!TIP]
108
+
> You can see what your current defaults are by using the `az configure -l` command.
109
+
110
+
```azurecli
111
+
az account set --subscription <subscription>
112
+
az configure --defaults workspace=<workspace> group=<resource-group> location=<location>
113
+
```
114
+
115
+
---
116
+
77
117
## Launch development container
78
118
119
+
# [Portal](#tab/azure-portal)
120
+
79
121
Azure Machine Learning local endpoints use Docker and VS Code development containers (dev container) to build and configure a local debugging environment. With dev containers, you can take advantage of VS Code features from inside a Docker container. For more information on dev containers, see [Create a development container](https://code.visualstudio.com/docs/remote/create-dev-container).
80
122
81
123
To debug online endpoints locally in VS Code, use the `--vscode-debug` flag when creating or updating and Azure Machine Learning online deployment. The following command uses a deployment example from the examples repo:
@@ -104,6 +146,102 @@ You'll use a few VS Code extensions to debug your deployments in the dev contain
104
146
> [!IMPORTANT]
105
147
> Before starting your debug session, make sure that the VS Code extensions have finished installing in your dev container.
106
148
149
+
150
+
# [Python](#tab/python)
151
+
152
+
Azure Machine Learning local endpoints use Docker and VS Code development containers (dev container) to build and configure a local debugging environment. With dev containers, you can take advantage of VS Code features from inside a Docker container. For more information on dev containers, see [Create a development container](https://code.visualstudio.com/docs/remote/create-dev-container).
153
+
154
+
Import the required modules:
155
+
156
+
```python
157
+
from azure.ai.ml import MLClient
158
+
from azure.ai.ml.entities import (
159
+
ManagedOnlineEndpoint,
160
+
ManagedOnlineDeployment,
161
+
Model,
162
+
CodeConfiguration,
163
+
Environment,
164
+
)
165
+
from azure.identity import DefaultAzureCredential, AzureCliCredential
166
+
```
167
+
168
+
Set up variables for the workspace and endpoint:
169
+
170
+
```python
171
+
subscription_id ="<SUBSCRIPTION_ID>"
172
+
resource_group ="<RESOURCE_GROUP>"
173
+
workspace_name ="<AML_WORKSPACE_NAME>"
174
+
175
+
endpoint_name ="<ENDPOINT_NAME>"
176
+
```
177
+
178
+
Get a handle to the workspace:
179
+
180
+
```python
181
+
182
+
credential = AzureCliCredential()
183
+
ml_client = MLClient(
184
+
credential,
185
+
subscription_id=subscription_id,
186
+
resource_group_name=resource_group,
187
+
workspace_name=workspace_name,
188
+
)
189
+
190
+
```
191
+
192
+
To debug online endpoints locally in VS Code, set the `vscode-debug` and `local` flags when creating or updating an Azure Machine Learning online deployment. The following code mirrors a deployment example from the examples repo:
> On Windows Subsystem for Linux (WSL), you'll need to update your PATH environment variable to include the path to the VS Code executable or use WSL interop. For more information, see [Windows interoperability with Linux](/windows/wsl/interop).
221
+
222
+
A Docker image is built locally. Any environment configuration or model file errors are surfaced at this stage of the process.
223
+
224
+
> [!NOTE]
225
+
> The first time you launch a new or updated dev container it can take several minutes.
226
+
227
+
Once the image successfully builds, your dev container opens in a VS Code window.
228
+
229
+
You'll use a few VS Code extensions to debug your deployments in the dev container. Azure Machine Learning automatically installs these extensions in your dev container.
> Before starting your debug session, make sure that the VS Code extensions have finished installing in your dev container.
238
+
239
+
---
240
+
241
+
242
+
243
+
---
244
+
107
245
## Start debug session
108
246
109
247
Once your environment is set up, use the VS Code debugger to test and debug your deployment locally.
@@ -136,6 +274,8 @@ For more information on the VS Code debugger, see [Debugging in VS Code](https:/
136
274
137
275
## Debug your endpoint
138
276
277
+
# [Portal](#tab/azure-portal)
278
+
139
279
Now that your application is running in the debugger, try making a prediction to debug your scoring script.
140
280
141
281
Use the `ml` extension `invoke` command to make a request to your local endpoint.
@@ -180,8 +320,68 @@ In this case, `<REQUEST-FILE>` is a JSON file that contains input data samples f
180
320
181
321
At this point, any breakpoints in your `run` function are caught. Use the debug actions to step through your code. For more information on debug actions, see the [debug actions guide](https://code.visualstudio.com/Docs/editor/debugging#_debug-actions).
182
322
323
+
324
+
# [Python](#tab/python)
325
+
326
+
Now that your application is running in the debugger, try making a prediction to debug your scoring script.
327
+
328
+
Use the`invoke` method on your `MLClient` object to make a request to your local endpoint.
In this case, `<REQUEST-FILE>` is a JSON file that contains input data samples for the model to make predictions on similar to the following JSON:
341
+
342
+
```json
343
+
{"data": [
344
+
[1,2,3,4,5,6,7,8,9,10],
345
+
[10,9,8,7,6,5,4,3,2,1]
346
+
]}
347
+
```
348
+
349
+
> [!TIP]
350
+
> The scoring URI is the address where your endpoint listens for requests. The `as_dict` method of endpoint objects returns information similar to `show` in the Azure CLI. The endpoint object can be obtained through `.get`.
> The output should look similar to the following:
358
+
>
359
+
>```json
360
+
> {
361
+
>"auth_mode": "aml_token",
362
+
>"location": "local",
363
+
>"name": "my-new-endpoint",
364
+
>"properties": {},
365
+
>"provisioning_state": "Succeeded",
366
+
>"scoring_uri": "http://localhost:5001/score",
367
+
>"tags": {},
368
+
>"traffic": {},
369
+
>"type": "online"
370
+
>}
371
+
>```
372
+
>
373
+
>The scoring URI can be found in the `scoring_uri` key.
374
+
375
+
At this point, any breakpoints in your `run` function are caught. Use the debug actions to step through your code. For more information on debug actions, see the [debug actions guide](https://code.visualstudio.com/Docs/editor/debugging#_debug-actions).
376
+
377
+
378
+
---
379
+
380
+
183
381
## Edit your endpoint
184
382
383
+
# [Portal](#tab/azure-portal)
384
+
185
385
As you debug and troubleshoot your application, there are scenarios where you need to update your scoring script and configurations.
186
386
187
387
To apply changes to your code:
@@ -200,6 +400,47 @@ az ml online-deployment update --file <DEPLOYMENT-YAML-SPECIFICATION-FILE> --loc
200
400
201
401
Once the updated image is built and your development container launches, use the VS Code debugger to test and troubleshoot your updated endpoint.
202
402
403
+
# [Python](#tab/python)
404
+
405
+
As you debug and troubleshoot your application, there are scenarios where you need to update your scoring script and configurations.
406
+
407
+
To apply changes to your code:
408
+
409
+
1. Update your code
410
+
1. Restart your debug session using the `Developer: Reload Window` command in the command palette. For more information, see the [command palette documentation](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette).
411
+
412
+
> [!NOTE]
413
+
> Since the directory containing your code and endpoint assets is mounted onto the dev container, any changes you make in the dev container are synced with your local file system.
414
+
415
+
For more extensive changes involving updates to your environment and endpoint configuration, use the `ml` extension `update` command. Doing so will trigger a full image rebuild with your changes.
0 commit comments