az iot central device command

Note

This reference is part of the azure-iot extension for the Azure CLI (version 2.30.0 or higher). The extension will automatically install the first time you run an az iot central device command command. Learn more about extensions.

Run device commands.

Commands

az iot central device command history

Get the details for the latest command request and response sent to the device.

az iot central device command run

Run a command on a device and view associated response. Does NOT monitor property updates that the command may perform.

az iot central device command history

Get the details for the latest command request and response sent to the device.

Lists the most recent command request and response that was sent to the device from IoT Central. Any update that the device performs to the device properties as a result of the command execution are not included in the response.

az iot central device command history --app-id
                                      --cn
                                      --device-id
                                      [--api-version {1.0, 1.1-preview, 2022-05-31, preview}]
                                      [--central-api-uri]
                                      [--co]
                                      [--interface-id]
                                      [--mn]
                                      [--token]

Examples

Show command response

az iot central device command history --app-id {appid} --device-id {deviceid} --interface-id {interfaceid} --command-name {commandname}

Show component command response

az iot central device command history --app-id {appid} --device-id {deviceid} --component-name {componentname} --command-name {commandname}

Show module component command response

az iot central device command history --app-id {appid} --device-id {deviceid} --module-name {modulename} --component-name {componentname} --command-name {commandname}

Required Parameters

--app-id -n

The App ID of the IoT Central app you want to manage. You can find the App ID in the "About" page for your application under the help menu.

--cn --command-name

The command name as specified in the device template. Command name could be different from the Display Name of the command.

--device-id -d

The device ID of the target device.You can find the device ID by, clicking on the Connect button on the Device Details page.

Optional Parameters

--api-version --av

The API version for the requested operation.

accepted values: 1.0, 1.1-preview, 2022-05-31, preview
default value: 2022-05-31
--central-api-uri --central-dns-suffix

The IoT Central DNS suffix associated with your application.

default value: azureiotcentral.com
--co --component-name

The name of the device component.

--interface-id -i

The name of the interface/component as specified in the device template.You can find it by navigating to Device Template and view the interface/component identity under the corresponding device capability.

--mn --module-name

The name of the device module.

--token

If you'd prefer to submit your request without authenticating against the Azure CLI, you can specify a valid user token to authenticate your request. You must specify the type of key as part of the request. Learn more at https://aka.ms/iotcentraldocsapi.

az iot central device command run

Run a command on a device and view associated response. Does NOT monitor property updates that the command may perform.

--content can be inline json or file path.

az iot central device command run --app-id
                                  --cn
                                  --content
                                  --device-id
                                  [--api-version {1.0, 1.1-preview, 2022-05-31, preview}]
                                  [--central-api-uri]
                                  [--co]
                                  [--interface-id]
                                  [--mn]
                                  [--token]

Examples

Run command with inline payload. Payload should be under "request" in json string

az iot central device command run --app-id {appid} --device-id {deviceid} --interface-id {interfaceid} --command-name {commandname} --content '{"request": {payload}}'

Short run command with json payload path.

az iot central device command run -n {appid} -d {deviceid} -i {interfaceid} --cn {commandname} -k {payload_file_path}

Run component command.

az iot central device command run -n {appid} -d {deviceid} --co {componentname} --cn {commandname} -k {payload}

Run module component command.

az iot central device command run -n {appid} -d {deviceid} --mn {modulename} --co {componentname} --cn {commandname} -k {payload}

Required Parameters

--app-id -n

The App ID of the IoT Central app you want to manage. You can find the App ID in the "About" page for your application under the help menu.

--cn --command-name

The command name as specified in the device template. Command name could be different from the Display Name of the command.

--content -k

Configuration for request. Provide path to JSON file or raw stringified JSON. [File Path Example: ./path/to/file.json] [Stringified JSON Example: {'a': 'b'}].

--device-id -d

The device ID of the target device.You can find the device ID by, clicking on the Connect button on the Device Details page.

Optional Parameters

--api-version --av

The API version for the requested operation.

accepted values: 1.0, 1.1-preview, 2022-05-31, preview
default value: 2022-05-31
--central-api-uri --central-dns-suffix

The IoT Central DNS suffix associated with your application.

default value: azureiotcentral.com
--co --component-name

The name of the device component.

--interface-id -i

The name of the interface/component as specified in the device template.You can find it by navigating to Device Template and view the interface/component identity under the corresponding device capability.

--mn --module-name

The name of the device module.

--token

If you'd prefer to submit your request without authenticating against the Azure CLI, you can specify a valid user token to authenticate your request. You must specify the type of key as part of the request. Learn more at https://aka.ms/iotcentraldocsapi.