Beginner

Introduction to Azure Machine Learning

Where Azure ML fits in the modern ML lifecycle, its common use cases and user workflows.

Microsoft’s enterprise machine learning platform — Covers the complete ML lifecycle, from data preparation to production monitoring.


Table of Contents

  1. Module 1 — Azure ML in the Modern ML Lifecycle
  2. Module 2 — Common Use Cases for Azure ML
  3. Module 3 — Azure ML Users and Their Workflows
  4. Quick Reference — Key Concepts

Module 1 — Azure ML in the Modern ML Lifecycle

1.1 What is Azure Machine Learning?

Azure Machine Learning (Azure ML) is Microsoft’s enterprise machine learning platform. It is a managed service that handles the heavy lifting involved in configuring and running machine learning workflows at scale, allowing organizations to focus on solving business problems rather than building infrastructure from scratch.

Core Pillars

CharacteristicDescription
Enterprise-gradeBuilt-in security, compliance, and governance
Managed serviceInfrastructure managed by Microsoft
Multi-roleSupports data scientists, ML engineers, analysts, ops engineers
End-to-endCovers the full ML lifecycle, from data to monitoring
FlexibleCode-first, no-code, and everything in between

The Three Fundamental Pillars

┌─────────────────────────────────────────────────────────────┐
│                   AZURE MACHINE LEARNING                    │
├───────────────┬──────────────────┬──────────────────────────┤
│   TRAINING    │    DEPLOYMENT    │       MANAGEMENT         │
│               │                  │                          │
│ • Notebooks   │ • Real-time      │ • Data drift monitoring  │
│ • AutoML      │   Inference      │ • Model versioning       │
│ • CLI / SDK   │ • Batch          │ • Dataset versioning     │
│ • Cloud       │   Inference      │ • Performance alerts     │
│   compute     │ • AKS / ACI /   │ • RBAC (Role-Based       │
│ • GPU / CPU   │   Edge devices   │   Access Control)        │
└───────────────┴──────────────────┴──────────────────────────┘

Roles Supported by the Platform

The running example for this course is a cloud engineering team that must reduce customer churn for a SaaS product:

mindmap
  root((Azure ML))
    Data Scientists
      Jupyter Notebooks
      AutoML
      Experiment tracking
    Data Engineers
      Pipelines
      Dataset registration
      Data prep
    ML Engineers
      Model deployment
      MLOps
      CI/CD integration
    Analysts
      Power BI
      Model outputs
      Dashboards
    Ops Engineers
      Monitoring
      RBAC
      Governance

Concrete example: A cloud engineering team receives the request to reduce customer churn through predictive analytics. Rather than building all the infrastructure from scratch, Azure ML provides the complete platform to train, deploy, and manage ML models.


1.2 Azure ML in the ML Lifecycle

Azure ML supports the entire ML lifecycle — from data ingestion to continuous monitoring in production.

Lifecycle Overview

flowchart LR
    A([🗄️ Data Sources\nAzure Data Lake\nAzure SQL\nBlob Storage]) --> B

    subgraph B[1 · Data Preparation]
        B1[Dataset\nRegistration]
        B2[Profiling &\nTransformation]
        B3[Data\nVersioning]
        B1 --> B2 --> B3
    end

    B --> C

    subgraph C[2 · Training]
        C1[Jupyter\nNotebooks]
        C2[AutoML]
        C3[CLI / SDK]
        C4[Experiment\nTracking]
        C1 & C2 & C3 --> C4
    end

    C --> D

    subgraph D[3 · Validation]
        D1[Metrics\nEvaluation]
        D2[UI\nVisualization]
        D3[Model\nRegistration]
        D1 --> D2 --> D3
    end

    D --> E

    subgraph E[4 · Deployment]
        E1[Containerized\nscoring script]
        E2[Environment\ndefinition]
        E3[Logging &\nperformance tracking]
        E1 & E2 --> E3
    end

    E --> F

    subgraph F[5 · Monitoring]
        F1[Performance\nMetrics]
        F2[Data drift\ndetection]
        F3[Azure Monitor /\nLog Analytics]
        F1 & F2 --> F3
    end

    F -->|⚠️ Drift detected| C

Complete Model Traceability

Every deployed model is traceable back to:

ElementDescription
DatasetExact version of training data
Training scriptExact code used for training
ComputeCompute resources used
EnvironmentExact dependencies and configuration
MetricsValidation results that justified the deployment

Best practice: This traceability (data lineage, version control, experiment tracking, deployment reproducibility) is essential in regulated environments.

monitor = DataDriftMonitor(
    name="churn-model-drift-monitor",
    target=MonitoringTarget(
        ml_task="classification",
        endpoint_deployment_id="churn-endpoint:v1"
    ),
    alert_notification=AlertNotification(
        emails=["ops-team@company.com"]
    ),
    lookback_period="P30D",
)
ml_client.monitors.create_or_update(monitor)

Complete Traceability

Deployed model
    └── linked to → Training run
        ├── linked to → Dataset (version X)
        ├── linked to → Training script (commit hash)
        ├── linked to → Environment definition
        └── linked to → Compute cluster used

Best practice: Azure ML bakes into the platform: data lineage, version control, experiment tracking, deployment reproducibility, and operational monitoring.


