YTKColumba
YTKColumba

Reputation: 25

Azure CLI Passing Value To Other Azure Command

Was wondering if there's a way to chain az cli command together and how they should work?

For example, I am trying to pipe one az storage account command output into another

Also the az storage account list command can return multiple values

az storage account list --subscription '<subscription>' --query "<query>" |
    az storage account update --name @ --allow-blob-public-access false

The above doesn't seem to work, and was wondering if there's a proper way to do it?

Upvotes: 0

Views: 1478

Answers (1)

Sparrow0hawk
Sparrow0hawk

Reputation: 577

I think the way to do this would probably be using xargs and setting the --output argument of your az storage account list call to tsv.

az storage account list --subscription '<subscription>' --query "<query>" --output tsv |
 xargs -I{} az storage account update --name {} --allow-blob-public-access false

xargs -I allows you to specify a placeholder string ({}) that can then be used as an input item in the rest of the xargs call.

This should allow you to perform this update operation on all the items outputted by your query if multiple values are returned.

Upvotes: 2

Related Questions