az iot hub digital-twin
Note
This reference is part of the azure-iot extension for the Azure CLI (version 2.59.0 or higher). 當您第一次執行 az iot hub digital-twin 命令 時,擴充功能會自動安裝。 Learn more about extensions.
操作與 IoT 中樞 裝置的數字對應項互動。
命令
名稱 | Description | 類型 | 狀態 |
---|---|---|---|
az iot hub digital-twin invoke-command |
叫用數字對應項裝置的根或元件層級命令。 |
Extension | GA |
az iot hub digital-twin show |
顯示 IoT 中樞裝置的數字對應項。 |
Extension | GA |
az iot hub digital-twin update |
透過 JSON 修補程式規格更新數位對應項裝置的讀寫屬性。 |
Extension | GA |
az iot hub digital-twin invoke-command
叫用數字對應項裝置的根或元件層級命令。
az iot hub digital-twin invoke-command --cn --command-name
--device-id
[--component-path]
[--connect-timeout --cto]
[--hub-name]
[--login]
[--payload]
[--resource-group]
[--response-timeout --rto]
範例
一般而言,叫用命令,其會使用內嵌 JSON 接受包含特定屬性的承載。
az iot hub digital-twin invoke-command --command-name {command_name} -n {iothub_name} -d {device_id} --payload '{"property_name": "property_value"}'
叫用根層級命令 「重新啟動」,其接受符合 DTDL 模型 https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v2/samples/TemperatureController.json. 名為“delay” 的承載
az iot hub digital-twin invoke-command --command-name reboot -n {iothub_name} -d {device_id} --payload 5
在不需要輸入的元件 「thermostat1」 上叫用命令 「getMaxMinReport」。
az iot hub digital-twin invoke-command --cn getMaxMinReport -n {iothub_name} -d {device_id} --component-path thermostat1
必要參數
數字對應項命令名稱。
目標裝置標識碼。
選擇性參數
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
數字對應項元件路徑。 例如:控溫器1。
IoT 中樞嘗試連線到裝置的最大時間間隔,以秒為單位。
屬性 | 值 |
---|---|
Parameter group: | Timeout Arguments |
IoT 中樞 名稱或主機名。 如果未提供 --login,則為必要項。
屬性 | 值 |
---|---|
Parameter group: | IoT Hub Identifier Arguments |
此命令支援具有執行動作許可權的實體 連接字串。 使用來避免透過 「az login」 的工作階段登入。 如果提供實體 連接字串 和名稱,則 連接字串 優先使用。 如果未提供 --hub-name,則為必要專案。
屬性 | 值 |
---|---|
Parameter group: | IoT Hub Identifier Arguments |
命令的 JSON 承載輸入。 提供檔案路徑或內嵌 JSON。
屬性 | 值 |
---|---|
預設值: | {} |
資源組名。 您可以使用 az configure --defaults group=<name>
來設定預設群組。
數字對應項命令會等候結果的最大時間間隔,以秒為單位。
屬性 | 值 |
---|---|
Parameter group: | Timeout Arguments |
全域參數
提高日誌詳細程度以顯示所有調試日誌。
屬性 | 值 |
---|---|
預設值: | False |
顯示此說明訊息並結束。
只顯示錯誤,隱藏警告。
屬性 | 值 |
---|---|
預設值: | False |
Output format.
屬性 | 值 |
---|---|
預設值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/。
訂用帳戶的名稱或標識碼。 您可以使用 az account set -s NAME_OR_ID
來設定預設訂用帳戶。
增加記錄的詳細程度。 針對完整偵錯記錄使用 --debug。
屬性 | 值 |
---|---|
預設值: | False |
az iot hub digital-twin show
顯示 IoT 中樞裝置的數字對應項。
az iot hub digital-twin show --device-id
[--hub-name]
[--login]
[--resource-group]
範例
顯示目標裝置數字對應項。
az iot hub digital-twin show -n {iothub_name} -d {device_id}
必要參數
目標裝置標識碼。
選擇性參數
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
IoT 中樞 名稱或主機名。 如果未提供 --login,則為必要項。
屬性 | 值 |
---|---|
Parameter group: | IoT Hub Identifier Arguments |
此命令支援具有執行動作許可權的實體 連接字串。 使用來避免透過 「az login」 的工作階段登入。 如果提供實體 連接字串 和名稱,則 連接字串 優先使用。 如果未提供 --hub-name,則為必要專案。
屬性 | 值 |
---|---|
Parameter group: | IoT Hub Identifier Arguments |
資源組名。 您可以使用 az configure --defaults group=<name>
來設定預設群組。
全域參數
提高日誌詳細程度以顯示所有調試日誌。
屬性 | 值 |
---|---|
預設值: | False |
顯示此說明訊息並結束。
只顯示錯誤,隱藏警告。
屬性 | 值 |
---|---|
預設值: | False |
Output format.
屬性 | 值 |
---|---|
預設值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/。
訂用帳戶的名稱或標識碼。 您可以使用 az account set -s NAME_OR_ID
來設定預設訂用帳戶。
增加記錄的詳細程度。 針對完整偵錯記錄使用 --debug。
屬性 | 值 |
---|---|
預設值: | False |
az iot hub digital-twin update
透過 JSON 修補程式規格更新數位對應項裝置的讀寫屬性。
目前作業僅限於新增、取代和移除。
az iot hub digital-twin update --device-id
--json-patch --patch
[--etag]
[--hub-name]
[--login]
[--resource-group]
範例
透過 JSON 修補程式規格更新數位對應項。
az iot hub digital-twin update --hub-name {iothub_name} --device-id {device_id} --json-patch '{"op":"add", "path":"/thermostat1/targetTemperature", "value": 54}'
透過 JSON 修補程式規格更新數位對應項。
az iot hub digital-twin update -n {iothub_name} -d {device_id} --json-patch '[
{"op":"remove", "path":"/thermostat1/targetTemperature"},
{"op":"add", "path":"/thermostat2/targetTemperature", "value": 22}
]'
透過檔案中定義的 JSON 修補程式規格來更新數位對應項屬性。
az iot hub digital-twin update -n {iothub_name} -d {device_id} --json-patch ./my/patch/document.json
必要參數
目標裝置標識碼。
JSON 修補程式所描述的更新規格。 作業僅限於新增、取代和移除。 提供檔案路徑或內嵌 JSON。
選擇性參數
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
對應至資源最後狀態的 Etag 或實體標記。 如果未提供任何 etag,則會使用 『*』 值。
IoT 中樞 名稱或主機名。 如果未提供 --login,則為必要項。
屬性 | 值 |
---|---|
Parameter group: | IoT Hub Identifier Arguments |
此命令支援具有執行動作許可權的實體 連接字串。 使用來避免透過 「az login」 的工作階段登入。 如果提供實體 連接字串 和名稱,則 連接字串 優先使用。 如果未提供 --hub-name,則為必要專案。
屬性 | 值 |
---|---|
Parameter group: | IoT Hub Identifier Arguments |
資源組名。 您可以使用 az configure --defaults group=<name>
來設定預設群組。
全域參數
提高日誌詳細程度以顯示所有調試日誌。
屬性 | 值 |
---|---|
預設值: | False |
顯示此說明訊息並結束。
只顯示錯誤,隱藏警告。
屬性 | 值 |
---|---|
預設值: | False |
Output format.
屬性 | 值 |
---|---|
預設值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/。
訂用帳戶的名稱或標識碼。 您可以使用 az account set -s NAME_OR_ID
來設定預設訂用帳戶。
增加記錄的詳細程度。 針對完整偵錯記錄使用 --debug。
屬性 | 值 |
---|---|
預設值: | False |