Loading...

Mastering the Shorthand Syntax in your daily workflow

Mastering the Shorthand Syntax in your daily workflow

Introduction

In this tech blog, we'll unravel the magic behind Azure CLI shorthand syntax and discover how it can elevate your command-line experience.

By unlocking the potential of Azure CLI Shorthand Syntax, we want to make your command-line experience as smooth as possible.

 

Quick walkthrough

  • Full Value Format: JSON without the quotes, making complex objects a breeze.
az some-command --contact "{name:Bill,age:20,paid:true,emails:[[email protected],[email protected]],address:{country:USA,company:Microsoft,details:{line1:'15590 NE 31st St',line2:'Redmond, WA'}}}"
  • Partial Value Format: Simplifying commands with key-value simplicity.

 

az some-command --contact name=Bill az some-command --contact age=20 paid=true az some-command --contact emails[1]="[email protected]" az some-command --contact address.details="{line1:'15590 NE 31st St',line2:'Redmond, WA'}" az some-command --contact address.details=./address_details.json

 

  • Combine Full Value and Partial Value for ultimate flexibility.

 

az some-command --contact "{name:Bill,age:20,paid:true,emails:[[email protected],[email protected]]}" motto="One man's bug is another man's lesson." az some-command --contact "{name:Bill,??" az some-command --contact "{name:Bill,address:??" az some-command --contact "{name:Bill,address:{country:??" az some-command --contact "{name:Bill,address:{country:USA},emails:??" az some-command --contact "{name:Bill,address:{country:USA},emails:[??" az some-command --contact name="'Bill RP'" data="'{a: [1, 2]}'" az some-command --contact name="'null'" az some-command --contact name="'bill'/s'"

 

  • ?? for Help: Use ?? to reveal helpful hints, making your life easier.

 

az some-command --contact "??" az some-command --contact "{??" az some-command --contact "{name:Bill,??" az some-command --contact "{name:Bill,address:??" az some-command --contact "{name:Bill,address:{country:??" az some-command --contact "{name:Bill,address:{country:USA},emails:??" az some-command --contact "{name:Bill,address:{country:USA},emails:[??" az some-command --contact address="??" az some-command --contact emails="??" az some-command --contact emails[0]="??"

 

  • Passing null Values: Effortlessly handle null values in both Full Value and Partial Value formats.

Pass null in Full Value:

 

az some-command --contact "{name:Bill,age:20,paid:true,emails:[[email protected],[email protected]],address:null}"

 

Pass null in Partial Value:

 

az some-command --contact name=Bill address=null

 

 

Single Quotes String is used to pass a string value with special characters: `:`, `,`, `{`, `}`, `[`, `]`, `null`, `??` and space. Because those characters usually have other meanings when parsing shorthand syntax. So with single quotes, it tells parser to parse as a string only.

  • Pass a String Value with Space and Special Characters

 

Crafting commands with spaces or special characters? No worries! Single Quotes String ensures your strings stay intact: az some-command --contact "{name:'Bill RP',age:20,paid:true,data:'{a: [1, 2]}'}" az some-command --contact name="'Bill RP'" data="'{a: [1, 2]}'"

 

  • Pass a "null" String Value

Need to pass a string with the value "null"? Single Quotes String to the rescue:

 

az some-command --contact "{name:'null',age:20,paid:true}" az some-command --contact name="'null'"

 

  • Use '/ to Pass ': Handling the tricky single quote within a Single Quotes String? Use '/ to navigate smoothly:

 

az some-command --contact "{name:'bill'/s',age:20,paid:true}" az some-command --contact name="'bill'/s'" az some-command --contact name="bill's"

 

 

Overall, our shorthand syntax is designed to streamline command creation, making it more concise and intuitive for day-to-day development around Azure CLI. By condensing commonly used parameters, it not only saves keystrokes but also enhances readability which will greatly beneficial to our codebase and CLI developer community.

Published on:

Learn more
Azure Tools Blog articles
Azure Tools Blog articles

Azure Tools Blog articles

Share post:

Related posts

Stay up to date with latest Microsoft Dynamics 365 and Power Platform news!
* Yes, I agree to the privacy policy