You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/digital-twins/concepts-cli.md
+63-2Lines changed: 63 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ titleSuffix: Azure Digital Twins
5
5
description: Learn about the Azure Digital Twins CLI command set.
6
6
author: baanders
7
7
ms.author: baanders # Microsoft employees only
8
-
ms.date: 02/28/2022
8
+
ms.date: 03/31/2022
9
9
ms.topic: conceptual
10
10
ms.service: digital-twins
11
11
@@ -17,7 +17,7 @@ ms.service: digital-twins
17
17
18
18
# Azure Digital Twins CLI command set
19
19
20
-
Apart from managing your Azure Digital Twins instance in the Azure portal, Azure Digital Twins also has a command set for the [Azure CLI](/cli/azure/what-is-azure-cli) that you can use to do most major actions with the service. This article covers the [Azure CLI](/cli/azure/what-is-azure-cli) in terms of its uses, how to get it, and the requirements for using it.
20
+
Apart from managing your Azure Digital Twins instance in the Azure portal, Azure Digital Twins also has a command set for the [Azure CLI](/cli/azure/what-is-azure-cli) that you can use to do most major actions with the service. This article covers the Azure CLI command set for Azure Digital twins including its uses, how to get it, and the requirements for using it.
21
21
22
22
Some of the actions you can do using the command set include:
23
23
* Managing an Azure Digital Twins instance
@@ -61,6 +61,67 @@ Otherwise, you can use the following command to install the extension yourself a
61
61
az extension add --upgrade --name azure-iot
62
62
```
63
63
64
+
## Use special characters in different shells
65
+
66
+
Some `az dt` commands use special characters that may have to be escaped for proper parsing in certain shell environments. Use the tips in this section to help you know when to do this in your shell of choice.
67
+
68
+
### Bash
69
+
70
+
Use these special character tips for Bash environments.
71
+
72
+
#### Queries
73
+
74
+
In many twin queries, the `$` character is used to reference the `$dtId` property of a twin. When using the [az dt twin query](/cli/azure/dt/twin#az-dt-twin-query) command to query in the Cloud Shell Bash environment, escape the `$` character with a backslash (`\`).
75
+
76
+
Here is an example of querying for a twin with a CLI command in the Cloud Shell Bash environment:
77
+
78
+
```azurecli
79
+
az dt twin query -n <instance-name> -q "SELECT * FROM DigitalTwins T Where T.\$dtId = 'room0'"
80
+
```
81
+
82
+
### PowerShell
83
+
84
+
Use these special character tips for PowerShell environments.
85
+
86
+
#### Inline JSON
87
+
88
+
Some commands, like [az dt twin create](/cli/azure/dt/twin#az-dt-twin-create), allow you to enter twin information in the form of inline JSON. When entering inline JSON in the PowerShell environment, escape double quote characters (`"`) inside the JSON with a backslash (`\`).
89
+
90
+
Here is an example of creating a twin with a CLI command in PowerShell:
>Many of the commands that support inline JSON also support input as a file path, which can help you avoid shell-specific text requirements.
98
+
99
+
#### Queries
100
+
101
+
In many twin queries, the `$` character is used to reference the `$dtId` property of a twin. When using the [az dt twin query](/cli/azure/dt/twin#az-dt-twin-query) command to query in a PowerShell environment, escape the `$` character with a backtick character.
102
+
103
+
Here is an example of querying for a twin with a CLI command in PowerShell:
104
+
```azurecli
105
+
az dt twin query -n <instance-name> -q "SELECT * FROM DigitalTwins T Where T.`$dtId = 'room0'"
106
+
```
107
+
108
+
### Windows CMD
109
+
110
+
Use these special character tips for the local Windows CMD.
111
+
112
+
#### Inline JSON
113
+
114
+
Some commands, like [az dt twin create](/cli/azure/dt/twin#az-dt-twin-create), allow you to enter twin information in the form of inline JSON. When entering inline JSON in a local Windows CMD window, enclose the parameter value with double quotes (`"`) instead of single quotes (`'`), and escape double quote characters inside the JSON with a backslash (`\`).
115
+
116
+
Here is an example of creating a twin with a CLI command in the local Windows CMD:
Copy file name to clipboardExpand all lines: articles/digital-twins/how-to-ingest-iot-hub-data.md
+6-1Lines changed: 6 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,9 +57,14 @@ To create a thermostat-type twin, you'll first need to upload the thermostat [mo
57
57
You'll then need to create one twin using this model. Use the following command to create a thermostat twin named thermostat67, and set 0.0 as an initial temperature value.
>If you're using anything other than Cloud Shell in the Bash environment, you may need to escape certain characters in the inline JSON so that it's parsed correctly.
65
+
>
66
+
>For more information, see [Use special characters in different shells](concepts-cli.md#use-special-characters-in-different-shells).
67
+
63
68
When the twin is created successfully, the CLI output from the command should look something like this:
description: Learn how to diagnose and resolve parsing failures with the Azure Digital Twins CLI command set.
5
+
ms.service: digital-twins
6
+
author: baanders
7
+
ms.author: baanders
8
+
ms.topic: troubleshooting
9
+
ms.date: 03/31/2022
10
+
---
11
+
12
+
# Troubleshoot parsing failures with Azure Digital Twins CLI commands
13
+
14
+
This article describes causes and resolution steps for various "parse failed" errors while running [az dt](/cli/azure/dt) commands in the Azure CLI.
15
+
16
+
## Symptoms
17
+
18
+
While attempting to run select `az dt` commands in an Azure CLI environment, you receive an error indicating that the command wasn't parsed correctly. The error message might include the words *parse failed* or *failed to parse*, or partial text from your command may be marked as *unrecognized arguments.*
19
+
20
+
## Causes
21
+
22
+
### Cause #1
23
+
24
+
Some `az dt` commands use special characters that have to be escaped for proper parsing in certain shell environments. It is possible that some special character in your CLI command needs to be escaped for it to be parsed in the shell that you're using.
25
+
26
+
## Solutions
27
+
28
+
### Solution #1
29
+
30
+
Use the full error message text to help you determine which character is causing an issue. Then, try escaping instances of this character with a backslash or a backtick. For a list of some specific characters that need to be escaped in certain shells, see [Use special characters in different shells](concepts-cli.md#use-special-characters-in-different-shells).
31
+
32
+
### Solution #2
33
+
34
+
If you're encountering the parsing issue while passing inline JSON into a command (like [az dt model create](/cli/azure/dt/model#az-dt-model-create) or [az dt twin create](/cli/azure/dt/twin#az-dt-twin-create)), check whether the command allows you to pass in a file instead. Many of the commands that support inline JSON also support input as a file path, which can help you avoid shell-specific text requirements.
35
+
36
+
### Solution #3
37
+
38
+
Not all shells have the same special character requirements, so you can try running the command in a different shell type (some options are the [Cloud Shell](https://shell.azure.com) Bash environment, [Cloud Shell](https://shell.azure.com) PowerShell environment, local Windows CMD, local Bash window, or local PowerShell window).
39
+
40
+
## Next steps
41
+
42
+
Read more about the CLI for Azure Digital Twins:
43
+
*[Azure Digital Twins CLI command set](concepts-cli.md)
Copy file name to clipboardExpand all lines: articles/digital-twins/tutorial-command-line-cli.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -143,7 +143,9 @@ To create a digital twin, you use the [az dt twin create](/cli/azure/dt/twin#az-
143
143
```
144
144
145
145
>[!NOTE]
146
-
> It's recommended to use the CLI in the Bash environment for this tutorial. If you're using the PowerShell environment, you may need to escape the quotation mark characters in order for the `--properties` JSON value to be parsed correctly.
146
+
>If you're using anything other than Cloud Shell in the Bash environment, you may need to escape certain characters in the inline JSON so that it's parsed correctly.
147
+
>
148
+
>For more information, see [Use special characters in different shells](concepts-cli.md#use-special-characters-in-different-shells).
147
149
148
150
The output from each command will show information about the successfully created twin (including properties for the room twins that were initialized with them).
0 commit comments