Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

az --version performs an update check #27437

Open
jessehouwing opened this issue Sep 20, 2023 · 8 comments
Open

az --version performs an update check #27437

jessehouwing opened this issue Sep 20, 2023 · 8 comments
Assignees
Labels
Azure CLI Team The command of the issue is owned by Azure CLI team Core CLI core infrastructure customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Upgrade az upgrade
Milestone

Comments

@jessehouwing
Copy link

Describe the bug

When running az --version an update check is performed against az-cli and the extensions.

Azure Pipelines' AzureCLI task runs az --version to capture the version details in the logs.

It would save quite a bit of CPU if az-cli would not perform an update check in a CI/CD scenario.

There already is an core.auto-upgrade=false option, would it not make sense to piggy back on that or to add another config setting to turn off update checking.

Related command

az --version

Errors

N/a

Issue script & Debug output

N/a

Expected behavior

No update check is performed in CI.

Environment Summary

2.52.0

Additional context

No response

@jessehouwing jessehouwing added the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Sep 20, 2023
@microsoft-github-policy-service microsoft-github-policy-service bot added the customer-reported Issues that are reported by GitHub users external to the Azure organization. label Sep 20, 2023
@yonzhan
Copy link
Collaborator

yonzhan commented Sep 20, 2023

Thank you for opening this issue, we will look into it.

@yonzhan yonzhan added Core CLI core infrastructure question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Azure CLI Team The command of the issue is owned by Azure CLI team and removed bug This issue requires a change to an existing behavior in the product in order to be resolved. labels Sep 21, 2023
@yonzhan yonzhan added this to the Backlog milestone Sep 21, 2023
@jiasli jiasli added the Upgrade az upgrade label Sep 28, 2023
@jiasli
Copy link
Member

jiasli commented Sep 28, 2023

There already is an core.auto-upgrade=false option

According to https://learn.microsoft.com/en-us/cli/azure/update-azure-cli#automatic-update, it should be auto-upgrade.enable=yes.

We do have az version command that doesn't make any network request (#27457 (comment)). I think what you are asking for is an option to disable update check in az --version, while #27457 asks for an option to enable version check in az version. 🤣

@jessehouwing
Copy link
Author

jessehouwing commented Sep 28, 2023

Yeah, have a way to disable network access for these commands. Either with an extra parameter to --check-updates true or a setting in the config file or an environment variable.

Ideally az would detect it's in CI/CD and turn off a load of stuff that only adds logspam and slowdowns by default.

It looks like az init is making a start of collecting the desired settings ;).

@jiasli
Copy link
Member

jiasli commented Sep 28, 2023

az init is actually a secret project. May I know where you heard of it? 🤣

@jessehouwing
Copy link
Author

jessehouwing commented Sep 28, 2023

az init is actually a secret project. May I know where you heard of it? 🤣

I was looking for a way to set the default config settings, and I tried it on the console. Lo and behold it downloaded the extension and ran.

I supplied a PR for it to add a few more settings.

@jiasli
Copy link
Member

jiasli commented Sep 28, 2023

Ideally az would detect it's in CI/CD and turn off a load of stuff that only adds logspam and slowdowns by default.

This is another topic we are still internally investigating. Not only Azure DevOps, we are aiming to find a unified way to detect the running environment - Azure DevOps, Azure Cloud Shell, GitHub Actions, etc.

@jiasli
Copy link
Member

jiasli commented Sep 28, 2023

az init is only an experimental feature we made in Azure/azure-cli-extensions#3969. It is never expected to be used in production. Also, az init allows the user to select the running environment. It can't really detect the running environment.

@jessehouwing
Copy link
Author

jessehouwing commented Sep 28, 2023

az init is only an experimental feature we made in Azure/azure-cli-extensions#3969. It is never expected to be used in production. Also, az init allows the user to select the running environment. It can't really detect the running environment.

Yeah, I figured as much. The experimental nature at least. But it does seem to reccomend certain settings in an automated environment.

As you mentioned above auto-upgrade.enable=yes in the docs turns out to probably be auto-upgrade.enable=true in the code, at least there are quite a few issues that dispute the correct syntax. I went looking for what settings there are and what their values should/could be and there is VERY little documentation on those topics.

I ended up doing a search through the codebase instead. But it lead to some useful insights!

I've been digging into the performance of az and az devops in Azure Pipelines and GtHub Hosted Runners.

If these each shave off a couple of seconds, over the number of invocations on the hosted runners worldwide it would save a couple of trees and a bunch of water.

Ideally az would detect it's in a CI/CD environment and turn off:

  • Telemetry
  • Disk logging
  • Error recommendations
  • Colors
  • Auto-updates
  • Version checks
  • Survey banners
  • auto-installation of missing extensions
  • Randomly downloading new pip packages (like keyring) or helm versions or other unexpectedly missing dependencies. I'd rather have it fail in CI/CD than for it to download versions of files I haven't been able to vet.

And would allow:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Azure CLI Team The command of the issue is owned by Azure CLI team Core CLI core infrastructure customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Upgrade az upgrade
Projects
None yet
Development

No branches or pull requests

3 participants