Get familiar with the new, flexible, and programmable Azure Sphere CLI
Published Feb 02 2021 09:00 AM 4,158 Views

The recent 21.01 Azure Sphere SDK release includes a new version of the azsphere CLI that is easier to use in your shell and in your scripts. This CLI v2 is in Beta right now, but it will soon become the long-term stable version. Make sure you subscribe to notifications to find out when this happens. At that point, the current v1 CLI will be deprecated before being fully retired after a few further months. So it’s well worth familiarizing yourself now with how the CLI v2 can help you better develop and deploy with Azure Sphere devices. Let’s look at what this CLI offers:

  • The CLI v2 supports tab completion. This works for command names and parameter names in Powershell on Windows (you’ll need to configure it first) or in bash on Linux. Just type the first character or two, and press Tab and/or CTRL-Space as appropriate for your shell. (We’re working on making completion happen more quickly.)
  • The CLI v2 can be run in any shell. On Windows, it doesn’t require a dedicated Azure Sphere Developer command prompt—instead azsphere is already in your path. On Linux, you can choose to add it to your path during installation or you can just invoke it directly
  • The CLI v2 supports more flexible output. You can more easily automate CLI commands by writing scripts that consume JSON or yaml output. You can separate this “stdout” output from “stderr” related error and informational messages. You redirect it or paginate it with your favorite tools. And you can filter, modify, and sort it using the new --query option. Only some commands currently support these new output options: let us know via “azsphere feedback” if we’re missing a command that you need to script.
  • The CLI v2 offers back-compatibility. It does have some differences from the CLI v1 that are worth noting. However, in each subsequent release, we aim to maintain back-compatibility for both its input—command names, parameter names, parameter values—and its output in JSON and yaml. Or, if we ever can’t do this, we aim to provide at least six months’ notice of deprecation.   
  • The CLI v2 provides simplified object identification. Objects such as tenants, products, and device groups are now always identified via a single consistently named parameter (e.g. --product) with values that can be either an ID or a friendly name.
  • The CLI v2 aligns better with the Azure CLI for managing other Azure products. If you’re familiar with one of these CLIs, you’ll be right at home with the other. Look for this alignment to increase further in future releases.

We hope the CLI v2 makes it easier for you to work with Azure Sphere. Please let us know what more you’d like to see. Just run “azsphere feedback” to see the options available to ask questions, get support, and make suggestions.

Version history
Last update:
‎Mar 04 2021 01:38 PM
Updated by: