Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] az iot central device-template create does not accept DTDL v2 interfaces #364

Open
rido-min opened this issue Jun 3, 2021 · 5 comments

Comments

@rido-min
Copy link
Member

rido-min commented Jun 3, 2021

az iot central device-template create does not accept DTDL v2 interfaces

To Reproduce

Install the latest with az extension remove azure-iot && az extension add azure-iot

Follow the reference docs to create a device template

Use the next DTDL v2 Model as the input file

{
  "@context": "dtmi:dtdl:context;2",
  "@id": "dtmi:com:example:basic;1",
  "@type": "Interface",
  "displayName": "basic",
  "contents": [
    {
      "@type": "Telemetry",
      "name": "temperature",
      "schema": "double"
    }
  ]
}

Expected behavior
A device template is added to my central app

Observed behavior

{'code': 'InvalidBody', 
'message': "The provided request body contains the following errors: 

should have required property 'capabilityModel'; 

['@type'] should be array. 

Environment (please complete the following information):

C:\code> az --version
azure-cli                         2.19.1 *

core                              2.19.1 *
telemetry                          1.0.6

Extensions:
azure-iot                        0.10.13
interactive                        0.4.4

Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe'
Extensions directory 'C:\Users\rido2\.azure\cliextensions'

Python (Windows) 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 23 2018, 23:31:17) [MSC v.1916 32 bit (Intel)]
@rido-min
Copy link
Member Author

rido-min commented Jun 3, 2021

/c @sandeeppujar @avneet723

@yang-hai-feng
Copy link
Contributor

yang-hai-feng commented Jun 3, 2021

Try this

{
	"displayName": "Themostat Template 2",
	"capabilityModel": {
		"@id": "dtmi:com:test:Thermostat;1",
		"@type": "Interface",
		"contents": [
			{
				"@type": [
					"Telemetry",
					"Temperature"
				],
				"description": "Temperature in degrees Celsius.",
				"displayName": "Temperature",
				"name": "temperature",
				"schema": "double",
				"unit": "degreeCelsius"
			}
		],
		"description": "Reports current temperature and provides desired temperature control.",
		"displayName": "Thermostat"
	},
	"@id": "dtmi:com:test:mythemostat",
	"@type": [
		"ModelDefinition",
		"DeviceModel"
	],
	"@context": [
		"dtmi:iotcentral:context;2",
		"dtmi:dtdl:context;2"
	]
}

With command:
az iot central device-template create -n [applicationid] -k "yourrequest.json" --dtid "dtmi:com:test:mythemostat"

@rido-min
Copy link
Member Author

rido-min commented Jun 3, 2021

@yang-hai-feng can you point me to the docs describing that file format? It does not conform to the DTDL v2 spec.

/c @briancr-ms

@rido-min
Copy link
Member Author

rido-min commented Jun 3, 2021

@yang-hai-feng
I read in docs --dtid The ID of the target device template. Example: somedevicetemplate. but your example suggest to use a malformed dtmi (without the version) can you clarify?

@yang-hai-feng
Copy link
Contributor

@yang-hai-feng
I read in docs --dtid The ID of the target device template. Example: somedevicetemplate. but your example suggests using a malformed dtmi (without the version) can you clarify?

You are right, the example wasn't updated, as now --api-version preview will continue support legacy naming "somedevicetemplate", --api-version 1.0 will use the dtmi format, ignore the id example that I provided, we should have more specific documentation regarding this, I will create a bug to track this doc update.

@avneet723, do we have a link of official docs regarding IoT central device template?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants