Transform Machine Learning Research into a Professional Product with Azure

Published 05-11-2021 12:12 AM 863 Views
Microsoft

Guest post by Lucas Liu Master’s student in Electrical & Computer Engineering at Duke University who specializes in Machine Learning & Federated Learning.

LUCAS.jpg 

Throughout my time at university, I have built any number of scikit-learn, Tensorflow, or PyTorch machine learning models. I have developed and trained deep neural networks for applications ranging from cheetah footprint image classification to content similarity matching for bug tracking.

 

Many of these research projects have wound up more or less as Python scripts sitting on my PC, only existing locally. If a colleague or client wanted to use the product for themselves, this would involve a complicated series of file downloads, installation steps, dependency management, and more – a painful process even for researchers who are intimately knowledgeable with the technologies being used.

How can we eliminate this barrier between our research and our users? Microsoft Azure can help us transform machine learning research into a refined & easy-to-use product.

 

Containerize

First, we containerize our research with Docker. We take our ML model and package it into a simple flask app that serves predictions from POST requests with json payloads routed to `/predict`.

 

Here is an example Flask setup which predicts the probability of stroke with a scikit-learn ML model:

 

from flask import Flask, request
from flask.logging import create_logger
import logging

import pandas as pd
import joblib

app = Flask(__name__)
LOG = create_logger(app)
LOG.setLevel(logging.INFO)

@app.route("/")
def home():
    html = "<h3>Stroke Prediction Home</h3>"
    return html.format(format)

@app.route("/predict", methods=['POST'])
def predict():
    """Performs an sklearn prediction for stroke likelihood"""
    json_payload = request.json
    LOG.info(f"JSON payload: {json_payload}")
    inference_payload = pd.DataFrame(json_payload)
    LOG.info(f"inference payload DataFrame: {inference_payload}")
    prediction = clf.predict_proba(inference_payload)[0][0]

    statement = f'Probability of patient stroke is {prediction: .4f}'
    return statement

if __name__ == "__main__":
    clf = joblib.load("stroke_prediction.joblib")
    app.run(host='0.0.0.0', port=8080, debug=True)

We then specify a Dockerfile configuration, which will handle requirements installation and run our Flask app. We will expose our container on port 80, and use Python slim, which is more lightweight.


A simple Docker configuration might look like this:

 

FROM python:3.8-slim

# Working Directory
WORKDIR /app
# Copy source code to working directory
COPY . app.py /app/

# Install packages from requirements.txt
RUN pip install --no-cache-dir --upgrade pip &&\
    pip install --no-cache-dir --trusted-host pypi.python.org -r requirements.txt

# Expose port 80
EXPOSE 80

# Run app.py at container launch
CMD ["python", "app.py"]

 

 

Next, we will upload our container to the Azure Container Registry by using the Azure CLI. Let’s call our project ‘mlproject’.

  1. Create a resource group name ‘mlproject’ in the Azure Dashboard.
  2. Create an ACR repository with the command: 

 

az acr create --resource-group mlproject --name mlproject –sku\ Basic --admin-enabled true

 

 

  1. Build the container in ACR (let’s call our container image ‘stroke-predict’:

 

az acr build --registry mlproject --image stroke-predict .

 

 

Now, users can more easily access our ML model by quickly pulling, building, and running our image, without having to worry about dependencies or model running details. This helps us avoid the age old “But it runs on my machine!” problem.

 

ACR.png

Deploy & Operationalize

What if, instead of building a container image, users could simply hit a URL and perform inferences (no image setup required)? Let’s use Azure Kubernetes Service to serve our container at a ready-to-go endpoint:

  1. First, we can use an Azure Pipeline Template to help us define a k8s deployment and load balancer YAML.

 

Example deployment YAML:

 

 

apiVersion: apps/v1
kind: Deployment
metadata:
  name: stroke-predict
spec:
  selector:
      matchLabels:
        app: stroke-predict
  replicas: 3
  template:
      metadata:
        labels:
            app: stroke-predict
      spec:
        containers:
        - name: stroke-predict
          image: mlproject.azurecr.io/stroke-predict
          imagePullPolicy: Always
          readinessProbe:
            httpGet:
              port: 8080
              path: /
          livenessProbe:
            httpGet:
              port: 8080
              path: /
          resources:
            requests:
              memory: "128Mi"
              cpu: "100m"
            limits:
              memory: "256Mi"
              cpu: "500m"

 

 

Example loadbalancer YAML:

 

 

apiVersion: v1
kind: Service
metadata:
  name: stroke-predict-loadbalancer
spec:
  type: LoadBalancer
  selector:
    app: stroke-predict
  ports:
  - protocol: TCP
    port: 80
    targetPort: 8080

 

 

 

  1. Now, we create an AKS cluster. This example cluster will have a load balancer, and the ability to autoscale between 1 and 5 nodes.

 

az aks create --resource-group mlproject --name mlproject \
--generate-ssh-keys \
--node-count 3 \
--vm-set-type VirtualMachineScaleSets \
--load-balancer-sku standard \
--enable-cluster-autoscaler \
--min-count 1 \
--max-count 5

 

 

 

  1. Next, Merge AKS credentials between kubectl and your AKS cluster

 

az aks get-credentials --resource-group mlproject --name mlproject

 

 

 

  1. Attach our repository to the cluster

 

az aks update --resource-group mlproject --name mlproject \--attach-acr mlproject

 

 

 

  1. Deploy Application on Cluster

 

kubectl apply -f k8s/deployment.yaml

 

 

 

  1. Apply Load Balancer

 

kubectl apply -f k8s/loadbalancer.yaml

 

 

 

  1. Find IP for Endpoint

 

kubectl get services

 

 

 

Now our users can simply query our endpoint and receive predictions!

 

The power of Azure goes beyond just initial deployment. We can adopt Continuous Deployment practices with Github Actions for Azure to automatically trigger a new build each time a new version of the model is released, ensuring that the service endpoint is always providing the most up-to-date model.

 

Additionally, Azure’s autoscale feature allows our service to automatically scale up or down to meet real usage needs, activating additional resources during heavy usage time. We can even expand our AKS to reach users around the world. The Azure portal also allows us to monitor our AKS cluster metrics, and gain insights on the health and performance of the service.

 

AutoScale.png

 

Next Steps: MLOps

In this blog, we discuss how to transform your existing ML research models into a much more refined product with Azure’s Container Registry and Kubernetes Service, making it easy for users to access the fruits of your research.

 

However, if we start building with Azure from the very beginning, Azure’s MLOps offering provides an end-to-end solution for the ML life-cycle, from training and building the model initially, to continually retraining / redeploying an up-to-date service. Azure MLOps can even help us compare model performances & automatically detect data drift. This is just a small portion of what Azure’s MLOps can do –

Learn more about Azure MLOps here.

 

MLOPs.png

 

 

%3CLINGO-SUB%20id%3D%22lingo-sub-2342330%22%20slang%3D%22en-US%22%3ETransform%20Machine%20Learning%20Research%20into%20a%20Professional%20Product%20with%20Azure%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2342330%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3EGuest%20post%20by%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fwww.linkedin.com%2Fin%2Flucas-t-liu%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3ELucas%20Liu%3C%2FA%3E%20Master%E2%80%99s%20student%20in%20Electrical%20%26amp%3B%20Computer%20Engineering%20at%20Duke%20University%20who%20specializes%20in%20Machine%20Learning%20%26amp%3B%20Federated%20Learning.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22LUCAS.jpg%22%20style%3D%22width%3A%20200px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F279607i31E6103C4E8FFFF5%2Fimage-size%2Fsmall%3Fv%3Dv2%26amp%3Bpx%3D200%22%20role%3D%22button%22%20title%3D%22LUCAS.jpg%22%20alt%3D%22LUCAS.jpg%22%20%2F%3E%3C%2FSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EThroughout%20my%20time%20at%20university%2C%20I%20have%20built%20any%20number%20of%20scikit-learn%2C%20Tensorflow%2C%20or%20PyTorch%20machine%20learning%20models.%20I%20have%20developed%20and%20trained%20deep%20neural%20networks%20for%20applications%20ranging%20from%20cheetah%20footprint%20image%20classification%20to%20content%20similarity%20matching%20for%20bug%20tracking.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EMany%20of%20these%20research%20projects%20have%20wound%20up%20more%20or%20less%20as%20Python%20scripts%20sitting%20on%20my%20PC%2C%20only%20existing%20locally.%20If%20a%20colleague%20or%20client%20wanted%20to%20use%20the%20product%20for%20themselves%2C%20this%20would%20involve%20a%20complicated%20series%20of%20file%20downloads%2C%20installation%20steps%2C%20dependency%20management%2C%20and%20more%20%E2%80%93%20a%20painful%20process%20even%20for%20researchers%20who%20are%20intimately%20knowledgeable%20with%20the%20technologies%20being%20used.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EHow%20can%20we%20eliminate%20this%20barrier%20between%20our%20research%20and%20our%20users%3F%20Microsoft%20Azure%20can%20help%20us%20transform%20machine%20learning%20research%20into%20a%20refined%20%26amp%3B%20easy-to-use%20product.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--467947759%22%20id%3D%22toc-hId--467947759%22%3E%3CSTRONG%3EContainerize%3C%2FSTRONG%3E%3C%2FH2%3E%0A%3CP%3E%3CSPAN%3EFirst%2C%20we%20%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Foverview%2Fwhat-is-a-container%2F%3FWT.mc_ID%3Dsql-27904-leestott%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Econtainerize%3C%2FA%3E%20our%20research%20with%20%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fservices%2Fkubernetes-service%2Fdocker%2F%3FWT.mc_ID%3Dsql-27904-leestott%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EDocker%3C%2FA%3E.%20We%20take%20our%20ML%20model%20and%20package%20it%20into%20a%20simple%20flask%20app%20that%20serves%20predictions%20from%20POST%20requests%20with%20json%20payloads%20routed%20to%20%60%2Fpredict%60.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EHere%20is%20an%20example%20Flask%20setup%20which%20predicts%20the%20probability%20of%20stroke%20with%20a%20scikit-learn%20ML%20model%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-python%22%3E%3CCODE%3Efrom%20flask%20import%20Flask%2C%20request%0Afrom%20flask.logging%20import%20create_logger%0Aimport%20logging%0A%0Aimport%20pandas%20as%20pd%0Aimport%20joblib%0A%0Aapp%20%3D%20Flask(__name__)%0ALOG%20%3D%20create_logger(app)%0ALOG.setLevel(logging.INFO)%0A%0A%40app.route(%22%2F%22)%0Adef%20home()%3A%0A%20%20%20%20html%20%3D%20%22%3CH3%20id%3D%22toc-hId-222613715%22%3EStroke%20Prediction%20Home%3C%2FH3%3E%22%0A%20%20%20%20return%20html.format(format)%0A%0A%40app.route(%22%2Fpredict%22%2C%20methods%3D%5B'POST'%5D)%0Adef%20predict()%3A%0A%20%20%20%20%22%22%22Performs%20an%20sklearn%20prediction%20for%20stroke%20likelihood%22%22%22%0A%20%20%20%20json_payload%20%3D%20request.json%0A%20%20%20%20LOG.info(f%22JSON%20payload%3A%20%7Bjson_payload%7D%22)%0A%20%20%20%20inference_payload%20%3D%20pd.DataFrame(json_payload)%0A%20%20%20%20LOG.info(f%22inference%20payload%20DataFrame%3A%20%7Binference_payload%7D%22)%0A%20%20%20%20prediction%20%3D%20clf.predict_proba(inference_payload)%5B0%5D%5B0%5D%0A%0A%20%20%20%20statement%20%3D%20f'Probability%20of%20patient%20stroke%20is%20%7Bprediction%3A%20.4f%7D'%0A%20%20%20%20return%20statement%0A%0Aif%20__name__%20%3D%3D%20%22__main__%22%3A%0A%20%20%20%20clf%20%3D%20joblib.load(%22stroke_prediction.joblib%22)%0A%20%20%20%20app.run(host%3D'0.0.0.0'%2C%20port%3D8080%2C%20debug%3DTrue)%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%3CSPAN%3EWe%20then%20specify%20a%20Dockerfile%20configuration%2C%20which%20will%20handle%20requirements%20installation%20and%20run%20our%20Flask%20app.%20We%20will%20expose%20our%20container%20on%20port%2080%2C%20and%20use%20Python%20slim%2C%20which%20is%20more%20lightweight.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CBR%20%2F%3EA%20simple%20Docker%20configuration%20might%20look%20like%20this%3A%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-yaml%22%3E%3CCODE%3EFROM%20python%3A3.8-slim%0A%0A%23%20Working%20Directory%0AWORKDIR%20%2Fapp%0A%23%20Copy%20source%20code%20to%20working%20directory%0ACOPY%20.%20app.py%20%2Fapp%2F%0A%0A%23%20Install%20packages%20from%20requirements.txt%0ARUN%20pip%20install%20--no-cache-dir%20--upgrade%20pip%20%26amp%3B%26amp%3B%5C%0A%20%20%20%20pip%20install%20--no-cache-dir%20--trusted-host%20pypi.python.org%20-r%20requirements.txt%0A%0A%23%20Expose%20port%2080%0AEXPOSE%2080%0A%0A%23%20Run%20app.py%20at%20container%20launch%0ACMD%20%5B%22python%22%2C%20%22app.py%22%5D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ENext%2C%20we%20will%20upload%20our%20container%20to%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fcontainer-registry%2F%3FWT.mc_ID%3Dsql-27904-leestott%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20Container%20Registry%3C%2FA%3E%20by%20using%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fcli%2Fazure%2F%3FWT.mc_ID%3Dsql-27904-leestott%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20CLI%3C%2FA%3E.%20Let%E2%80%99s%20call%20our%20project%20%E2%80%98mlproject%E2%80%99.%20%3C%2FSPAN%3E%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3E%3CSPAN%3ECreate%20a%20resource%20group%20name%20%E2%80%98mlproject%E2%80%99%20in%20the%20Azure%20Dashboard.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3ECreate%20an%20ACR%20repository%20with%20the%20command%3A%3C%2FSPAN%3E%26nbsp%3B%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3Eaz%20acr%20create%20--resource-group%20mlproject%20--name%20mlproject%20%E2%80%93sku%5C%20Basic%20--admin-enabled%20true%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%20start%3D%223%22%3E%0A%3CLI%3EBuild%20the%20container%20in%20ACR%20(let%E2%80%99s%20call%20our%20container%20image%20%E2%80%98stroke-predict%E2%80%99%3A%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3Eaz%20acr%20build%20--registry%20mlproject%20--image%20stroke-predict%20.%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ENow%2C%20users%20can%20more%20easily%20access%20our%20ML%20model%20by%20quickly%20pulling%2C%20building%2C%20and%20running%20our%20image%2C%20without%20having%20to%20worry%20about%20dependencies%20or%20model%20running%20details.%20This%20helps%20us%20avoid%20the%20age%20old%20%E2%80%9CBut%20it%20runs%20on%20my%20machine!%E2%80%9D%20problem.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22ACR.png%22%20style%3D%22width%3A%20322px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F279611iF413AA9348AC7A05%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22ACR.png%22%20alt%3D%22ACR.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-2019565074%22%20id%3D%22toc-hId-212110611%22%3E%3CSTRONG%3EDeploy%20%26amp%3B%20Operationalize%3C%2FSTRONG%3E%3C%2FH2%3E%0A%3CP%3E%3CSPAN%3EWhat%20if%2C%20instead%20of%20building%20a%20container%20image%2C%20users%20could%20simply%20hit%20a%20URL%20and%20perform%20inferences%20(no%20image%20setup%20required)%3F%20Let%E2%80%99s%20use%20%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fservices%2Fkubernetes-service%2F%3FWT.mc_ID%3Dsql-27904-leestott%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20Kubernetes%20Service%3C%2FA%3E%20to%20serve%20our%20container%20at%20a%20ready-to-go%20endpoint%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3E%3CSPAN%3EFirst%2C%20we%20can%20use%20an%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fdevops%2Fpipelines%2Fecosystems%2Fkubernetes%2Faks-template%3Fview%3Dazure-devops%23how-we-build-your-pipeline%3FWT.mc_ID%3Dsql-27904-leestott%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20Pipeline%20Template%3C%2FA%3E%20to%20help%20us%20define%20a%20k8s%20deployment%20and%20load%20balancer%20YAML.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EExample%20deployment%20YAML%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-yaml%22%3E%3CCODE%3EapiVersion%3A%20apps%2Fv1%0Akind%3A%20Deployment%0Ametadata%3A%0A%20%20name%3A%20stroke-predict%0Aspec%3A%0A%20%20selector%3A%0A%20%20%20%20%20%20matchLabels%3A%0A%20%20%20%20%20%20%20%20app%3A%20stroke-predict%0A%20%20replicas%3A%203%0A%20%20template%3A%0A%20%20%20%20%20%20metadata%3A%0A%20%20%20%20%20%20%20%20labels%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20app%3A%20stroke-predict%0A%20%20%20%20%20%20spec%3A%0A%20%20%20%20%20%20%20%20containers%3A%0A%20%20%20%20%20%20%20%20-%20name%3A%20stroke-predict%0A%20%20%20%20%20%20%20%20%20%20image%3A%20mlproject.azurecr.io%2Fstroke-predict%0A%20%20%20%20%20%20%20%20%20%20imagePullPolicy%3A%20Always%0A%20%20%20%20%20%20%20%20%20%20readinessProbe%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20httpGet%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20port%3A%208080%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20path%3A%20%2F%0A%20%20%20%20%20%20%20%20%20%20livenessProbe%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20httpGet%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20port%3A%208080%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20path%3A%20%2F%0A%20%20%20%20%20%20%20%20%20%20resources%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20requests%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20memory%3A%20%22128Mi%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20cpu%3A%20%22100m%22%0A%20%20%20%20%20%20%20%20%20%20%20%20limits%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20memory%3A%20%22256Mi%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20cpu%3A%20%22500m%22%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EExample%20loadbalancer%20YAML%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-yaml%22%3E%3CCODE%3EapiVersion%3A%20v1%0Akind%3A%20Service%0Ametadata%3A%0A%20%20name%3A%20stroke-predict-loadbalancer%0Aspec%3A%0A%20%20type%3A%20LoadBalancer%0A%20%20selector%3A%0A%20%20%20%20app%3A%20stroke-predict%0A%20%20ports%3A%0A%20%20-%20protocol%3A%20TCP%0A%20%20%20%20port%3A%2080%0A%20%20%20%20targetPort%3A%208080%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3COL%20start%3D%222%22%3E%0A%3CLI%3E%3CSPAN%3ENow%2C%20we%20create%20an%20AKS%20cluster.%20This%20example%20cluster%20will%20have%20a%20load%20balancer%2C%20and%20the%20ability%20to%20autoscale%20between%201%20and%205%20nodes.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3Eaz%20aks%20create%20--resource-group%20mlproject%20--name%20mlproject%20%5C%0A--generate-ssh-keys%20%5C%0A--node-count%203%20%5C%0A--vm-set-type%20VirtualMachineScaleSets%20%5C%0A--load-balancer-sku%20standard%20%5C%0A--enable-cluster-autoscaler%20%5C%0A--min-count%201%20%5C%0A--max-count%205%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%20start%3D%223%22%3E%0A%3CLI%3E%3CSPAN%3ENext%2C%20Merge%20AKS%20credentials%20between%20kubectl%20and%20your%20AKS%20cluster%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3Eaz%20aks%20get-credentials%20--resource-group%20mlproject%20--name%20mlproject%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3COL%20start%3D%224%22%3E%0A%3CLI%3E%3CSPAN%3EAttach%20our%20repository%20to%20the%20cluster%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3Eaz%20aks%20update%20--resource-group%20mlproject%20--name%20mlproject%20%5C--attach-acr%20mlproject%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%20start%3D%225%22%3E%0A%3CLI%3E%3CSPAN%3EDeploy%20Application%20on%20Cluster%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3Ekubectl%20apply%20-f%20k8s%2Fdeployment.yaml%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3COL%20start%3D%226%22%3E%0A%3CLI%3E%3CSPAN%3EApply%20Load%20Balancer%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3Ekubectl%20apply%20-f%20k8s%2Floadbalancer.yaml%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3COL%20start%3D%227%22%3E%0A%3CLI%3E%3CSPAN%3EFind%20IP%20for%20Endpoint%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3Ekubectl%20get%20services%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ENow%20our%20users%20can%20simply%20query%20our%20endpoint%20and%20receive%20predictions!%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EThe%20power%20of%20Azure%20goes%20beyond%20just%20initial%20deployment.%20We%20can%20adopt%20Continuous%20Deployment%20practices%20with%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2Factions%2F%3FWT.mc_ID%3Dsql-27904-leestott%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EGithub%20Actions%20for%20Azure%3C%2FA%3E%20to%20automatically%20trigger%20a%20new%20build%20each%20time%20a%20new%20version%20of%20the%20model%20is%20released%2C%20ensuring%20that%20the%20service%20endpoint%20is%20always%20providing%20the%20most%20up-to-date%20model.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EAdditionally%2C%20Azure%E2%80%99s%20autoscale%20feature%20allows%20our%20service%20to%20automatically%20scale%20up%20or%20down%20to%20meet%20real%20usage%20needs%2C%20activating%20additional%20resources%20during%20heavy%20usage%20time.%20We%20can%20even%20expand%20our%20AKS%20to%20reach%20users%20around%20the%20world.%20The%20Azure%20portal%20also%20allows%20us%20to%20monitor%20our%20AKS%20cluster%20metrics%2C%20and%20gain%20insights%20on%20the%20health%20and%20performance%20of%20the%20service.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorLee%20Stott_0%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22AutoScale.png%22%20style%3D%22width%3A%20936px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F279609i5BF159A2268B5A3D%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22AutoScale.png%22%20alt%3D%22AutoScale.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-212110611%22%20id%3D%22toc-hId--1595343852%22%3E%3CSTRONG%3ENext%20Steps%3A%20MLOps%20%3C%2FSTRONG%3E%3C%2FH2%3E%0A%3CP%3E%3CSPAN%3EIn%20this%20blog%2C%20we%20discuss%20how%20to%20transform%20your%20existing%20ML%20research%20models%20into%20a%20much%20more%20refined%20product%20with%20Azure%E2%80%99s%20Container%20Registry%20and%20Kubernetes%20Service%2C%20making%20it%20easy%20for%20users%20to%20access%20the%20fruits%20of%20your%20research.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EHowever%2C%20if%20we%20start%20building%20with%20Azure%20from%20the%20very%20beginning%2C%20Azure%E2%80%99s%20MLOps%20offering%20provides%20an%20end-to-end%20solution%20for%20the%20ML%20life-cycle%2C%20from%20training%20and%20building%20the%20model%20initially%2C%20to%20continually%20retraining%20%2F%20redeploying%20an%20up-to-date%20service.%20Azure%20MLOps%20can%20even%20help%20us%20compare%20model%20performances%20%26amp%3B%20automatically%20detect%20data%20drift.%20This%20is%20just%20a%20small%20portion%20of%20what%20Azure%E2%80%99s%20MLOps%20can%20do%20%E2%80%93%20%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ELearn%20more%20about%20Azure%20MLOps%20%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fservices%2Fmachine-learning%2Fmlops%2F%3FWT.mc_ID%3Dsql-27904-leestott%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorLee%20Stott_1%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22MLOPs.png%22%20style%3D%22width%3A%20576px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F279610i13542448572743B6%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22MLOPs.png%22%20alt%3D%22MLOPs.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2342330%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3EThroughout%20my%20time%20at%20university%2C%20I%20have%20built%20any%20number%20of%20scikit-learn%2C%20Tensorflow%2C%20or%20PyTorch%20machine%20learning%20models.%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EHowever%2C%20if%20we%20start%20building%20with%20Azure%20from%20the%20very%20beginning%2C%20Azure%E2%80%99s%20MLOps%20offering%20provides%20an%20end-to-end%20solution%20for%20the%20ML%20life-cycle%2C%20from%20training%20and%20building%20the%20model%20initially%2C%20to%20continually%20retraining%20%2F%20redeploying%20an%20up-to-date%20service.%20Azure%20MLOps%20can%20even%20help%20us%20compare%20model%20performances%20%26amp%3B%20automatically%20detect%20data%20drift%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2342330%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EACR%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Eaks%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ELearning%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMachine%20Learning%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMLOps%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Estudent%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Co-Authors
Version history
Last update:
‎May 11 2021 12:12 AM
Updated by: