Deploying ML Models on Azure IoT Edge: A Complete Guide

We design and deploy artificial intelligence systems: from prototype to production-ready solutions. Our team combines expertise in machine learning, data engineering and MLOps to make AI work not in the lab, but in real business.
Showing 1 of 1All 1564 services
Deploying ML Models on Azure IoT Edge: A Complete Guide
Medium
~2-3 days
Frequently Asked Questions

AI Development Areas

AI Solution Development Stages

Latest works

  • image_website-b2b-advance_0.webp
    B2B ADVANCE company website development
    1347
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1247
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    948
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1183
  • image_logo-advance_0.webp
    B2B Advance company logo design
    642
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    921

With over 5 years of experience and 30+ successful deployments, we guarantee a robust edge solution. When deploying ML models at the edge, clients often face a bottleneck — network latency and data transfer costs. We offer a proven solution on Azure IoT Edge: models run locally, in containers, with orchestration from the cloud. This reduces latencies to milliseconds and saves up to 40% on traffic. Pricing: basic deployment from $1,500, custom modules from $5,000.

How to Deploy an ML Model on Azure IoT Edge

Azure's edge runtime runs containers (modules) on Edge devices with orchestration via IoT Hub. ML models from Azure Machine Learning are packaged into a Docker image and deployed via a deployment manifest. Integration with Azure Stream Analytics, Cognitive Services, ONNX Runtime — all under the hood.

IoT Edge runtime — two system containers: edgeAgent manages the lifecycle of modules according to the deployment manifest, edgeHub — a local MQTT/AMQP broker, message routing, and buffering during connection loss.

Deployment manifest (JSON) defines which modules to run, their parameters, and routes:

{
  "modulesContent": {
    "$edgeAgent": {
      "properties.desired": {
        "modules": {
          "MLInference": {
            "type": "docker",
            "settings": {
              "image": "myregistry.azurecr.io/ml-inference:1.2.0",
              "createOptions": "{\"HostConfig\":{\"Devices\":[{\"PathOnHost\":\"/dev/video0\"}]}}"
            }
          }
        }
      }
    },
    "$edgeHub": {
      "properties.desired": {
        "routes": {
          "MLToCloud": "FROM /messages/modules/MLInference/* INTO $upstream"
        }
      }
    }
  }
}

Step 1: Prepare ML Module via Azure Machine Learning

Workflow: training on compute cluster → register model in Model Registry → create IoT Edge package via Model.package() → push container to ACR → update manifest. Change the image version — IoT Hub automatically rolls out the update to the target group.

Step 2: Optimize with ONNX Runtime for Edge Inference

ONNX Runtime is a cross-platform engine with hardware optimization. On Intel CPU with OpenVINO, acceleration 2.5–3 times compared to pure Python; on NVIDIA Jetson via TensorRT — up to 5 times. Automated deployment via IoT Hub is 10 times faster than manual device updates. Example hardware-aware session:

import onnxruntime as ort

opts = ort.SessionOptions()
opts.graph_optimization_level = ort.GraphOptimizationLevel.ORT_ENABLE_ALL
opts.intra_op_num_threads = 4

providers = ['TensorrtExecutionProvider', 'CUDAExecutionProvider', 'CPUExecutionProvider']

session = ort.InferenceSession('model.onnx', opts, providers=providers)

def infer(image_np):
    input_name = session.get_inputs()[0].name
    return session.run(None, {input_name: image_np})

Ready-made Microsoft images: mcr.microsoft.com/azureml/onnxruntime:latest-openvino for Intel, :latest-jetpack for Jetson.

Module Interaction on the Edge

Module Twin and Direct Methods

Via module twin, change parameters on the fly (confidence threshold, model version) without rebuilding the container:

async def twin_patch_handler(patch):
    if 'modelVersion' in patch:
        await update_model(patch['modelVersion'])
    if 'confidenceThreshold' in patch:
        global THRESHOLD
        THRESHOLD = patch['confidenceThreshold']

module_client.on_twin_desired_properties_patch_received = twin_patch_handler

async def method_handler(method_request):
    if method_request.name == "GetStats":
        payload = {"fps": current_fps, "detections_today": counter}
        return MethodResponse.create_from_method_request(
            method_request, 200, payload)

Direct Methods — synchronous call from the cloud (timeout 30 s). Used for diagnostics, module restart, getting statistics.

Message Routing

edgeHub routes messages by source, topic, properties. Example: all frames with resolution above Full HD are sent to the HiResProcessor module, and detections with confidence >0.9 — directly to the cloud:

FROM /messages/modules/Camera/* WHERE $body.width > 1920 INTO modules/HiResProcessor/inputs/frames
FROM /messages/modules/MLInference/* WHERE $body.confidence > 0.9 INTO $upstream

Azure Stream Analytics on the Edge

For real-time aggregation without the cloud: average temperature over a 30-second window, anomalies — all locally. Results sent to another module or to the cloud when network becomes available.

SELECT
    System.Timestamp() as EventTime,
    AVG(temperature) as AvgTemp,
    COUNT(*) as Anomalies
INTO AlertOutput
FROM TemperatureInput TIMESTAMP BY EventTime
GROUP BY TumblingWindow(second, 30)
HAVING AVG(temperature) > 75 OR COUNT(*) > 10

Comparison of Deployment Methods

Method Speed Scaling Scenario
Manual manifest via portal 10–30 min Single devices Testing/debugging
Automatic Deployment 1–5 min Thousands of devices Industrial parks
DPS Zero-touch At first boot Millions Mass production

Comparison of Inference Backends

Backend Platform Acceleration Power consumption
OpenVINO Intel CPU (Xeon, Core) 2–3x vs Python Low
TensorRT NVIDIA GPU (Jetson, T4) 3–5x vs Python Medium
ONNX Runtime CPU Any x86/ARM 1.5–2x vs Python Minimal
Triton Inference Server NVIDIA GPU 2–4x vs Python Medium

Fleet Management via IoT Hub

Device Provisioning Service (DPS) — zero-touch provisioning: device registers with DPS at first boot, automatically assigned to IoT Hub and receives deployment. Automatic Deployments with target condition tags.location = 'factory-A' — rollout by groups with priorities.

Monitoring: Azure Monitor + built-in metrics (connected devices, messages/day). Custom metrics via send_message() with application properties for filtering in Log Analytics.

What Is Included in the Work

  • Infrastructure audit and inference requirements
  • Development and containerization of ML module (ONNX / TensorRT / OpenVINO)
  • Configuration of deployment manifest and routing
  • DPS integration for scaling
  • Documentation, training sessions, access to ACR, IoT Hub, and DPS
  • Technical support for 3 months

We guarantee stable operation under load: latency p99 < 200 ms on Jetson Nano with YOLOv5 model, uptime 99.9% during connection loss up to 4 hours.

Timeline: 3–6 weeks

Basic deployment with Azure ML model — 1–2 weeks. Custom modules, ASA Edge, OPC Publisher integration with industrial equipment, DPS fleet provisioning — 5–6 weeks. For MLOps edge scenarios, we integrate continuous deployment pipelines. Evaluate your project — contact us for a consultation. Request an audit of your infrastructure to get exact timelines and cost.

Source: Azure IoT Edge documentation

Edge AI and Optimization: How to Deploy Models Without Cloud?

Imagine: your face recognition model has 4 seconds latency on Jetson Orin, the battery runs out in an hour, and the model crashes with OOM. We are a team of Edge AI engineers with 5+ years in production — we have optimized over 150 models for edge devices. Without profiling and proper choice of quantization or distillation, the project is doomed. The gap between research code and edge deployment is a separate engineering discipline; we help you master it in 2–16 weeks turnkey. Edge AI and model optimization services are not just export, but systematic work with hardware.


Why Simply Exporting a Model Doesn't Work?

A PyTorch model with float32 and batch_size=32 is not ready for edge. Typical problems:

  • ResNet-50 in fp32 occupies 98 MB, inference on Cortex-A78 — 380 ms. After INT8 quantization via torch.ao.quantization — 24 MB, 95 ms. Export to ONNX + TensorRT on Jetson — 28 ms.
  • YOLOv8m on Raspberry Pi 5 in fp32 — 2.8 fps. TFLite INT8 — 9.4 fps. With XNNPACK delegate — 14 fps (1.5× faster than pure INT8).
  • Transformer encoder on mobile CPU: MobileBERT in fp16 via CoreML on iPhone 15 — 18 ms/inference. distilbert-base-uncased in ONNX — 42 ms.

The problem is not choosing "quantize or not" — the right path is determined by the device, task, and acceptable metric degradation. We offer an assessment of your project: within 24 hours we will tell you how feasible it is to speed up the model.


How to Choose Quantization Method for Your Task?

PTQ (Post-Training Quantization) — a quick path. Take a trained model, run a calibration dataset (200–1000 samples), get INT8 or INT4 weights. Tools: torch.ao.quantization, ONNX Runtime quantization tool, bitsandbytes. Accuracy degradation: 0.5–2% on classification. Red zone — small object detection and segmentation, where PTQ gives -4–8% mAP.

QAT (Quantization-Aware Training) — training with simulated quantization noise. More expensive (retraining), but degradation 0.1–0.5%. Justified when PTQ is unacceptable. In PyTorch — torch.ao.quantization.prepare_qat().

GPTQ / AWQ — for LLMs. AWQ better preserves quality at 4-bit quantization. llm-compressor from Neural Magic or autoawq are the main libraries.

Method Implementation Time Accuracy Degradation Tools
PTQ 1–2 days 0.5–2% (up to 8% on detection) torch.ao, ONNX RT, bitsandbytes
QAT 1–3 weeks 0.1–0.5% torch.ao.prepare_qat, TF Quantization
GPTQ/AWQ 3–7 days 1–3% (LLM) autoawq, llm-compressor

Potential savings from choosing the right method can be substantial — for example, reducing cloud inference costs by up to 70% when deploying to edge. Project cost is calculated individually based on model complexity and target platform.


When to Use Pruning vs Distillation?

Structural pruning removes channels or layers. torch.nn.utils.prune — basic tool. For transformers — attention head pruning (LTP, movement pruning). Result: ResNet-50 after removing 40% of channels with fine-tuning — -35% size, -28% latency, -1.2% top-1 accuracy.

Knowledge distillation — train a small student to mimic a large teacher. Classic via KLDivLoss on soft labels. Feature distillation on intermediate layers is more effective. Hugging Face DistilBERT: 66M vs 110M parameters, -40% latency, -3% on GLUE. This is a model compression technique.

Combined approach: distillation → pruning → QAT. Gives maximum effect on limited hardware. We recorded a case where a client achieved 70% reduction in cloud compute spend after moving to edge with this pipeline.


Target Platforms and Tools

Platform Preferred Format Tool Specifics
NVIDIA Jetson TensorRT engine trtexec, torch2trt INT8 calibration, DLA offload
Apple Silicon / iOS CoreML (.mlmodel) coremltools ANE (Neural Engine) automatically
Android TFLite (.tflite) tf.lite.TFLiteConverter GPU delegate, NNAPI
x86 CPU ONNX + ORT onnxruntime AVX-512, VNNI
Arm Cortex TFLite / ONNX ort-arm, tflite XNNPACK, NEON
Qualcomm NPU QNN (.dlc) Qualcomm AI Hub Hexagon DSP

TensorRT — the main tool for NVIDIA edge. TRT builds a graph with operator fusion, selects optimal kernels. On Jetson AGX Orin YOLOv8m in TRT INT8 gives 78 fps vs 22 fps in fp16 PyTorch — 3.5× improvement.


Practical Case: How We Detected Defects on a Production Line (Our Client)

Task: real-time scratch detection on metal, 30 fps, camera to Jetson Xavier NX (16GB). Original model YOLOv8l mAP50 0.91, server inference 28 ms, on Jetson in fp16 — 110 ms (9 fps). Not suitable.

Optimization steps we performed for our client:

  1. Switch to YOLOv8m — mAP50 0.887 (-2.3%), 68 ms
  2. Export to TensorRT FP16 via yolo export format=engine half=True — 31 ms (32 fps)
  3. INT8 calibration on 500 frames — 22 ms (45 fps), mAP50 0.879

Result: 3.5% degradation at 5× speedup. Client received engine and documentation. We guarantee metric will not drop below agreed threshold — specified in contract.

Example model profiling (layer latency)

Profile slice of YOLOv8m on Jetson Xavier NX (fp16):

  • Convolution (layer 1–5): 12 ms
  • Bottleneck (layer 6–10): 8 ms
  • Head (detection): 11 ms

Bottleneck is the last layers of the head. After quantizing the head separately, head latency dropped to 4 ms.


What is Included in the Work?

  • Report on model profiling on target device (layer latency, bottlenecks)
  • Selection and justification of optimization methods (quantization / pruning / distillation)
  • Optimized model (TensorRT engine / TFLite / CoreML / ONNX)
  • Configs for reproducibility (scripts, Docker image, instructions)
  • Testing on real device (at least 10,000 inferences)
  • Training of your team (2 hours online)
  • 1 month support after delivery

How to Order Model Optimization

  1. Submit a request on the website or contact us in any convenient way.
  2. We perform free profiling of your model on the target device within 24 hours.
  3. We prepare an optimization plan with trade-off estimates (speed vs quality).
  4. You approve the plan — we start work.
  5. After completion, we deliver the optimized model, configs, and documentation.
  6. We train your team and provide monthly support.

Timeline: optimization of an existing model — 2–4 weeks. Development from scratch for edge — 6–16 weeks.

Get a consultation — we will evaluate your model for free and offer a plan within 24 hours. Order free profiling now. For complex projects, contact our engineering team to discuss custom optimisation strategies.