1.3 Azure ML vs Manual ML Workflows

Comparing Approaches

graph TD
    subgraph DIY["🔧 DIY Approach (Do-It-Yourself)"]
        D1[Local notebook\non laptop]
        D2[Manual scripts\ncleaning + training]
        D3[Flask app / \nmanual\ncontainerization]
        D4[Custom logging\nmanual alerts]
        D5[❌ No audit trail\n❌ No versioning\n❌ Difficult collaboration]
        D1 --> D2 --> D3 --> D4 --> D5
    end

    subgraph AML["☁️ Azure ML Approach"]
        A1[Cloud-hosted\nnotebook environment]
        A2[AutoML + SDK\nversioned experiments]
        A3[Automated +\ncontainerized deployment]
        A4[Azure Monitor /\nApp Insights integrated]
        A5[✅ Complete audit trail\n✅ Auto versioning\n✅ Workspace collaboration]
        A1 --> A2 --> A3 --> A4 --> A5
    end

Key Advantages of Azure ML Over Manual Workflows

1. Speed

  • DIY pipelines require manual environment setup, dependency management, and compute resource allocation.
  • Azure ML automates all of this: compute clusters are pre-configured, pipelines are built visually or with simple code, and experiments/datasets/environments are versioned automatically.

2. Governance

  • In DIY workflows, there is rarely a reliable audit trail — it’s impossible to know which version of data was used or who modified the training script.
  • Azure ML provides complete traceability: every model is linked to its training run, the specific dataset, the code snapshot, and the compute environment.
  • Access is controlled via Azure RBAC (Role-Based Access Control) and actions are logged automatically.

3. Collaboration

  • Azure ML provides a shared workspace where teams can co-develop, experiment, and deploy.
  • Everyone’s preferred tools connect inside this shared workspace.

1.4 Azure ML in the Azure Ecosystem

Azure ML integrates natively with the entire Azure ecosystem:

graph TB
    subgraph CORE["🧠 Azure Machine Learning (Core)"]
        WS[Workspace\nExperiments · Models\nPipelines · Endpoints]
    end

    subgraph DATA["🗄️ Data Services"]
        DL[Azure Data Lake\nStorage]
        SQL[Azure SQL\nDatabase]
        CDB[Cosmos DB]
        BS[Blob Storage]
    end

    subgraph SEC["🔐 Security & Identity"]
        AAD[Microsoft Entra ID\nAzure Active Directory]
        RBAC[RBAC\nRole-Based Access Control]
        KV[Azure Key Vault\nSecrets management]
        VN[Virtual Networks\nPrivate Endpoints]
    end

    subgraph DEVOPS["🔄 DevOps & CI/CD"]
        GH[GitHub\nAzure Repos]
        GHA[GitHub Actions]
        AP[Azure Pipelines]
        GA[GitHub Actions]
    end

    subgraph MONITOR["📊 Observability"]
        AM[Azure Monitor]
        LA[Log Analytics]
        AI[Application Insights]
    end

    subgraph COMPUTE["⚙️ Compute"]
        AKS[Azure Kubernetes\nService]
        ACI[Azure Container\nInstances]
        CC[Compute Clusters\nGPU / CPU]
    end

    DATA -->|Registered datastores| WS
    SEC -->|Authentication & secrets| WS
    DEVOPS -->|Trigger training / deploy| WS
    WS -->|Logs & metrics| MONITOR
    WS -->|Model deployment| COMPUTE

Critical Integration Points

Data Azure ML does not store your data directly. It connects to existing sources (Data Lake, Azure SQL, Cosmos DB) via registered datastores. This ensures centralized data governance and avoids duplicated copies.

Security and Governance

  • Identity and access via Microsoft Entra ID and RBAC
  • Secrets (API keys, credentials, connection strings) are stored in Azure Key Vault and referenced dynamically at runtime — never hardcoded in training scripts
  • Support for private endpoints, managed identities, and customer-managed encryption keys

DevOps / MLOps Integration Azure ML is designed for MLOps practices — the idea that machine learning should follow the same CI/CD principles as modern software development:

sequenceDiagram
    participant DEV as Developer
    participant GH as GitHub / Azure Repos
    participant AML as Azure ML
    participant PROD as Production

    DEV->>GH: Push training script + config
    GH->>AML: Trigger CI/CD pipeline
    AML->>AML: Run training job
    AML->>AML: Validate model (metrics)
    AML->>AML: Register model (Model Registry)
    AML->>PROD: Deploy to endpoint (AKS / ACI)
    PROD->>AML: Logs & monitoring
    AML-->>DEV: Alerts if degradation

DevOps Integration (MLOps)

# .github/workflows/train-and-deploy.yml
name: MLOps - Train and Deploy Churn Model

on:
  push:
    branches: [main]
    paths:
      - 'src/training/**'
      - 'pipelines/**'

