Supported output formats for Azure Sphere CLI (Preview)

Azure Sphere CLI supports several formats in which the data can be viewed. By default, it uses table as the default format for displaying the CLI output, but also supports other formats.

Note

This feature is in preview. It may be changed or removed in a future release. Using machine-readable structured output format is supported only in Azure Sphere CLI. Azure Sphere classic CLI only supports human-readable output and not machine-readable structured format such as JSON.

The argument values and the output types are:

Output format Description
table ASCII table with keys as column headings. This is the default format.
json JSON string.
jsonc Colorized JSON.
yaml YAML, a machine-readable alternative to JSON.
yamlc Colorized YAML.
tsv Tab-separated values, with no keys.
none No output other than errors and warnings.

Supported commands

You can specify the required output format for the command using --output, -out, or -o. If we’re missing a command that you need to script, let us know with azsphere feedback. It is supported for the following commands:

Table output format

The table format is the default format that prints output as an ASCII table, making it easy to read and scan. This format is best when you want a quick, human-searchable overview of data. It is useful for getting a summary of focused information, particularly for list commands.

azsphere tenant list --output table
 ------------------------------------ --------------------- -------------
 Id                                   Name                  Roles
 ========================================================================
 a323c263-2aa3-2559-aabb-a3fc32631900 Tenant1               Contributor
 ------------------------------------ --------------------- -------------
 183adhc9-a5c8-8he2-84a2-c4f00f73a471 Tenant2               Administrator
                                                            Contributor
 ------------------------------------ --------------------- -------------

JSON output format

JSON output format includes all raw data and nested data in a structured format. We recommend using the JSON output for concise output and scripting purposes.

The following example displays the list of tenants in the default JSON format.

azsphere tenant list --output json
[
  {
    "id": "a323c263-2aa3-2559-aabb-a3fc32631900",
    "name": "Tenant1",
    "roles": [
      "Contributor"
    ]
  },
  {
    "id": "183adhc9-a5c8-8he2-84a2-c4f00f73a471",
    "name": "Tenant2",
    "roles": [
      "Administrator",
      "Contributor"
    ]
  }
]

YAML output format

The yaml format prints output as YAML, a plain-text data serialization format. YAML tends to be easier to read than JSON.

azsphere tenant list --output yaml
- id: a323c263-2aa3-2559-aabb-a3fc32631900
  name: Tenant1
  roles:
  - Contributor
- id: 183adhc9-a5c8-8he2-84a2-c4f00f73a471
  name: Tenant2
  roles:
  - Administrator
  - Contributor

TSV output format

The tsv output format returns tab-separated and newline-separated values without additional formatting, keys, or other symbols. The tsv output is similar to the table output but differs in the following ways:

  • Column headers are not displayed in the tsv output.
  • The table output displays list and tsv displays the length of a list.
  • Nested objects are not printed in the tsv output.
  • The tsv output is tab separated and does not scale to fit the terminal.
azsphere tenant list --output tsv
a323c263-2aa3-2559-aabb-a3fc32631900    Tenant1       1
183adhc9-a5c8-8he2-84a2-c4f00f73a471    Tenant2   2