Azure Sphere CLI interactive mode (Preview)
Important
This is the Azure Sphere (Legacy) documentation. Azure Sphere (Legacy) is retiring on 27 September 2027, and users must migrate to Azure Sphere (Integrated) by this time. Use the Version selector located above the TOC to view the Azure Sphere (Integrated) documentation.
Azure Sphere CLI supports interactive mode which provides an interactive environment to run Azure Sphere CLI commands, which is ideal for new users learning the CLI’s capabilities, command structures, and output formats. You can start the interactive mode using the azsphere interactive command in a command-line interface using PowerShell, Windows Command Prompt, or Bash shell. The command prompt changes to azsphere>>
to indicate that you are now running commands in the interactive shell.
Important
This feature is in preview. It may be changed or removed in a future release.
Configure
Interactive mode optionally displays command descriptions, parameter descriptions, and command examples.
Option | Description |
---|---|
F1 | Turns descriptions and examples on or off. |
F2 | Turns the display of parameter defaults on or off. |
F3 | Toggles the display of some key gestures. |
[Ctrl+D] | Exits the interactive mode. |
Set scope
The interactive mode allows you to scope commands to a specific group of commands. If you only want to work with device certificate
commands, you can use the following to set the right scope so that you don’t have to type device certificate
with all subsequent commands.
For example, when you set the scope as %%device certificate
:
azsphere>> %%device certificate
defaulting: device
defaulting: certificate
azsphere device certificate>>
To remove the scope enter, $ %% ..
and to remove all scoping enter, %%
.
Examples
The interactive mode lists examples for some commands contextually as you type the commands. If the command has too many examples to fit on the terminal window, you can look through all examples by scrolling through the example pane with CTRL+Y and CTRL+N for ‘up’ and ‘down’, respectively.
The interactive mode provides multiple ways to create and run the command. The example number is indicated in the example pane. You can select a specific one to view in the example pane. For example:
Autocompletion
The interactive mode displays the result for the entered command. It provides an autocomplete dropdown list box, auto cached suggestions, and dynamic documentation including examples of how each command is used. Parameter value completion is supported for the --application-update
, --debug-mode
, --device
, --device-group
, --enable-rt-core-debugging
, --force
, --full
, --manual-start
, --none
, --os-feed
, --product
, --role
, --state
, --style
, --targeted-scan
, --temporary
, --tenant
, --type
, and --user
parameters.
Frequently used commands
Interactive mode keeps track of previously typed commands and the most frequently used commands. The command is displayed when the initial characters are typed in command-prompt interface.
Exit code
The $
option allows you to see the exit code of the last ran command to verify it ran properly. For example:
azsphere>> $
Success: 0
Commands outside the interactive mode
Azure Sphere CLI interactive mode allows a user to run commands outside of Azure Sphere CLI without exiting the interactive mode by using #[command]
in the command-line interface. For example:
azsphere>> #git --version
git version 2.28.0.windows.1
Query Previous Command
You can run a JMESPath query on the results of the last command that you ran by using ??
followed by a JMESPath query. For instance after listing all products, you can run the query to list only the product names.
azsphere>> azsphere product list
------------------------------------ ------------------------------------ --------------- --------------------
Id TenantId Name Description
==============================================================================================================
a2cd64be-adc2-4bfd-8f34-7d8c90293893 143adbc9-1bf0-4be2-84a2-084a331d81cb MyFridgeProduct None
------------------------------------ ------------------------------------ --------------- --------------------
e5fe65f7-0df5-481e-9f4c-44b1a00d2d60 143adbc9-1bf0-4be2-84a2-084a331d81cb CoffeeMaker None
------------------------------------ ------------------------------------ --------------- --------------------
The output for the jmespath query will be:
azsphere>> ??"[].{Productname:name}"
[
{
"Productname": "MyFridgeProduct"
},
{
"Productname": "CoffeeMaker"
}
]