(+351) 21 24 10006  ·  info@bconcepts.pt
Carnaxide, Lisbon
Azure AI & Machine Learning
Azure AI & Machine Learning 2 min

Azure Machine Learning: register models, endpoints and MLOps in production

João Barros 10 de March de 2025 2 min read

Azure Machine Learning is Microsoft's MLOps platform covering the full model lifecycle: experimentation, registration, deployment and monitoring. For teams that need governance and reproducibility in production.

Connect to the workspace

from azure.ai.ml import MLClient
from azure.identity import DefaultAzureCredential

ml_client = MLClient(
    credential=DefaultAzureCredential(),
    subscription_id=os.environ["AZURE_SUBSCRIPTION_ID"],
    resource_group_name="rg-ml-prod",
    workspace_name="aml-bconcepts"
)

Submit a training job

from azure.ai.ml import command
from azure.ai.ml.entities import Environment

job = command(
    code="./src",                            # folder with the code
    command="python train.py --data ${{inputs.training_data}} --output ${{outputs.model}}",
    inputs={"training_data": Input(type="uri_folder", path="azureml://datastores/workspaceblobstore/paths/data/")},
    outputs={"model": Output(type="mlflow_model")},
    environment="AzureML-sklearn-1.0-ubuntu20.04-py38-cpu@latest",
    compute="gpu-cluster",
    display_name="Churn_Training_v3"
)

returned_job = ml_client.jobs.create_or_update(job)
ml_client.jobs.stream(returned_job.name)    # follow the logs

Register and deploy the model

from azure.ai.ml.entities import Model, ManagedOnlineEndpoint, ManagedOnlineDeployment

# Register the model
model = ml_client.models.create_or_update(Model(
    path=f"azureml://jobs/{returned_job.name}/outputs/model",
    name="churn-prediction",
    type="mlflow_model"
))

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

# Deploy with auto-scaling
deployment = ManagedOnlineDeployment(
    name="blue",
    endpoint_name="churn-endpoint",
    model=f"churn-prediction:{model.version}",
    instance_type="Standard_DS3_v2",
    instance_count=1
)
ml_client.online_deployments.begin_create_or_update(deployment).result()

Invoke the endpoint

import json, urllib.request

data = json.dumps({"input_data": {"columns": ["feature1","feature2"], "data": [[0.5, 1.2]]}})
req  = urllib.request.Request(endpoint.scoring_uri, data.encode(), {"Authorization": f"Bearer {api_key}"})
resp = urllib.request.urlopen(req)
print(json.loads(resp.read()))

Conclusion

Azure ML consolidates the whole MLOps cycle in one platform with RBAC, versioned model registry, managed endpoints with auto-scaling and monitoring. For teams needing reproducibility and governance in production ML, it is the managed alternative to self-hosted solutions.

Share: