Open SenseiJoe opened 3 years ago
--output none
only works for stdout
. These survey lines
Please let us know how we are doing: https://aka.ms/azureclihats
and let us know if you're interested in trying out our newest features: https://aka.ms/CLIUXstudy
are written to stderr
which can be disabled with 2> $null
:
> az --version > $null 2> $null
>
az --version
is only designed for better human readability. To only check the version, you may use az version
which outputs a JSON:
> az version
{
"azure-cli": "2.19.1",
"azure-cli-core": "2.19.1",
"azure-cli-telemetry": "1.0.6",
"extensions": {
"account": "0.2.1",
"support": "1.0.2"
}
}
As for
az --needupgrade
perhaps we can add a programmatic way to az version
to detect if update is available? Something like:
> az version --check-upgrade
{
"azure-cli": "2.19.1*",
"azure-cli-core": "2.19.1*",
"azure-cli-telemetry": "1.0.6",
"extensions": {
"account": "0.2.1",
"support": "1.0.2"
}
}
or
> az version --latest
{
"azure-cli": "2.20.0",
"azure-cli-core": "2.20.0",
"azure-cli-telemetry": "1.0.6",
"extensions": {
"account": "0.2.1",
"support": "1.0.2"
}
}
@fengzhou-msft
I like the --latest option but... I still like having an option that tells me if the core or extension needs updating. returning true of false. something like az version --name azure-cli --upgrade or az version --name azure-cli --islatest
You could apply that to any module or extension
this way I could write if (az version --name azure-cli --upgrade) ) { az upgrade }
You suggestion for suppression output works, so I can work around that.
Thanks for the work you do and your help. Joe
@SenseiJoe, glad to know it works for you!
Perhaps we can make something like
> az version --check-upgrade
{
"azure-cli": true,
"azure-cli-core": true,
"azure-cli-telemetry": false,
"extensions": {}
}
Then you may query the result with --query '\"azure-cli\"'
(pay attention to Quoting issues with PowerShell).
Indeed, comparing version doesn't seem like a good option to me, as 2.10.0
can actually be smaller than 2.9.0
due to string comparison.
Thanks, I think that will work just fine. (as long as that banner doesn't show up) ;)
@SenseiJoe It looks like you may be interested in the auto-upgrade feature. You can enable it by running:
az config set auto-upgrade.enable=yes auto-upgrade.prompt=no
Azure CLI will then periodically check for new versions and auto-upgrade when a command finishes running.
Is your feature request related to a problem? Please describe. I'm always frustrated when I do "az --version | Out-Null" or any version of this syntax where I'm trying to put the version information into a variable. I always get
Describe the solution you'd like If I pipe to Out-Null there is no console output.
My goal is control if and when I need to upgrade. if something is out of date I ask the user if they want to upgrade. My profile script checks the version information of many modules including az cli. when I do $v = az --version | Out-Null, most of it works but I still get that header on the console.
Describe alternatives you've considered
$v = az --version --output none, Gives me the same header Even tried $v = az --version --output none | Out-Null, Gets the same header
Additional context I'd like to see the ability to check individual version numbers of modules & main az version # only or something that just answers the question of needing an upgrade az --needupgrade
OR
az --version --name azure-cli PS> 2.20.0
az --version --name azure-devops PS> 0.18.0