Azure / azure-cli

Azure Command-Line Interface
MIT License
3.97k stars 2.95k forks source link

Install time must be radically improved #13028

Open ghstahl opened 4 years ago

ghstahl commented 4 years ago

Is your feature request related to a problem? Please describe. It isn't reasonable in some cases to prebuild VM images with az cli installed. In those cases, when its needed an install must be on par if not better than installing terraform.

I have a github action that has these numbers;

 Install/Upgrade AZ CLI      4m 56s
    CONTAINER_NAME: intake
Run Start-Process msiexec.exe -Wait -ArgumentList '/I azure-cli-2.3.1.msi /quiet'
  Start-Process msiexec.exe -Wait -ArgumentList '/I azure-cli-2.3.1.msi /quiet'
  shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"

This is just the install as I had the installer checked in to my github repo.

Describe the solution you'd like A az cli install must be in the seconds range. (10-30 seconds). Frankly this should be a fast as a file copy.

yungezz commented 4 years ago

hi @fengzhou-msft could you pls have a look? thanks

ghstahl commented 4 years ago

I changed my initial requirement. az cli must install under 4 seconds.

Terraform installed in under 4s via a github action and that was with a wget in the mix.

Terraform makes API calls to azure, as does az cli. A 5 min install is not an acceptable time compared to this direct competitor.

 Install Terraform   4s
   200K .......... .......... .......... .......... ..........  1% 88.9M 2s
Run pushd './'
~/work/terraform-setup-azfunc-shorturl/terraform-setup-azfunc-shorturl ~/work/terraform-setup-azfunc-shorturl/terraform-setup-azfunc-shorturl
Reading package lists...
Building dependency tree...
fengzhou-msft commented 4 years ago

@ghstahl Azure CLI relies on a bunch of SDK dependencies and third-party packages. The MSI package size is over 50 MB and the space on disk after installation is over 200 MB.

With the current design, it's hard to make dramatic improvement. We are working on a lightweight installer to improve the install time.

ghstahl commented 4 years ago

@fengzhou-msft I was in a situation like this once where I had to change the design a bit so that I could zip the whole 100+ MB and slam it down to a folder. That was the install portion - unzip and run. Other than that, a rewrite in GO like terraform cli where its one big ole exe is the extreme option. Thank you for looking at this.

cveld commented 4 years ago

Setting up this as a 50 MB zip package on a CDN within Azure would be reachable right? Then you could stream the unzip command from this CDN location towards the disk of the agent. Or maybe preinstalling Az CLI on your shared agents. PowerShell Az Modules are already there with various versions. Or, @ghstahl you could set up your self-hosted agent with Az CLI preinstalled.

Petermarcu commented 3 years ago

Investigating options for having less files would probably be the most fruitful exercise. There is overhead for each file no matter how large it is. Especially on windows. 200mb can copy extremely fast. You can see this if you have 2 local drives. Copy the CLI from one to the other. Then copy one 200mb file. Measure the difference and that's your opportunity for improvement for something with 200mb size on disk.

Beyond that. There may be some low hanging fruit in the msi. Compare the install time after downloading to the copy time you measured above to see what the msi overhead is.

Petermarcu commented 3 years ago

Here is a small change that will help a little. https://github.com/Azure/azure-cli/pull/16903

Petermarcu commented 3 years ago

I will note that upgrade is the worst path here. I have some ideas that could improve that path more too.

yonzhan commented 3 years ago

@jiasli for awareness

Petermarcu commented 3 years ago

Something failed WRT to the PR title but nothing telling me what it should look like. Let me know what needs to be adjusted.

jiasli commented 2 years ago

I did some tests recently:

The installation time is mainly due to the file number of Python SDK which includes lots of "duplicated" files for all API versions.

The overall file number of Azure CLI 2.34.1 is 15667 and 8594 files are from Python SDK (more than a half of totally file number).

image

image

Reducing Python SDK size (https://github.com/Azure/azure-sdk-for-python/issues/11149) will certainly improve the installation time of Azure CLI.

caoloi01 commented 2 years ago

Do we have any update on this? It takes more than 800s to install azure cli in Github Runner

iSeiryu commented 7 months ago

Microsoft owns dotnet that is able to build awesome CLI tools and could help to reduce the size of the executable as well as produce a self-contained app:

Other options could be Go or Powershell. Python was a weird choice for this tool. It makes it even weirder when different teams within Azure build tools using their own stacks, e.g. https://github.com/Azure/static-web-apps-cli/ It makes us, the end users, to download a bunch of dependencies that we did not sign up for.

jmc5113 commented 7 months ago

Just installed the latest release on a powerful windows 11 workstation and it takes FOREVER. It's still running. I don't understand how I can install office or solidworks faster than a CLI. This install time really needs to be improved when it updates frequently.