Skip to content
Learni
View all tutorials
Cloud & IA

How to Get Started with Azure Machine Learning in 2026

Lire en français

Introduction

Azure Machine Learning enables you to create, train, and deploy machine learning models at scale. This tutorial guides you step by step from creating a workspace to deploying a simple model. You will learn how to use the Python SDK and CLI to automate your workflows. This guide is designed for beginners who want to quickly practice with functional, ready-to-use code.

Prerequisites

  • Active Azure account with a subscription
  • Python 3.10 or higher installed
  • Azure CLI version 2.50+
  • Basic knowledge of Python and machine learning

Azure CLI Installation

terminal
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
az login
az extension add -n ml

This command installs Azure CLI and the Machine Learning extension. It then allows you to manage Azure resources directly from the terminal.

Workspace Creation

terminal
az group create --name rg-ml-demo --location francecentral
az ml workspace create --name ws-ml-demo --resource-group rg-ml-demo

These commands create a resource group and an Azure ML workspace. The workspace centralizes all your experiments, models, and endpoints.

Python SDK Setup

terminal
pip install azure-ai-ml azure-identity pandas scikit-learn

Install the necessary libraries to interact with Azure ML and train a simple model with scikit-learn.

Training Script

train.py
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
import joblib

X, y = load_iris(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
model = RandomForestClassifier()
model.fit(X_train, y_train)
joblib.dump(model, 'model.pkl')
print('Modèle entraîné avec succès')

Complete script that loads the Iris dataset, trains a RandomForest, and saves the model. It is ready to be executed as an Azure ML job.

Job Submission

submit_job.py
from azure.ai.ml import MLClient
from azure.identity import DefaultAzureCredential
from azure.ai.ml.entities import CommandJob

ml_client = MLClient(DefaultAzureCredential(), subscription_id='votre-id', resource_group_name='rg-ml-demo', workspace_name='ws-ml-demo')
job = CommandJob(command='python train.py', code='.', environment='azureml:AzureML-sklearn-1.0-ubuntu20.04-py38-cpu@latest', compute='cpu-cluster')
ml_client.jobs.create_or_update(job)

This code submits the training script as an Azure ML job. Replace subscription_id with your actual identifier.

Model Deployment

deploy.py
from azure.ai.ml.entities import ManagedOnlineEndpoint, ManagedOnlineDeployment

endpoint = ManagedOnlineEndpoint(name='iris-endpoint', auth_mode='key')
ml_client.online_endpoints.begin_create_or_update(endpoint)
deployment = ManagedOnlineDeployment(name='blue', endpoint_name='iris-endpoint', model='model.pkl', instance_type='Standard_DS2_v2', instance_count=1)
ml_client.online_deployments.begin_create_or_update(deployment)

Creates a managed endpoint and deploys the model to production with a CPU instance. The endpoint is accessible via REST API.

Best Practices

  • Always version your models and datasets
  • Use managed environments for reproducibility
  • Configure compute clusters with autoscaling
  • Monitor metrics with Azure Monitor
  • Protect endpoints with authentication keys

Common Errors

  • Forgetting to create a compute cluster before submitting a job
  • Not managing dependencies correctly in the environment
  • Using local paths instead of Azure datastores
  • Ignoring RBAC permissions on the workspace

Going Further

Discover our complete training courses on Azure and Machine Learning at Learni Group.