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

Unlocking the Best of Azure with AzureRM and AzAPI Providers

With the recent release of AzAPI 2.0, Azure offers two powerful Terraform providers to meet your infrastructure needs: AzureRM and AzAPI. The ...

1 year ago

Announcing AzAPI 2.0

The AzAPI provider, designed to expedite the integration of new Azure services with HashiCorp Terraform, has now released 2.0. This updated ve...

1 year ago

Azure CLI docker container base Linux image is now Azure Linux

Starting from the version  2.64.0 of Azure CLI, the base Linux distribution of Azure CLI is now Azure Linux.   Impact of the change ...

1 year ago

Azure Verified Modules - Monthly Update [June]

AVM Module Summary The AVM team are excited that our community have been busy building AVM Modules. As of June 17th, the AVM Footprint curren...

2 years ago

Azure Verified Modules - Monthly Update [May]

Quarterly Community Call This month we held our first community call. Thank you to everyone that attended & contributed. It was amazing t...

2 years ago

Azure CLI and PowerShell Tools Build 2024 Announcement

Microsoft has announced several new capabilities for Azure CLI and Azure PowerShell at the Microsoft Build 2024. The priority remains to provi...

2 years ago

Terraform on Azure May 2024 Update

    Welcome to our April 2024 update! These blogposts will be covering everything we've gotten up to recently with Terraform on Azu...

2 years ago

Azure Verified Modules - Monthly Update [April]

In the April edition of the Azure Verified Modules update, the AVM team announces their upcoming quarterly community call scheduled for 21st M...

2 years ago

Announcing AzAPI Dynamic Properties

  It’s been almost two years since the announcement of AzAPI, and the provider has eclipsed 20M+ downloads thanks to all of you. We’re ex...

2 years ago

Demystifying Azure CLI pagnination

Introduction   Pagination in the context of the command line refers to the process of displaying long lists of information or text i...

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