Get familiar with the new, flexible, and programmable Azure Sphere CLI

Published Feb 02 2021 09:00 AM 1,555 Views
Microsoft

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.

%3CLINGO-SUB%20id%3D%22lingo-sub-2071919%22%20slang%3D%22en-US%22%3EGet%20familiar%20with%20the%20new%2C%20flexible%2C%20and%20programmable%20Azure%20Sphere%20CLI%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2071919%22%20slang%3D%22en-US%22%3E%3CP%3EThe%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Finternet-of-things%2Fazure-sphere-version-21-01-is-now-available%2Fba-p%2F2107720%22%20target%3D%22_blank%22%3Erecent%2021.01%20Azure%20Sphere%20SDK%20release%3C%2FA%3E%20includes%20a%20new%20version%20of%20the%20%3CSTRONG%3Eazsphere%3C%2FSTRONG%3E%20CLI%20that%20is%20easier%20to%20use%20in%20your%20shell%20and%20in%20your%20scripts.%20This%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure-sphere%2Freference%2Fazsphere-cli-v2%3Ftabs%3Dcliv2beta%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3ECLI%20v2%3C%2FA%3E%26nbsp%3Bis%20in%20Beta%20right%20now%2C%20but%20it%20will%20soon%20become%20the%20long-term%20stable%20version.%20Make%20sure%20you%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure-sphere%2Finstall%2Fget-notifications%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Esubscribe%20to%20notifications%3C%2FA%3E%20to%20find%20out%20when%20this%20happens.%20At%20that%20point%2C%20the%20current%20v1%20CLI%20will%20be%20deprecated%20before%20being%20fully%20retired%20after%20a%20few%20further%20months.%20So%20it%E2%80%99s%20well%20worth%20familiarizing%20yourself%20now%20with%20how%20the%20CLI%20v2%20can%20help%20you%20better%20develop%20and%20deploy%20with%20Azure%20Sphere%20devices.%20Let%E2%80%99s%20look%20at%20what%20this%20CLI%20offers%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3EThe%20CLI%20v2%20supports%20tab%20completion.%3C%2FSTRONG%3E%26nbsp%3BThis%20works%20for%20command%20names%20and%20parameter%20names%20in%20Powershell%20on%20Windows%20(you%E2%80%99ll%20need%20to%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure-sphere%2Freference%2Fazsphere-cli-v2%3Ftabs%3Dcliv2beta%23tab-completion%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Econfigure%20it%20first%3C%2FA%3E)%20or%20in%20bash%20on%20Linux.%20Just%20type%20the%20first%20character%20or%20two%2C%20and%20press%20Tab%20and%2For%20CTRL-Space%20as%20appropriate%20for%20your%20shell.%20(We%E2%80%99re%20working%20on%20making%20completion%20happen%20more%20quickly.)%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EThe%20CLI%20v2%20can%20be%20run%20in%20any%20shell.%3C%2FSTRONG%3E%26nbsp%3BOn%20Windows%2C%20it%20doesn%E2%80%99t%20require%20a%20dedicated%20Azure%20Sphere%20Developer%20command%20prompt%E2%80%94instead%20%3CSTRONG%3Eazsphere%3C%2FSTRONG%3E%20is%20already%20in%20your%20path.%20On%20Linux%2C%20you%20can%20choose%20to%20add%20it%20to%20your%20path%20during%20installation%20or%20you%20can%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure-sphere%2Freference%2Fazsphere-cli-v2%3Ftabs%3Dcliv1%23run-the-azure-sphere-cli%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ejust%20invoke%20it%20directly%3C%2FA%3E.%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EThe%20CLI%20v2%20supports%20more%20%3C%2FSTRONG%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure-sphere%2Freference%2Fazsphere-ps-format-output%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%3CSTRONG%3Eflexible%20output%3C%2FSTRONG%3E%3C%2FA%3E%3CSTRONG%3E.%3C%2FSTRONG%3E%26nbsp%3BYou%20can%20more%20easily%20automate%20CLI%20commands%20by%20writing%20scripts%20that%20consume%20JSON%20or%20yaml%20output.%20You%20can%20separate%20this%20%E2%80%9Cstdout%E2%80%9D%20output%20from%20%E2%80%9Cstderr%E2%80%9D%20related%20error%20and%20informational%20messages.%20You%20redirect%20it%20or%20paginate%20it%20with%20your%20favorite%20tools.%20And%20you%20can%20filter%2C%20modify%2C%20and%20sort%20it%20using%20the%20new%20--query%20option.%20Only%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure-sphere%2Freference%2Fazsphere-ps-format-output%23supported-commands%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Esome%20commands%3C%2FA%3E%20currently%20support%20these%20new%20output%20options%3A%20let%20us%20know%20via%20%E2%80%9Cazsphere%20feedback%E2%80%9D%20if%20we%E2%80%99re%20missing%20a%20command%20that%20you%20need%20to%20script.%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EThe%20CLI%20v2%20offers%20back-compatibility.%3C%2FSTRONG%3E%26nbsp%3BIt%20does%20have%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure-sphere%2Freference%2Fazsphere-cli-v2%3Ftabs%3Dcliv2beta%23key-updates%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Esome%20differences%20from%20the%20CLI%20v1%3C%2FA%3E%20%3CSPAN%3Ethat%20are%20worth%20noting.%20However%2C%20in%20each%20subsequent%20release%2C%20we%20aim%20to%20maintain%20back-compatibility%20for%20both%20its%20input%E2%80%94command%20names%2C%20parameter%20names%2C%20parameter%20values%E2%80%94and%20its%20output%20in%20JSON%20and%20yaml.%20Or%2C%20if%20we%20ever%20can%E2%80%99t%20do%20this%2C%20we%20aim%20to%20provide%20at%20least%20six%20months%E2%80%99%20notice%20of%20deprecation.%26nbsp%3B%20%26nbsp%3B%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EThe%20CLI%20v2%20provides%20%3C%2FSTRONG%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure-sphere%2Freference%2Fazsphere-cli-v2%23simplified-object-identification%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%3CSTRONG%3Esimplified%20object%20identification%3C%2FSTRONG%3E%3C%2FA%3E%3CSTRONG%3E.%3C%2FSTRONG%3E%26nbsp%3BObjects%20such%20as%20tenants%2C%20products%2C%20and%20device%20groups%20are%20now%20always%20identified%20via%20a%20single%20consistently%20named%20parameter%20(e.g.%20--product)%20with%20values%20that%20can%20be%20either%20an%20ID%20or%20a%20friendly%20name.%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EThe%20CLI%20v2%20aligns%20better%20with%20the%20%3C%2FSTRONG%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fcli%2Fazure%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%3CSTRONG%3EAzure%20CLI%3C%2FSTRONG%3E%3C%2FA%3E%3CSTRONG%3E%20for%20managing%20other%20Azure%20products.%3C%2FSTRONG%3E%26nbsp%3BIf%20you%E2%80%99re%20familiar%20with%20one%20of%20these%20CLIs%2C%20you%E2%80%99ll%20be%20right%20at%20home%20with%20the%20other.%20Look%20for%20this%20alignment%20to%20increase%20further%20in%20future%20releases.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EWe%20hope%20the%20CLI%20v2%20makes%20it%20easier%20for%20you%20to%20work%20with%20Azure%20Sphere.%20Please%20let%20us%20know%20what%20more%20you%E2%80%99d%20like%20to%20see.%20Just%20run%20%E2%80%9Cazsphere%20feedback%E2%80%9D%20to%20see%20the%20options%20available%20to%20ask%20questions%2C%20get%20support%2C%20and%20make%20suggestions.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2071919%22%20slang%3D%22en-US%22%3E%3CP%3EThe%20Azure%20Sphere%20SDK%20now%20includes%20a%20new%20version%20of%20the%20%3CSTRONG%3Eazsphere%3C%2FSTRONG%3E%20CLI%20that%20is%20easier%20to%20use%20in%20your%20shell%20and%20in%20your%20scripts%E2%80%94find%20out%26nbsp%3B%3CSPAN%3Ehow%20it%20can%20help%20you%20better%20develop%20and%20deploy%20with%20Azure%20Sphere%3C%2FSPAN%3E.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22CLO20b_Sylvie_office_night_001_small.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F247311i2DA4B23A5068AD9E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22CLO20b_Sylvie_office_night_001_small.jpg%22%20alt%3D%22CLO20b_Sylvie_office_night_001_small.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-TEASER%3E
Co-Authors
Version history
Last update:
‎Mar 04 2021 01:38 PM
Updated by: