jayyanar / blr-azure-mlops-demo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[[TOC]]

Task 1 - Create Azure Subscription

image.png

Click --> Start free

Create New Account or Signup using your Github

image.png

---------- I signed up using GitHub ------------------------------

================ END OF TASK 1 =======================================

Task 2 - Create DevOps Subscription

Azure Portal

Once you signed up - You will be directed to https://portal.azure.com/#home

Create Resource Group

Go to --> https://portal.azure.com/#create/Microsoft.ResourceGroup

Create Resource Group

image.png

Create DevOps Project

  1. Search - DevOps - from the Azure Portal Search**

image.png

  1. Create Organization in Azure DevOps

Go to --> https://dev.azure.com/ --> Select "New Organization"

image.png

  1. Create Project inside the Organization --> Select "New Project"
    • This will create a Repository
    • Wiki
    • Project Board

image.png

Once created you will see below the console

image.png

================ END OF TASK 2 =======================================

Task 3 - Create ML Workspace Manually (Testing)

Create ML Workspace

  1. Search - "Azure Machine Learning - from the Azure Portal Search**

image.png

  1. Click on "Create" - Wait for 5-10 minutes till Workspace get created.

image.png

  1. Open Azure ML Workspace Studio URL

image.png

Explore Azure ML Studio

  • Check Notebooks

  • Data

  • Jobs and Experiements

  • Model

  • Endpoints

  • Compute

  • Data Stores

Create Compute Instance

  • Go to Manage - Compute

image.png

Click Create

Test Data Information

  • Go to Assets --> Data --> Create --> From Local Files

image.png

  • Browse and Select the files from local

image.png

  • You can see the Data Discovered and Preview., Also data schema type

image.png

image.png

  • Enable Checkbox of "Profile the Data Set" and select the Compute created in before steps"

image.png

================ END OF TASK 3 =======================================

Task 4 - Create Service Principal and ML Extension to Azure DevOps

Create Service Connection

image.png or https://dev.azure.com///_settings

  • Click Service Connection. --> New Service Connection --> Select "Azure Resource Manager"

image.png

  • Select "Service Principal (automatic) for Azure DevOps

image.png

  • Select "Subscription" - We need this to be created, In Order for Azure DevOps to create the required resources inside the Resource group.

image.png

  • Select "Service Principal (automatic) for Azure DevOps to Azure ML

  • Select "Machine Learning Workspace " - We need this to be created, In Order for Azure DevOps to create the resources in the Azure Workspace via Azure Pipeline

image.png

Install ML Extension to Azure DevOps Project

  • Install Machine Learning Extention to Azure DevOps Click on the Highlight red one --> Manage Extension --> Browser Market Place

image.png

Select Machine Learning

image.png

================ END OF TASK 4 =======================================

Task 5 - Create ML Workspace via IaaC using Azure DevOps

Create Variables

  • Go to the Azure Projected created in #Task 2
  • Let us create Required Variables in the Library Section Pipeline

image.png

  • Create a Variable group
AZURE_RM_SVC_CONNECTION mlops-demo-azure-devops-service-connection
BASE_NAME mlopsblrws
LOCATION eastus2
RESOURCE_GROUP mlops-demo-blr-resource-group
WORKSPACE_NAME mlops-blr-ws-aml
WORKSPACE_SVC_CONNECTION mlops-aml-service-connection

Create Pipeline

Click on New Pipeline image.png

  • Select "Azure Repos Git"

image.png

  • Select the Repo and Cli

image.png

  • Select "Existing Azure Pipeline YAML File"

image.png

  • Provide the Path of YAML

image.png

  • Run the Pipeline
    image.png

Validate the Results

  • Select the Pipeline and go to the Run and Make sure it is GREEN

image.png

Check the Jobs for Pipeline Run logs

  • Select the recent logs --> go to Jobs and check the Jobs

image.png

================ END OF TASK 5 =======================================

Task 6 - Create ML Pipeline Continuous Integration

  • Follow the same procedure as above to create a Pipeline but select different path for creating MLOps Pipeline

image.png

  • Create a Variables.
Name Value
aml.sp Get the Object ID from DevOps Service Principle
amlcompute.clusterName mldemocluster
amlcompute.idleSecondsBeforeScaledown 300
amlcompute.maxNodes 2
amlcompute.minNodes 0
amlcompute.vmSize STANDARD_DS2_V2
azureml.location eastus2
azureml.resourceGroup mlops-demo-blr-resource-group
azureml.workspaceName mlops-blr-ws-aml
  • Run the Pipeline - It takes 10 Minutes to execute.

  • Select the Run and Click on "Agent Job 1" - and You can see all Tasks in Pipeline succeeded.

image.png

================ END OF TASK 6 =======================================

Task 7 - Create Deployment Pipeline

  • Go to Azure devops project --> Pipelines --> Releases --> Create New Release

image.png

  • You can select the Artifacts from the pipeline created before. - Click Add and Artifact

image.png

  • Add a Stage to perform the deployment - The best practice is to Create a Deployment to staging environment as part of (Stage 2 )and if succeed deploy to Prod.

  • For Demo Purpose, I am directly deploying to the Production environment.

  • Click Add - New Agent will be created. - Rename to ML-Deployment-Agent

  • Create Variables

Name Value
aks.clusterName Select your existing cluster
aks.vmSize Standard_B2ms
azureml.resourceGroup mlops-demo-blr-resource-group
azureml.workspaceName mlops-blr-ws-aml
service.name.prod insurance-ml-model-prod
aks.agentCount 3
  • Set the Agent Job
    1. Rename the Display Name
    2. Agent Pool --> Azure Pipeline
    3. Agent Specification --> Ubuntu-18.04

image.png

  • Click on Add task from the Agent

image.png

Search for Python Version

image.png

AZ CLI ML Extension

  • Click on Add task from the Agent -> Search Azure CLI -> Change Display - Add ML Extension

image.png

  • Inline script - Add below Value az extension add -n azure-cli-ml

image.png

AZ CLI ML Extension - Deploy to AKS

  • Click on Add task from the Agent -> Search Azure CLI -> Change Display -Deploy to AKS

    • Inline script - Add below Value az ml model deploy -g $(azureml.resourceGroup) -w $(azureml.workspaceName) -n $(service.name.prod) -f ../metadata/model.json --dc aksDeploymentConfigProd.yml --ic inferenceConfig.yml --ct $(aks.clusterName) --overwrite

image.png

Create Release

  • image.png

  • Create

image.png

  • Validate the Status of Pipeline

image.png

================ END OF TASK 7 =======================================

Task 8 - Validate Model Endpoint

  • Go to Azure Machine learning Workspace
  • Validate the Model - You can see the New Model Created

image.png

  • Validate Endpoint.

image.png

  • Validate with test data - Step 1 - Get the Python Code
    • Go to Assets - Endpoints -- Consume - Check Python and Take the code

image.png

  • Validate with test data - Step 1 - Test in Notebook

    • Go to Author - Notebook -- Consume - Create the Notebook file. -> Paste the Python Code. -> Change the Value of the Data as mentioned below --> Run the Cell

Replace the line 8 Data with below Values

data = {'data': [[0,1,8,1,0,0,1,0,0,0,0,0,0,0,12,1,0,0,0.5,0.3,0.610327781,7,1,-1,0,-1,1,1,1,2,1,65,1,0.316227766,0.669556409,0.352136337,3.464101615,0.1,0.8,0.6,1,1,6,3,6,2,9,1,1,1,12,0,1,1,0,0,1],[4,2,5,1,0,0,0,0,1,0,0,0,0,0,5,1,0,0,0.9,0.5,0.771362431,4,1,-1,0,0,11,1,1,0,1,103,1,0.316227766,0.60632002,0.358329457,2.828427125,0.4,0.5,0.4,3,3,8,4,10,2,7,2,0,3,10,0,0,1,1,0,1]]}

image.png

  • Monitor using the Application Insights using the Application Insight URL from Endpoints.
  • Go to Assets - Endpoints - Details --> Application Insights URL --> Click the URL

image.png

  • You can see the Application throughput here.

image.png

================ END OF LAB =======================================

About

License:MIT License


Languages

Language:Python 98.8%Language:Shell 1.2%