# espressif/esp-azure architecture

> Architecture diagram of the GitHub repository espressif/esp-azure, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/espressif/esp-azure
- Repository: https://github.com/espressif/esp-azure

## Overview

This is an ESP32 port of the Azure IoT C SDK, with sample applications for IoT Hub messaging, device twins/direct methods, and device provisioning. The main workflow is to run a sample on an ESP32, connect it to Azure using device credentials, and exchange messages or device-management data; the provisioning sample instead demonstrates DPS enrollment. The graph includes the sampled ESP platform and TLS adapter. Sample-to-cloud links follow the README’s product description and sample names; unsampled SDK internals are represented only as a subsystem.

Main entry points: [`examples/prov_dev_client_ll_sample/main/prov_dev_client_ll_sample.c`](https://github.com/espressif/esp-azure/blob/master/examples/prov_dev_client_ll_sample/main/prov_dev_client_ll_sample.c) (Provisioning Sample), [`examples/iothub_client_sample_mqtt/main/iothub_client_sample_mqtt.c`](https://github.com/espressif/esp-azure/blob/master/examples/iothub_client_sample_mqtt/main/iothub_client_sample_mqtt.c) (MQTT Sample), [`examples/iothub_devicetwin_samples_and_methods/main/iothub_client_device_twin_and_methods_sample.c`](https://github.com/espressif/esp-azure/blob/master/examples/iothub_devicetwin_samples_and_methods/main/iothub_client_device_twin_and_methods_sample.c) (Twin And Methods), [`port/src/platform_esp.c`](https://github.com/espressif/esp-azure/blob/master/port/src/platform_esp.c) (ESP Platform)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_samples["Device Samples"]
  node_mqtt_sample["MQTT Sample"]
  node_twin_sample["Twin And Methods"]
  node_dps_sample["Provisioning Sample"]
  node_custom_hsm["Custom X.509 HSM<br/>[custom_hsm_x509.c]"]
end

subgraph group_platform["ESP Platform"]
  node_esp_platform["ESP Platform<br/>[platform_esp.c]"]
  node_tls_adapter["ESP TLS Adapter<br/>[tlsio_esp_tls.c]"]
  node_tls_interface["TLS Interface<br/>[tlsio_pal.h]"]
  node_time_sync["SNTP Time<br/>[agenttime_esp.c]"]
  node_root_certs["Root Certificates<br/>[certs.c]"]
end

subgraph group_cloud["Azure Services"]
  node_azure_sdk["Azure IoT C SDK"]
  node_iot_hub(("Azure IoT Hub"))
  node_dps(("Device Provisioning Service"))
  node_azure_cli["Azure CLI"]
end

node_developer(("Developer"))
node_esp32(("ESP32 Device"))

node_developer -->|"runs sample"| node_mqtt_sample
node_developer -->|"runs sample"| node_twin_sample
node_developer -->|"runs sample"| node_dps_sample
node_mqtt_sample -->|"runs on"| node_esp32
node_twin_sample -->|"runs on"| node_esp32
node_dps_sample -->|"runs on"| node_esp32
node_mqtt_sample -->|"uses SDK"| node_azure_sdk
node_twin_sample -->|"uses SDK"| node_azure_sdk
node_dps_sample -->|"uses SDK"| node_azure_sdk
node_mqtt_sample -->|"connects to"| node_iot_hub
node_twin_sample -->|"manages device"| node_iot_hub
node_dps_sample -->|"enrolls device"| node_dps
node_dps_sample -.->|"uses"| node_custom_hsm
node_azure_cli -->|"manages device"| node_iot_hub
node_azure_cli -.->|"monitors events"| node_dps
node_esp_platform -->|"selects interface"| node_tls_adapter
node_esp_platform -->|"initializes time"| node_time_sync
node_tls_adapter -->|"implements interface"| node_tls_interface
node_esp_platform -->|"runs on"| node_esp32

click node_mqtt_sample "https://github.com/espressif/esp-azure/blob/master/examples/iothub_client_sample_mqtt/main/iothub_client_sample_mqtt.c"
click node_twin_sample "https://github.com/espressif/esp-azure/blob/master/examples/iothub_devicetwin_samples_and_methods/main/iothub_client_device_twin_and_methods_sample.c"
click node_dps_sample "https://github.com/espressif/esp-azure/blob/master/examples/prov_dev_client_ll_sample/main/prov_dev_client_ll_sample.c"
click node_custom_hsm "https://github.com/espressif/esp-azure/blob/master/examples/prov_dev_client_ll_sample/main/custom_hsm_x509.c"
click node_esp_platform "https://github.com/espressif/esp-azure/blob/master/port/src/platform_esp.c"
click node_tls_adapter "https://github.com/espressif/esp-azure/blob/master/port/src/tlsio_esp_tls.c"
click node_tls_interface "https://github.com/espressif/esp-azure/blob/master/port/inc/tlsio_pal.h"
click node_time_sync "https://github.com/espressif/esp-azure/blob/master/port/src/agenttime_esp.c"
click node_root_certs "https://github.com/espressif/esp-azure/blob/master/port/src/certs.c"
click node_azure_sdk "https://github.com/espressif/esp-azure/tree/master/azure-iot-sdk-c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_mqtt_sample,node_twin_sample,node_dps_sample,node_custom_hsm toneBlue
class node_esp_platform,node_tls_adapter,node_tls_interface,node_time_sync,node_root_certs toneAmber
class node_azure_sdk,node_iot_hub,node_dps,node_azure_cli toneMint
class node_developer,node_esp32 toneIndigo
```

## Components

### Device Samples

- [MQTT Sample](https://github.com/espressif/esp-azure/blob/master/examples/iothub_client_sample_mqtt/main/iothub_client_sample_mqtt.c): `examples/iothub_client_sample_mqtt/main/iothub_client_sample_mqtt.c`
- [Twin And Methods](https://github.com/espressif/esp-azure/blob/master/examples/iothub_devicetwin_samples_and_methods/main/iothub_client_device_twin_and_methods_sample.c): `examples/iothub_devicetwin_samples_and_methods/main/iothub_client_device_twin_and_methods_sample.c`
- [Provisioning Sample](https://github.com/espressif/esp-azure/blob/master/examples/prov_dev_client_ll_sample/main/prov_dev_client_ll_sample.c): `examples/prov_dev_client_ll_sample/main/prov_dev_client_ll_sample.c`
- [Custom X.509 HSM](https://github.com/espressif/esp-azure/blob/master/examples/prov_dev_client_ll_sample/main/custom_hsm_x509.c): `examples/prov_dev_client_ll_sample/main/custom_hsm_x509.c`

### ESP Platform

- [ESP Platform](https://github.com/espressif/esp-azure/blob/master/port/src/platform_esp.c): `port/src/platform_esp.c`
- [ESP TLS Adapter](https://github.com/espressif/esp-azure/blob/master/port/src/tlsio_esp_tls.c): `port/src/tlsio_esp_tls.c`
- [TLS Interface](https://github.com/espressif/esp-azure/blob/master/port/inc/tlsio_pal.h): `port/inc/tlsio_pal.h`
- [SNTP Time](https://github.com/espressif/esp-azure/blob/master/port/src/agenttime_esp.c): `port/src/agenttime_esp.c`
- [Root Certificates](https://github.com/espressif/esp-azure/blob/master/port/src/certs.c): `port/src/certs.c`

### Azure Services

- [Azure IoT C SDK](https://github.com/espressif/esp-azure/tree/master/azure-iot-sdk-c): `azure-iot-sdk-c`
- **Azure IoT Hub**
- **Device Provisioning Service**
- **Azure CLI**

### Other components

- **Developer**
- **ESP32 Device**

## Connections

- Developer → MQTT Sample: runs sample (evidence: `README.md`)
- Developer → Twin And Methods: runs sample (evidence: `README.md`)
- Developer → Provisioning Sample: runs sample (evidence: `README.md`)
- MQTT Sample → ESP32 Device: runs on (evidence: `README.md`)
- Twin And Methods → ESP32 Device: runs on (evidence: `README.md`)
- Provisioning Sample → ESP32 Device: runs on (evidence: `README.md`)
- MQTT Sample → Azure IoT C SDK: uses SDK (evidence: `README.md`)
- Twin And Methods → Azure IoT C SDK: uses SDK (evidence: `README.md`)
- Provisioning Sample → Azure IoT C SDK: uses SDK (evidence: `README.md`)
- MQTT Sample → Azure IoT Hub: connects to (evidence: `README.md`)
- Twin And Methods → Azure IoT Hub: manages device (evidence: `README.md`)
- Provisioning Sample → Device Provisioning Service: enrolls device (evidence: `README.md`)
- Provisioning Sample → Custom X.509 HSM: uses
- Azure CLI → Azure IoT Hub: manages device (evidence: `README.md`)
- Azure CLI → Device Provisioning Service: monitors events
- ESP Platform → ESP TLS Adapter: selects interface (evidence: `port/src/platform_esp.c`)
- ESP Platform → SNTP Time: initializes time (evidence: `port/src/platform_esp.c`)
- ESP TLS Adapter → TLS Interface: implements interface (evidence: `port/src/tlsio_esp_tls.c`)
- ESP Platform → ESP32 Device: runs on (evidence: `README.md`)