jobs:
  train:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Login to Azure
        uses: azure/login@v1
        with:
          creds: ${{ secrets.AZURE_CREDENTIALS }}

      - name: Submit training pipeline
        run: |
          az ml job create \
            --file pipelines/churn-training-pipeline.yml \
            --workspace-name ${{ vars.AML_WORKSPACE }} \
            --resource-group ${{ vars.RESOURCE_GROUP }}

  deploy:
    needs: train
    runs-on: ubuntu-latest
    steps:
      - name: Deploy model to endpoint
        run: |
          az ml online-endpoint update \
            --name churn-realtime-endpoint \
            --workspace-name ${{ vars.AML_WORKSPACE }}

Module 2 — Common Use Cases for Azure ML

2.1 Business Use Cases

Azure ML addresses key business problems that require transforming data into decisions quickly, securely, and at scale.

Use Case Overview

mindmap
  root((Azure ML\nUse Cases))
    Churn Prediction
      User behavior analysis
      Real-time risk score
      Real-time endpoint deployment
    Personalization
      Feature recommendations
      Pricing optimization
      Customer lifetime value prediction
    Forecasting
      Sales forecasting
      Inventory levels
      Server load
    Anomaly Detection
      Financial fraud
      Equipment failures
      Cybersecurity
    Classification
      Loan approval
      Customer support triage
      Insurance fraud detection

Detailed Example: Churn Prediction (SaaS)

Problem: A SaaS company notices that users inactive for more than a week are much more likely to cancel.

Solution with Azure ML:

Churn signals identified by the model:

  • Declining login frequency
  • Increasing volume of support tickets
  • Reduced usage of key features
  • No login for > 7 days

Forecasting

from azure.ai.ml import automl

# AutoML configuration for sales forecasting
forecasting_job = automl.forecasting(
    compute="cpu-cluster",
    experiment_name="sales-forecast-weekly",
    training_data=ml_client.data.get("sales-history", version="latest"),
    target_column_name="units_sold",
    primary_metric="normalized_root_mean_squared_error",
    forecasting_settings=automl.ForecastingSettings(
        time_column_name="date",
        forecast_horizon=12,          # 12 weeks ahead
        time_series_id_column_names=["product_id", "region"],
        frequency="W",                # Weekly
    ),
    n_cross_validations=3,
)
returned_job = ml_client.jobs.create_or_update(forecasting_job)
Data sources                  Azure ML Pipeline               Outputs
─────────────────             ─────────────────────────       ────────────────
Azure Data Explorer  ──────►  1. Ingestion & cleaning    ──►  Risk score
(user behavior)                2. Feature engineering          per user
                               3. AutoML training         ──►  Real-time API
Usage signals:                 4. Model validation             for intervention
• Session frequency            5. Endpoint deployment     ──►  CS team dashboard
• Feature usage                6. Continuous monitoring
• Support tickets

Personalization: Once churn is predicted, the same data is used to personalize the experience — recommend new features, create targeted content, or optimize pricing tiers based on predicted customer lifetime value.

Use Case Summary Table

Use CaseIndustryModel TypeOutput
Churn predictionSaaS, RetailClassificationRisk score 0–1
ForecastingRetail, FinanceTime-seriesQuantitative forecasts
Anomaly detectionFinance, Manufacturing, CybersecUnsupervised / SupervisedReal-time alerts
ClassificationFinance, InsuranceClassificationCategory (Approve/Deny)
PersonalizationE-commerce, SaaSRecommendationTop-N recommendations

Note: These use cases do not require large data science teams. With AutoML, templates, and the Designer’s drag-and-drop tools, Azure ML lowers the barrier of entry for organizations wanting to get started with AI.


2.2 Azure AutoML and Pipelines

AutoML — Accelerating Model Development

AutoML in Azure ML is designed to accelerate model development, especially for teams that want solid results without writing every line of ML code from scratch.

flowchart TD
    A[📊 Provide a dataset] --> B[🎯 Define the target column]
    B --> C{Select the task type}
    C --> C1[Classification]
    C --> C2[Regression]
    C --> C3[Time-series\nForecasting]
    C1 & C2 & C3 --> D

    subgraph D["🤖 AutoML — Automated Experimentation"]
        direction LR
        D1[Algorithm A\n+ preprocessing X]
        D2[Algorithm B\n+ preprocessing Y]
        D3[Ensemble\nMethod]
        D4[...]
    end

    D --> E[📈 Evaluation by\ncross-validation]
    E --> F[🏆 Leaderboard of\nbest models]
    F --> G[✅ Best model\n+ explanations]
    F --> H[📋 Exportable and\neditable training script]

What AutoML automates:

  • Algorithm selection and comparison
  • Hyperparameter tuning
  • Feature selection and transformation
  • Cross-validation evaluation
  • Generation of Ensemble models (stacking multiple models)

For experienced users: AutoML is not a black box. You can customize the search space, control time limits, and export the generated training scripts for in-depth inspection.

Azure ML Pipelines — MLOps for Data Science

Azure ML Pipelines chain multiple ML workflow steps into a repeatable, automated sequence.

graph LR
    subgraph PIPELINE["Azure ML Pipeline — Churn Prediction Example"]
        direction LR
        S1["📥 Step 1\nData Ingestion\n─────────\nCompute: CPU VM\nSource: Azure Data Lake"]
        S2["⚙️ Step 2\nFeature Engineering\n─────────\nCompute: CPU Cluster\nScript: prep.py"]
        S3["🧠 Step 3\nModel Training\n─────────\nCompute: GPU Cluster\nScript: train.py"]
        S4["📊 Step 4\nModel Evaluation\n─────────\nCompute: CPU VM\nScript: evaluate.py"]
        S5["📦 Step 5\nModel Registration\n─────────\nModel Registry\nAuto versioning"]

        S1 -->|Dataset v2.3| S2
        S2 -->|Engineered features| S3
        S3 -->|Model artifact| S4
        S4 -->|✅ Validation OK| S5
    end

    TRIGGER["🕐 Scheduler\nor\n🔀 GitHub Actions"] --> S1
    S5 --> DEPLOY["🚀 Deployment\nEndpoint"]

Pipeline Advantages:

AdvantageDetail
Flexible computeEach step uses the appropriate compute (CPU for data prep, GPU for training)
ReproducibilityInputs, outputs, logs, and metadata are tracked for each step
ReusabilityA pipeline built once is reusable across different projects, teams, and datasets
CollaborationData engineer for ingestion, Data Scientist for training, ML Engineer for deployment
AutomationScheduling, triggers from GitHub Actions, full CI/CD integration

AutoML + Pipelines — Complementarity:

AutoML                              Pipelines
────────────────────                ────────────────────────────
✅ Rapid identification             ✅ Production readiness
   of high-performing models
✅ Ideal for rapid                  ✅ Consistency, scalability
   experimentation and baselines       and governance at scale
✅ Suited for ML beginners         ✅ Cross-team collaboration
✅ Jump-start for new              ✅ Automation and scheduling
   problems

AutoML vs. Pipelines — two complementary problems:

  • AutoML → Rapid identification of high-performing models (experimentation, baseline)
  • Pipelines → Putting the workflow into production (consistency, scalability, governance)

2.3 Azure ML vs Other Azure Services

The Azure ecosystem offers several services with AI/ML capabilities. Understanding their differences helps you choose the right tool.

quadrantChart
    title Azure AI Services — Positioning
    x-axis Generic --> Domain-specific
    y-axis Low control --> Full control
    quadrant-1 Maximum control, specific usage
    quadrant-2 Full control, general usage
    quadrant-3 General usage, little control
    quadrant-4 Specific usage, little control
    Azure ML: [0.85, 0.90]
    Azure OpenAI: [0.40, 0.45]
    Azure AI Services: [0.15, 0.15]
    SynapseML: [0.60, 0.65]

Detailed Comparison

ServicePrimary RoleIdeal Use CaseLimitations
Azure AI ServicesPre-built APIs (text, vision, speech)Sentiment analysis, OCR, translation — no training requiredLimited customization; generic Microsoft models
Azure Machine LearningFull custom ML platformCustom models with your data, MLOps, complianceRequires more expertise and configuration
SynapseMLDistributed ML on Apache SparkBig data pipelines, millions of events/dayNot a full MLOps platform; used alongside Azure ML
Azure OpenAIGenerative models (GPT, DALL-E, Codex)Summarization, code generation, chatbots, LLM fine-tuningFixed base models; no custom ML pipeline

Typical Combined Architecture

flowchart TD
    Q1{Do you need\nout-of-the-box AI\nwithout training?}
    Q1 -->|Yes| A1[Azure AI Services\nPre-trained APIs]
    Q1 -->|No| Q2

    Q2{Are you working with\ngenerative LLMs\nGPT / DALL-E?}
    Q2 -->|Yes| A2[Azure OpenAI\nFine-tuning or prompting]
    Q2 -->|No| Q3

    Q3{Is your data in a Spark\npipeline at very\nlarge scale?}
    Q3 -->|Yes| A3[SynapseML\non Synapse or Databricks]
    Q3 -->|Partially| A4[SynapseML for\nexploration\n+\nAzure ML for\ndeployment]
    Q3 -->|No| A5

    A5[Azure Machine Learning\nCustom model · Traceability\nMLOps · Governance]

These services are complementary, not competing. Example of a combined architecture:

Support tickets
      │
      ▼
Azure AI Services ──► Keyword extraction (text)
      │
      ▼ structured data
Azure ML ──────────► Custom churn prediction model
      │
      ▼ summarized interaction
Azure OpenAI ───────► Personalized follow-up generation
      │
      ▼
CRM / Dashboard

Module 3 — Azure ML Users and Their Workflows

The four main roles interacting with Azure ML in a typical ML project:

graph LR
    DS[👩‍🔬 Data Scientist\nMaya\nExperimentation &\nTraining]
    MLE[👨‍💻 ML Engineer\nJordan\nDeployment &\nAutomation]
    BA[👩‍📊 Business Analyst\nCasey\nConsuming\nOutputs]
    OPS[👨‍🔧 Ops Engineer\nOmar\nMonitoring &\nGovernance]

    DS -->|Model registered in\nModel Registry| MLE
    MLE -->|Batch / API predictions| BA
    MLE -->|Endpoints + pipelines| OPS
    BA -->|Anomaly alerts| DS
    OPS -->|Monitoring & alerts| MLE

3.1 The Data Scientist: Experimentation and Training

Profile: Maya, Data Scientist at a B2B SaaS company. Goal: Build a predictive customer churn model.

Typical Workflow

flowchart TD
    A[🚀 Launch\nCloud-hosted Notebook\nCompute Instance] --> B

    B[🔍 Data Exploration\nDataset registered in\nAzure Data Lake] --> C

    C[📊 Trend Visualization\nFeature/churn correlations\nData cleaning] --> D

    D{Chosen approach}
    D -->|Code-first| D1[Custom Python script\nAzure ML SDK]
    D -->|Accelerated| D2[AutoML\nClassification]
    D1 & D2 --> E

    subgraph E["⚙️ Experimentation (Compute Cluster)"]
        E1[Job 1: Algorithm A + preprocessing X]
        E2[Job 2: Algorithm B + preprocessing Y]
        E3[Job 3: Ensemble method]
        E4[Job N: ...]
    end

    E --> F[📈 Automatic\nExperiment Tracking\nMetrics · Logs · Params · Outputs]

    F --> G[🏆 Results Leaderboard\nBest model: Gradient Boosted Tree\nTop features: login_freq · support_tickets]

    G --> H[🔬 Iteration\nClone + modify\noriginal run]
    H --> E

    G --> I[📦 Model Registration\nin the Model Registry\nVersioned + linked to experiment]

What Azure ML Brings to the Data Scientist

Without Azure ML                     With Azure ML
──────────────────────────────       ──────────────────────────────────
📂 Manual results spreadsheets       ✅ Automatic experiment tracking
📸 Screenshots of metrics            ✅ Complete history + comparison
🔄 Manual re-execution               ✅ Clone + replay of a run
   of scripts
📧 Sharing by email                  ✅ Shared workspace, no friction
💻 Local dependencies                ✅ Pre-configured cloud compute

Code Example — Launching an AutoML Job

from azure.ai.ml import MLClient
from azure.ai.ml.automl import classification
from azure.ai.ml.entities import Data
from azure.identity import DefaultAzureCredential

# Connect to workspace
ml_client = MLClient(
    credential=DefaultAzureCredential(),
    subscription_id="<subscription-id>",
    resource_group_name="<resource-group>",
    workspace_name="<workspace-name>"
)

# Define the AutoML task
classification_job = classification(
    compute="cpu-cluster",
    experiment_name="churn-prediction-automl",
    training_data=Data(
        path="azureml:customer-churn-dataset:1",
        type="mltable"
    ),
    target_column_name="churned",
    primary_metric="accuracy",
    n_cross_validations=5,
    enable_model_explainability=True,
)

# Submit the job
returned_job = ml_client.jobs.create_or_update(classification_job)
print(f"Job created: {returned_job.name}")
print(f"Studio URL: {returned_job.studio_url}")

Code Example — Registering the Model

# Register the best model in the Model Registry with complete metadata
from azure.ai.ml.entities import Model
from azure.ai.ml.constants import AssetTypes

model = ml_client.models.create_or_update(
    Model(
        name="churn-prediction-model",
        path=f"azureml://jobs/{returned_job.name}/outputs/artifacts/best_model",
        type=AssetTypes.MLFLOW_MODEL,
        description="Churn prediction model — Gradient Boosted Tree",
        tags={"experiment": "churn-prediction-automl", "accuracy": "0.92"}
    )
)
print(f"Model registered: {model.name} v{model.version}")

3.2 The ML Engineer: Deployment and Automation

Profile: Jordan, ML Engineer on the same team. Goal: Put the model into production, automate retraining, ensure reliability at scale.

Full Workflow — Retraining Pipeline

flowchart LR
    subgraph PIPELINE["ML Pipeline — Weekly Retraining"]
        direction TB
        P1["📥 Data Ingestion\nAzure Data Lake\nCompute: CPU VM"]
        P2["⚙️ Feature Engineering\nScript: prep.py\nCompute: CPU Cluster"]
        P3["🧠 Model Training\nParams from version control\nCompute: GPU Cluster"]
        P4["📊 Model Evaluation\nMetrics validation\nCompute: CPU VM"]
        P5["📦 Model Registration\nModel Registry\nAuto versioning"]

        P1 -->|Raw data| P2
        P2 -->|Engineered features| P3
        P3 -->|Model artifact| P4
        P4 -->|✅ Metrics OK| P5
        P4 -->|❌ Metrics KO| ALERT["⚠️ Team alert"]
    end

    SCHED["🕐 Weekly\nScheduler"] --> P1
    GH["🔀 GitHub Actions\n(merge to main)"] --> P1
    P5 --> DEPLOY

    subgraph DEPLOY["Deployment"]
        E1["⚡ Real-time Endpoint\nAzure Kubernetes Service\nInstant prediction\nduring user actions"]
        E2["📦 Batch Inference\nNightly job\nScore all active customers\n→ Azure SQL Database"]
    end

Code Example — Defining a Pipeline in Python

from azure.ai.ml import MLClient, Input, Output
from azure.ai.ml.dsl import pipeline
from azure.ai.ml.entities import CommandComponent
from azure.identity import DefaultAzureCredential

ml_client = MLClient(
    credential=DefaultAzureCredential(),
    subscription_id="<subscription-id>",
    resource_group_name="<resource-group>",
    workspace_name="<workspace-name>"
)

# Pipeline definition
@pipeline(
    name="churn-retraining-pipeline",
    description="Weekly retraining pipeline for the churn model",
    compute="cpu-cluster"
)
def churn_pipeline(raw_data_path: str):
    # Step 1: Data preparation
    prep_step = prep_component(
        raw_data=Input(path=raw_data_path, type="uri_folder")
    )
    prep_step.compute = "cpu-cluster"

    # Step 2: Training
    train_step = train_component(
        prepared_data=prep_step.outputs.prepared_data
    )
    train_step.compute = "gpu-cluster"

    # Step 3: Evaluation
    eval_step = evaluate_component(
        model=train_step.outputs.model,
        test_data=prep_step.outputs.test_data
    )
    eval_step.compute = "cpu-cluster"

    return {"model": eval_step.outputs.validated_model}

# Publish and schedule
pipeline_job = churn_pipeline(
    raw_data_path="azureml://datastores/datalake/paths/customer_data/"
)
pipeline_job = ml_client.jobs.create_or_update(pipeline_job)

Code Example — Deploying a Real-time Endpoint

from azure.ai.ml.entities import (
    ManagedOnlineEndpoint,
    ManagedOnlineDeployment,
    Model,
    Environment,
    CodeConfiguration
)

# Create the endpoint
endpoint = ManagedOnlineEndpoint(
    name="churn-prediction-endpoint",
    description="Real-time endpoint for churn prediction",
    auth_mode="key"
)
ml_client.online_endpoints.begin_create_or_update(endpoint).result()

# Define the deployment
blue_deployment = ManagedOnlineDeployment(
    name="blue",
    endpoint_name="churn-prediction-endpoint",
    model="azureml:churn-prediction-model:3",
    environment=Environment(
        name="churn-inference-env",
        conda_file="environments/conda.yaml",
        image="mcr.microsoft.com/azureml/openmpi4.1.0-ubuntu20.04"
    ),
    code_configuration=CodeConfiguration(
        code="./scoring",
        scoring_script="score.py"
    ),
    instance_type="Standard_DS3_v2",
    instance_count=2
)
ml_client.online_deployments.begin_create_or_update(blue_deployment).result()

# Route 100% of traffic to blue
endpoint.traffic = {"blue": 100}
ml_client.online_endpoints.begin_create_or_update(endpoint).result()

Code Example — Scoring Script (score.py)

import os
import json
import mlflow
import pandas as pd

def init():
    """Load the model at container startup."""
    global model
    model_path = os.path.join(os.environ["AZUREML_MODEL_DIR"], "model")
    model = mlflow.pyfunc.load_model(model_path)

def run(raw_data: str) -> str:
    """Inference on incoming data."""
    try:
        data = json.loads(raw_data)
        df = pd.DataFrame(data["data"], columns=data["columns"])
        predictions = model.predict(df)
        probabilities = model.predict_proba(df)[:, 1]

        return json.dumps({
            "predictions": predictions.tolist(),
            "model_version": os.environ.get("AZUREML_MODEL_VERSION", "unknown")
        })
    except Exception as e:
        return json.dumps({"error": str(e)})

MLOps Configuration with GitHub Actions

# .github/workflows/retrain-pipeline.yml
name: Retrain Churn Model

on:
  schedule:
    - cron: '0 2 * * 1'   # Every Monday at 2am
  push:
    branches: [main]
    paths:
      - 'pipelines/**'
      - 'components/**'

jobs:
  retrain:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Login Azure
        uses: azure/login@v1
        with:
          creds: ${{ secrets.AZURE_CREDENTIALS }}

      - name: Install Azure ML CLI
        run: az extension add -n ml

      - name: Run retraining pipeline
        run: |
          az ml job create \
            --file pipelines/retrain-pipeline.yaml \
            --workspace-name ${{ vars.AML_WORKSPACE }} \
            --resource-group ${{ vars.RESOURCE_GROUP }} \
            --set inputs.data_version=latest

3.3 The Business Analyst: Consuming Outputs

Profile: Casey, business analyst on the Customer Success team. Goal: Transform predictions into concrete actions to improve retention.

flowchart LR
    subgraph AML["Azure ML (behind the scenes)"]
        direction TB
        M[Deployed\nchurn model]
        B[Batch Inference\nNightly job]
        DB[(Azure SQL\nDatabase\nRisk scores)]
        M --> B --> DB
    end

    subgraph CASEY["Casey's Interface — Power BI"]
        direction TB
        DASH[Power BI Dashboard\nCustomers ranked by\nchurn risk]
        SEG[Segmentation\nby account · feature usage\nsupport history]
        EXP[Explainability\nWhy this score?\n• Recent inactivity\n• High tickets\n• Usage change]
        DASH --> SEG
        DASH --> EXP
    end

    DB -->|Power BI connection\ndataset| CASEY

    CASEY -->|Segment anomaly alert| DS[👩‍🔬 Maya\nData Scientist]
    CASEY -->|Pipeline check| MLE[👨‍💻 Jordan\nML Engineer]

What Casey Sees Without Touching Code

Available InformationSource in Azure ML
Churn risk score (0–1)Batch inference endpoint output
Account segment & tenureEnrichment from Azure SQL
Features contributing to the scoreModel explainability (SHAP values)
Model performanceMetrics exposed via RBAC
Last retraining dateModel Registry metadata

