az iot central device command

Note

This reference is part of the azure-iot extension for the Azure CLI (version 2.37.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

Name Description Type Status
az iot central device command history

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

Extension GA
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.

Extension GA

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 {2022-06-30-preview, 2022-07-31}]
                                      [--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
Deprecated

Argument 'api_version' has been deprecated and will be removed in a future release.

This command parameter has been deprecated and will be ignored.In the future release, we will only support IoT Central APIs from latest GA version.If any API is not GA yet, we will call latest preview version.

accepted values: 2022-06-30-preview, 2022-07-31
default value: 2022-07-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.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

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 {2022-06-30-preview, 2022-07-31}]
                                  [--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
Deprecated

Argument 'api_version' has been deprecated and will be removed in a future release.

This command parameter has been deprecated and will be ignored.In the future release, we will only support IoT Central APIs from latest GA version.If any API is not GA yet, we will call latest preview version.

accepted values: 2022-06-30-preview, 2022-07-31
default value: 2022-07-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.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.