Skip to content

Commit

Permalink
Add/update for managed online endpoint examples for vnet (#2570)
Browse files Browse the repository at this point in the history
* Create deploy-managed-online-endpoint-workspacevnet.sh

* Rename deploy-moe-vnet-mlflow.sh to deploy-moe-vnet-mlflow-legacy.sh

* Rename deploy-moe-vnet.sh to deploy-moe-vnet-legacy.sh

* rename legacy vnet folder

* rerun readme.py to reflect folder changes

* Revert "rerun readme.py to reflect folder changes"

This reverts commit cf9eedb.

* Revert "rename legacy vnet folder"

This reverts commit 6ede0bf.

* clarify legacy without changing folder name

* add code for possible combinations
  • Loading branch information
dem108 authored Aug 19, 2023
1 parent 96241c3 commit 0e4589b
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 3 deletions.
88 changes: 88 additions & 0 deletions cli/deploy-managed-online-endpoint-workspacevnet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
set -e

export RESOURCEGROUP_NAME="<YOUR_RESOURCEGROUP_NAME>"
export WORKSPACE_NAME="<YOUR_WORKSPACE_NAME>"

# If you want to allow outbound traffic, use below instead.
# <create_workspace_internet_outbound>
# az ml workspace create -g $RESOURCEGROUP_NAME -n $WORKSPACE_NAME -m allow_internet_outbound
# </create_workspace_internet_outbound>

# If you want to block outbound traffic, use below instead.
# <create_workspace_allow_only_approved_outbound>
az ml workspace create -g $RESOURCEGROUP_NAME -n $WORKSPACE_NAME -m allow_only_approved_outbound
# </create_workspace_allow_only_approved_outbound>

az configure --defaults workspace=$WORKSPACE_NAME group=$RESOURCEGROUP_NAME

# <set_endpoint_name>
export ENDPOINT_NAME="<YOUR_ENDPOINT_NAME>"
# </set_endpoint_name>

export ENDPOINT_NAME=endpt-moe-`echo $RANDOM`

# If you want to allow inbound traffic, use below instead.
# <create_endpoint_inbound_allowed>
# az ml online-endpoint create --name $ENDPOINT_NAME -f endpoints/online/managed/sample/endpoint.yml
# </create_endpoint_inbound_allowed>

# If you want to block inbound traffic, use below instead.
# <create_endpoint_inbound_blocked>
az ml online-endpoint create --name $ENDPOINT_NAME -f endpoints/online/managed/sample/endpoint.yml --set public_network_access=disabled
# </create_endpoint_inbound_blocked>

# <create_deployment>
az ml online-deployment create --name blue --endpoint $ENDPOINT_NAME -f endpoints/online/managed/sample/blue-deployment.yml --all-traffic
# </create_deployment>

# <get_status>
az ml online-endpoint show -n $ENDPOINT_NAME
# </get_status>

# check if create was successful
endpoint_status=`az ml online-endpoint show --name $ENDPOINT_NAME --query "provisioning_state" -o tsv`
echo $endpoint_status
if [[ $endpoint_status == "Succeeded" ]]
then
echo "Endpoint created successfully"
else
echo "Endpoint creation failed"
exit 1
fi

deploy_status=`az ml online-deployment show --name blue --endpoint $ENDPOINT_NAME --query "provisioning_state" -o tsv`
echo $deploy_status
if [[ $deploy_status == "Succeeded" ]]
then
echo "Deployment completed successfully"
else
echo "Deployment failed"
exit 1
fi

# <test_endpoint>
az ml online-endpoint invoke --name $ENDPOINT_NAME --request-file endpoints/online/model-1/sample-request.json
# </test_endpoint>

# supress printing secret
set +x

# <test_endpoint_using_curl_get_key>
ENDPOINT_KEY=$(az ml online-endpoint get-credentials -n $ENDPOINT_NAME -o tsv --query primaryKey)
# </test_endpoint_using_curl_get_key>

set -x

# <test_endpoint_using_curl>
SCORING_URI=$(az ml online-endpoint show -n $ENDPOINT_NAME -o tsv --query scoring_uri)

curl --request POST "$SCORING_URI" --header "Authorization: Bearer $ENDPOINT_KEY" --header 'Content-Type: application/json' --data @endpoints/online/model-1/sample-request.json
# </test_endpoint_using_curl>

# <get_logs>
az ml online-deployment get-logs --name blue --endpoint $ENDPOINT_NAME
# </get_logs>

# <delete_endpoint>
az ml online-endpoint delete --name $ENDPOINT_NAME --yes --no-wait
# </delete_endpoint>
4 changes: 2 additions & 2 deletions cli/deploy-moe-vnet.sh → cli/deploy-moe-vnet-legacy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

set -e

# This is now a legacy script that uses the old way of creating a managed vnet endpoint. The new way is to use Workspace Managed VNet. See cli\deploy-managed-online-endpoint-workspacevnet.sh for the new way.
# This is the instructions for docs.User has to execute this from a test VM - that is why user cannot use defaults from their local setup


# <set_env_vars>
export SUBSCRIPTION="<YOUR_SUBSCRIPTION_ID>"
export RESOURCE_GROUP="<YOUR_RESOURCE_GROUP>"
Expand Down Expand Up @@ -107,4 +107,4 @@ az ml online-endpoint delete --name $ENDPOINT_NAME --yes --no-wait
# </delete_endpoint>
# <delete_vm>
az vm delete -n $VM_NAME -y --no-wait
# </delete_vm>
# </delete_vm>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

set -e

# This is now a legacy script that uses the old way of creating a managed vnet endpoint. The new way is to use Workspace Managed VNet. See cli\deploy-managed-online-endpoint-workspacevnet.sh for the new way.
# This is the instructions for docs.User has to execute this from a test VM - that is why user cannot use defaults from their local setup

# <set_env_vars>
Expand Down Expand Up @@ -106,4 +107,4 @@ az ml online-endpoint delete --name $ENDPOINT_NAME --yes --no-wait
# </delete_endpoint>
# <delete_vm>
az vm delete -n $VM_NAME -y --no-wait
# </delete_vm>
# </delete_vm>

0 comments on commit 0e4589b

Please sign in to comment.