RBAC in action: Casey can see predictions, metadata, and certain performance metrics — but cannot modify pipelines, access raw training data, or deploy models. Permissions are defined by Omar in Microsoft Entra.

Cross-Role Collaboration Triggered by Casey

📊 Main reasons:
  ▓▓▓▓▓▓▓▓░░  login_frequency     (-0.42) → Sharply reduced logins
  ▓▓▓▓▓▓░░░░  support_tickets     (+0.28) → 5 tickets in 2 weeks
  ▓▓▓▓░░░░░░  feature_usage_score (-0.21) → Only using 2/10 features
  ▓▓░░░░░░░░  days_since_login    (+0.15) → 12 days without login
Casey sees spike in predicted churn
for a segment → FLAG
         │
         ▼
    Two possible paths:
         │
    ┌────┴────────────────────┐
    │                         │
    ▼                         ▼
Maya (Data Scientist)    Jordan (ML Engineer)
Analyzes whether the     Verifies the pipeline
underlying behavior      ran correctly and that
has changed              input data hasn't drifted

3.4 The Operations Engineer: Monitoring and Governance

Profile: Omar, platform engineer. Goal: Keep the system secure, observable, and compliant.

Monitoring Architecture

graph TB
    subgraph ENDPOINTS["Azure ML Endpoints"]
        RT[Real-time\nEndpoint AKS]
        BT[Batch Inference\nJob]
    end

    subgraph METRICS["Collected Metrics"]
        LAT[Latency]
        THR[Throughput]
        ERR[Error rate]
        DRF[Data Drift]
        SCH[Schema violations]
    end

    subgraph OBSERVABILITY["Observability Stack"]
        AM[Azure Monitor]
        LA[Log Analytics]
        AI[Application Insights]
    end

    subgraph ACTIONS["Automated Actions"]
        ALT[Email / Teams alerts]
        DASH[Ops dashboards]
        TICKET[Auto incident]
    end

    RT & BT --> METRICS
    METRICS --> OBSERVABILITY
    OBSERVABILITY --> ACTIONS

Security and Access Control

graph TD
    subgraph ENTRA["Microsoft Entra ID"]
        RBAC[Role-Based\nAccess Control]
    end

    subgraph ROLES["Defined Roles"]
        R1["👩‍🔬 Data Scientist\n• Run experiments\n• View logs\n• Register models"]
        R2["👨‍💻 ML Engineer\n• Deploy models\n• Manage pipelines\n• Configure endpoints"]
        R3["👩‍📊 Analyst\n• View predictions\n• View metrics\n• Power BI only"]
        R4["👨‍🔧 Ops Engineer\n• All above\n• RBAC management\n• Audit logs\n• Network config"]
    end

    subgraph NET["Network Security"]
        PE[Private Endpoints]
        VN[Virtual Networks]
        MI[Managed Identities]
        KV[Azure Key Vault\nSecrets management]
    end

    ENTRA --> ROLES
    NET -->|Authentication without\nhardcoded secrets| ROLES

Complete Audit Trail

Every action in the workspace is logged and timestamped:

ActionLogged Information
Experiment creationWho · When · Dataset used · Params
Pipeline modificationWho · When · Change diff
Model deploymentWho · When · Which version · Which compute
Deployment approvalApprover · Timestamp · Test results

Regulatory compliance: In finance, healthcare, or government sectors, this audit trail enables producing complete lineage reports: which data produced which model, who approved the deployment, and from which code.

Omar’s Operational Responsibilities

Omar does not need to be
an expert in Machine Learning!
            │
            ▼
┌───────────────────────────────────────┐
│  What he manages with Azure tools     │
├─────────────────────────────────────  │
│  ✅ Endpoint uptime                   │
│  ✅ Alerts on latency or errors       │
│  ✅ RBAC management in Entra ID       │
│  ✅ Network isolation (VNet/PE)       │
│  ✅ Secret rotation (Key Vault)       │
│  ✅ Audit logs for compliance         │
│  ✅ Data drift alerts                 │
└───────────────────────────────────────┘

3.5 Collaboration in the Workspace

The Azure ML shared workspace is the convergence point for all roles. Every asset is versioned, traceable, and scoped to the right access level.

sequenceDiagram
    participant Maya as Maya (Data Scientist)
    participant Registry as Model Registry (Azure ML)
    participant Jordan as Jordan (ML Engineer)
    participant Casey as Casey (Business Analyst)
    participant Omar as Omar (Ops Engineer)

    Note over Maya: Exploration in Studio UI
    Maya->>Registry: Register model v3\nwith complete metadata
    Note over Registry: Model linked to:\n- dataset v2.3\n- training script SHA\n- compute env\n- metrics

    Jordan->>Registry: Retrieve model v3
    Note over Jordan: Packaging for deployment\nPipeline + scoring script\n→ Source control (GitHub)
    Jordan->>Omar: Pipeline deployed\nEndpoints configured

    Omar->>Omar: Configure RBAC\nMonitoring · Audit
    Note over Omar: Network isolation\nKey Vault secrets\nAzure Monitor alerts

    Jordan-->>Casey: Batch scores\n→ Azure SQL DB

    Note over Casey: Power BI Dashboard\n(indirect access via outputs)
    Casey->>Maya: 🚨 Churn spike\nEnterprise segment

    Maya->>Registry: Analysis + new\nexperiment launched

Shared and Versioned Assets in the Workspace

Azure ML Workspace
├── 📊 Datasets (versioned)
│   ├── customer-churn-dataset:1
│   ├── customer-churn-dataset:2
│   └── customer-churn-dataset:3  ← current
│
├── 🧪 Experiments & Runs (tracked)
│   ├── churn-prediction-automl/
│   │   ├── run_001 [accuracy: 0.89]
│   │   ├── run_002 [accuracy: 0.91]
│   │   └── run_003 [accuracy: 0.92] ← best
│   └── churn-custom-features/
│
├── 📦 Model Registry (versioned)
│   ├── churn-prediction-model:1
│   ├── churn-prediction-model:2
│   └── churn-prediction-model:3  ← deployed
│
├── 🔧 Environments (versioned)
│   └── churn-inference-env:2
│
├── ⚙️ Compute Targets
│   ├── cpu-cluster (data prep / eval)
│   ├── gpu-cluster (training)
│   └── compute-instance (notebooks)
│
└── 🚀 Endpoints
    ├── churn-prediction-endpoint (real-time)
    └── batch-scoring-job (nightly)

Quick Reference — Key Concepts

Glossary

TermDefinition
AutoMLAutomated Machine Learning — automates algorithm selection, hyperparameter tuning, and model evaluation
Batch InferenceInference on large volumes of data at scheduled intervals (e.g., nightly scoring of all customers)
Compute ClusterElastic compute resources in Azure for running training jobs (CPU/GPU)
Compute InstanceCloud VM for interactive development (notebooks)
Data DriftSignificant change in the distribution of input data compared to training data — signal of model degradation
DatastoreRegistered connection to a data source (Data Lake, Blob, SQL)
EndpointHTTP entry point for calling a deployed model (real-time or batch)
Experiment TrackingAutomatic recording of metrics, parameters, logs, and outputs for each training run
MLflowOpen-source framework for ML tracking and model management, natively integrated in Azure ML
MLOpsSet of practices applying DevOps principles (CI/CD, versioning, monitoring) to machine learning
Model RegistryCentral catalog for managing trained model versions with their metadata
Pipeline (ML)Automated and reproducible sequence of ML steps (ingestion → prep → training → eval → deploy)
RBACRole-Based Access Control — permission control by role in Azure
Real-time InferenceInstantaneous low-latency inference on demand (e.g., live recommendation on a website)
Scoring ScriptPython script (score.py) that loads the model and handles inference requests
WorkspaceCentral Azure ML workspace grouping all assets, experiments, models, and team configurations

Complete Reference Architecture

graph TB
    subgraph SOURCES["Data Sources"]
        ADL[Azure Data Lake]
        ASQL[Azure SQL]
        BLOB[Blob Storage]
    end

    subgraph WORKSPACE["Azure ML Workspace"]
        subgraph DEV["Development"]
            NB[Notebooks\nCompute Instance]
            AML_AUTO[AutoML]
            SDK[SDK / CLI\nCustom training]
        end

        subgraph TRACK["Tracking & Registry"]
            EXP[Experiment\nTracking]
            MODEL_REG[Model\nRegistry]
            DATA_REG[Dataset\nRegistry]
            ENV_REG[Environment\nRegistry]
        end

        subgraph COMPUTE["Compute"]
            CPU[CPU Cluster]
            GPU[GPU Cluster]
            AKS_COMP[AKS]
        end

        subgraph PIPE["Pipelines"]
            PREP[Data Prep]
            TRAIN[Training]
            EVAL[Evaluation]
            DEPLOY_STEP[Deploy]
        end

        subgraph ENDPOINTS_WS["Endpoints"]
            RT_EP[Real-time\nEndpoint]
            BATCH_EP[Batch\nEndpoint]
        end
    end

    subgraph SECURITY["Security"]
        ENTRA[Microsoft\nEntra ID]
        KV[Key Vault]
        VNT[VNet / PE]
    end

    subgraph MONITOR_OUT["Monitoring"]
        AZMON[Azure Monitor]
        APPINS[App Insights]
        LOG[Log Analytics]
    end

    subgraph CONSUMERS["Consumers"]
        PBI[Power BI]
        APP[SaaS\nApplication]
        API_CON[API Consumer]
    end

    SOURCES -->|Datastores| DATA_REG
    DATA_REG --> DEV
    DEV --> EXP
    EXP --> MODEL_REG
    MODEL_REG --> PIPE
    PIPE --> ENDPOINTS_WS
    COMPUTE --> PIPE
    ENV_REG --> PIPE

    SECURITY -->|Auth & secrets| WORKSPACE
    ENDPOINTS_WS --> MONITOR_OUT
    ENDPOINTS_WS --> CONSUMERS

Search Terms

azure · machine · ml · platforms · deployment · data · science · architecture · automl · lifecycle · mlops · model · workflows · business · case · cases · casey · collaboration · detailed · engineer · integration · manual · monitoring · pillars

Interested in this course?

Contact us to book it or get a custom training plan for your team.