@@ -329,9 +329,12 @@ So far, the endpoint is empty. There are no deployments on it. Let's create the
329
329
# [Azure CLI](#tab/cli)
330
330
331
331
```azurecli
332
- az ml online-deployment create --endpoint-name $ENDPOINT_NAME -f blue-deployment.yml
332
+ az ml online-deployment create --endpoint-name $ENDPOINT_NAME -f blue-deployment.yml --all-traffic
333
333
```
334
334
335
+ > [!TIP]
336
+ > We set the flag `--all-traffic` in the create command, which will assign all the traffic to the new deployment.
337
+
335
338
# [Python (Azure ML SDK)](#tab/sdk)
336
339
337
340
```python
@@ -349,6 +352,57 @@ So far, the endpoint is empty. There are no deployments on it. Let's create the
349
352
)
350
353
```
351
354
355
+ 1. Assign all the traffic to the deployment
356
+
357
+ So far, the endpoint has one deployment, but none of its traffic is assigned to it. Let's assign it.
358
+
359
+ # [Azure CLI](#tab/cli)
360
+
361
+ *This step in not required in the Azure CLI since we used the `--all-traffic` during creation.*
362
+
363
+ # [Python (Azure ML SDK)](#tab/sdk)
364
+
365
+ ```python
366
+ endpoint.traffic = { blue_deployment_name: 100 }
367
+ ```
368
+
369
+ # [Python (MLflow SDK)](#tab/mlflow)
370
+
371
+ ```python
372
+ traffic_config = {"traffic": {blue_deployment_name: 100}}
373
+ ```
374
+
375
+ Write the configuration to a file:
376
+
377
+ ```python
378
+ traffic_config_path = "traffic_config.json"
379
+ with open(traffic_config_path, "w") as outfile:
380
+ outfile.write(json.dumps(traffic_config))
381
+ ```
382
+
383
+ 1. Update the endpoint configuration:
384
+
385
+ # [Azure CLI](#tab/cli)
386
+
387
+ ```azurecli
388
+ *This step in not required in the Azure CLI since we used the `--all-traffic` during creation.*
389
+ ```
390
+
391
+ # [Python (Azure ML SDK)](#tab/sdk)
392
+
393
+ ```python
394
+ ml_client.begin_create_or_update(endpoint).result()
395
+ ```
396
+
397
+ # [Python (MLflow SDK)](#tab/mlflow)
398
+
399
+ ```python
400
+ deployment_client.update_endpoint(
401
+ endpoint=endpoint_name,
402
+ config={"endpoint-config-file": traffic_config_path},
403
+ )
404
+ ```
405
+
352
406
1. Create a sample input to test the deployment
353
407
354
408
# [Azure CLI](#tab/cli)
@@ -446,7 +500,6 @@ So far, the endpoint is empty. There are no deployments on it. Let's create the
446
500
headers = {
447
501
'Content-Type':'application/json',
448
502
'Authorization':('Bearer '+ endpoint_secret_key),
449
- 'azureml-model-deployment': 'default'
450
503
}
451
504
```
452
505
0 commit comments