#!/bin/bash set -e # export ENDPOINT_NAME="" export ACR_NAME="" # export ENDPOINT_NAME=endpt-moe-`echo $RANDOM` export ACR_NAME=$(az ml workspace show --query container_registry -o tsv | cut -d'/' -f9-) export BASE_PATH=endpoints/online/custom-container/minimal/single-model export ASSET_PATH=endpoints/online/model-1 # Helper function to change parameters in yaml files change_vars() { for FILE in "$@"; do TMP="${FILE}_" cp $FILE $TMP readarray -t VARS < <(cat $TMP | grep -oP '{{.*?}}' | sed -e 's/[}{]//g'); for VAR in "${VARS[@]}"; do sed -i "s/{{${VAR}}}/${!VAR}/g" $TMP done done } # change_vars $BASE_PATH/minimal-single-model-endpoint.yml az ml online-endpoint create -f $BASE_PATH/minimal-single-model-endpoint.yml_ # rm $BASE_PATH/minimal-single-model-endpoint.yml_ # Get key and url echo "Getting access key and scoring URL..." KEY=$(az ml online-endpoint get-credentials -n $ENDPOINT_NAME --query primaryKey -o tsv) SCORING_URL=$(az ml online-endpoint show -n $ENDPOINT_NAME --query scoring_uri -o tsv) echo "Scoring url is $SCORING_URL" # az acr build -f $BASE_PATH/pip-in-dockerfile/minimal-single-model-pip-in-dockerfile.dockerfile -t azureml-examples/minimal-single-model-pip-in-dockerfile:1 -r $ACR_NAME $ASSET_PATH # # DEPLOYMENT_YML=$BASE_PATH/pip-in-dockerfile/minimal-single-model-pip-in-dockerfile-deployment.yml change_vars $DEPLOYMENT_YML az ml online-deployment create --endpoint-name $ENDPOINT_NAME -f "${DEPLOYMENT_YML}_" --all-traffic # # curl -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" -d @$ASSET_PATH/sample-request.json $SCORING_URL # rm $BASE_PATH/pip-in-dockerfile/*.yml_ # az acr build -f $BASE_PATH/conda-in-dockerfile/minimal-single-model-conda-in-dockerfile.dockerfile -t azureml-examples/minimal-single-model-conda-in-dockerfile:1 -r $ACR_NAME $ASSET_PATH # # DEPLOYMENT_YML=$BASE_PATH/conda-in-dockerfile/minimal-single-model-conda-in-dockerfile-deployment.yml change_vars $DEPLOYMENT_YML az ml online-deployment create --endpoint-name $ENDPOINT_NAME -f "${DEPLOYMENT_YML}_" --all-traffic # # curl -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" -d @$ASSET_PATH/sample-request.json $SCORING_URL # rm $BASE_PATH/conda-in-dockerfile/*.yml_ # az ml online-endpoint delete -y -n $ENDPOINT_NAME #