@@ -109,7 +109,7 @@ from azure.ai.ml.entities import (
109
109
CodeConfiguration,
110
110
Environment,
111
111
)
112
- from azure.identity import DefaultAzureCredential, AzureCliCredential
112
+ from azure.identity import DefaultAzureCredential
113
113
```
114
114
115
115
Set up variables for the workspace and endpoint:
@@ -164,7 +164,7 @@ Azure Machine Learning local endpoints use Docker and VS Code development contai
164
164
Get a handle to the workspace:
165
165
166
166
``` python
167
- credential = AzureCliCredential ()
167
+ credential = DefaultAzureCredential ()
168
168
ml_client = MLClient(
169
169
credential,
170
170
subscription_id = subscription_id,
@@ -179,7 +179,7 @@ To debug online endpoints locally in VS Code, set the `vscode-debug` and `local`
179
179
deployment = ManagedOnlineDeployment(
180
180
name = " blue" ,
181
181
endpoint_name = endpoint_name,
182
- model = Model(path = " ../model-1/model" ),
182
+ model = Model(path = " ../model-1/model/sklearn_regression_model.pkl " ),
183
183
code_configuration = CodeConfiguration(
184
184
code = " ../model-1/onlinescoring" , scoring_script = " score.py"
185
185
),
@@ -192,9 +192,7 @@ deployment = ManagedOnlineDeployment(
192
192
)
193
193
194
194
deployment = ml_client.online_deployments.begin_create_or_update(
195
- deployment,
196
- local = True ,
197
- vscode_debug = True ,
195
+ deployment, local = True , vscode_debug = True
198
196
)
199
197
```
200
198
@@ -314,7 +312,7 @@ endpoint = ml_client.online_endpoints.get(name=endpoint_name, local=True)
314
312
315
313
request_file_path = "../model-1/sample-request.json"
316
314
317
- endpoint .invoke(endpoint_name, request_file_path, local=True)
315
+ ml_client.online_endpoints .invoke(endpoint_name, request_file_path, local=True)
318
316
```
319
317
320
318
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:
@@ -330,8 +328,7 @@ In this case, `<REQUEST-FILE>` is a JSON file that contains input data samples f
330
328
> 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 ` .
331
329
>
332
330
> ``` python
333
- > endpoint = ml_client.online_endpoints.get(endpoint_name, local = True )
334
- > endpoint.as_dict()
331
+ > print (endpoint)
335
332
> ```
336
333
>
337
334
> The output should look similar to the following:
@@ -398,7 +395,7 @@ For more extensive changes involving updates to your environment and endpoint co
398
395
new_deployment = ManagedOnlineDeployment(
399
396
name = " green" ,
400
397
endpoint_name = endpoint_name,
401
- model = Model(path = " ../model-2/model" ),
398
+ model = Model(path = " ../model-2/model/sklearn_regression_model.pkl " ),
402
399
code_configuration = CodeConfiguration(
403
400
code = " ../model-2/onlinescoring" , scoring_script = " score.py"
404
401
),
@@ -410,7 +407,9 @@ new_deployment = ManagedOnlineDeployment(
410
407
instance_count = 2 ,
411
408
)
412
409
413
- ml_client.online_deployments.update(new_deployment, local = True , vscode_debug = True )
410
+ deployment = ml_client.online_deployments.begin_create_or_update(
411
+ new_deployment, local = True , vscode_debug = True
412
+ )
414
413
```
415
414
416
415
Once the updated image is built and your development container launches, use the VS Code debugger to test and troubleshoot your updated endpoint.
0 commit comments