Device template format exported from web UI does not work with CLI

Reported
Waqas Ilyas 1 Reputation point
2022-05-19T20:59:45.18+00:00

I can create a new device template in the Azure IoT Central app UI (at https://apps.azureiotcentral.com). I can also export a device template from this UI.

However, if I use the exported template to create template through the CLI, it doesn't work. In fact, if I run a 'az iot central device-template show' command, I see the device template content wrapped up in some surrounding JSON.

I could not find any documentation of the format for this JSON, and the difference between CLI and UI behavior. I want to find out what is the proper format to work with, and possibly share with others. And why there is this difference

Azure IoT Central
Azure IoT Central
An Azure hosted internet of things (IoT) application platform.
364 questions

1 answer

Sort by: Most helpful
  1. Dom 1,631 Reputation points Microsoft Employee
    2022-05-20T09:16:33.22+00:00

    There is a difference in the JSON format between what you can export in the UI and what you can export using 'az iot central device-template show' (or the REST API).

    In the UI, you can export a JSON document that's a DTDL v2 document - for more information about DTDL, see https://github.com/Azure/opendigitaltwins-dtdl and https://learn.microsoft.com/azure/iot-develop/overview-iot-plug-and-play. This document is sometimes referred to as a device model. DTDL is used by services other than IoT Central.

    Using the CLI (or REST API), you interact with device template. A device template is an IoT Central artifact that is a DTDL model with additional IoT Central specific data. As you pointed out, this document wraps the DTDL model. It also includes additional IoT Central specific information such as:

    • Cloud property definitions
    • Customizations
    • Additional schema elements such as 'displayUnit', 'maxValue', and 'minValue'.