Azure / azure-cli

Azure Command-Line Interface
MIT License
3.96k stars 2.94k forks source link

azure-cli rpm take ~700MB of disk space #22955

Open chantra opened 2 years ago

chantra commented 2 years ago

Describe the bug

Installing azure-cli-2.36.0-1.el8.x86_64 result in 730MB worth of files installed.

To Reproduce

rpm -q --queryformat '%{SIZE} %{NAME} %{VERSION}\n' azure-cli
730875850 azure-cli 2.36.0

the RPM itself is only 50MB (compressed):

dnf info azure-cli-2.36.0-1.el8.x86_64
Name         : azure-cli
Version      : 2.36.0
Release      : 1.el8
Architecture : x86_64
Size         : 50 M
Source       : azure-cli-2.36.0-1.el8.src.rpm
Repository   : rolling_stable_microsoft
Summary      : Azure CLI
URL          : https://docs.microsoft.com/cli/azure/install-azure-cli
License      : MIT
Description  : A great cloud needs great tools; we're excited to introduce Azure CLI,
             :  our next generation multi-platform command line experience for Azure.

There is probably a good reason for that many libraries to be shipped along, such as ensuring that the CLI is self contained and does not depend on system libraries, but it seems there is an abnormal amount of historical versions shipped along, such as:

du -sh /usr/lib64/az/lib/python3.6/site-packages/azure/mgmt/compute/v*     
1.5M    /usr/lib64/az/lib/python3.6/site-packages/azure/mgmt/compute/v2015_06_15
1.6M    /usr/lib64/az/lib/python3.6/site-packages/azure/mgmt/compute/v2016_03_30
2.1M    /usr/lib64/az/lib/python3.6/site-packages/azure/mgmt/compute/v2016_04_30_preview
2.6M    /usr/lib64/az/lib/python3.6/site-packages/azure/mgmt/compute/v2017_03_30
172K    /usr/lib64/az/lib/python3.6/site-packages/azure/mgmt/compute/v2017_09_01
2.6M    /usr/lib64/az/lib/python3.6/site-packages/azure/mgmt/compute/v2017_12_01
3.0M    /usr/lib64/az/lib/python3.6/site-packages/azure/mgmt/compute/v2018_04_01
3.4M    /usr/lib64/az/lib/python3.6/site-packages/azure/mgmt/compute/v2018_06_01
496K    /usr/lib64/az/lib/python3.6/site-packages/azure/mgmt/compute/v2018_09_30
2.7M    /usr/lib64/az/lib/python3.6/site-packages/azure/mgmt/compute/v2018_10_01
3.9M    /usr/lib64/az/lib/python3.6/site-packages/azure/mgmt/compute/v2019_03_01
172K    /usr/lib64/az/lib/python3.6/site-packages/azure/mgmt/compute/v2019_04_01
4.4M    /usr/lib64/az/lib/python3.6/site-packages/azure/mgmt/compute/v2019_07_01
656K    /usr/lib64/az/lib/python3.6/site-packages/azure/mgmt/compute/v2019_11_01
4.1M    /usr/lib64/az/lib/python3.6/site-packages/azure/mgmt/compute/v2019_12_01
816K    /usr/lib64/az/lib/python3.6/site-packages/azure/mgmt/compute/v2020_05_01
3.8M    /usr/lib64/az/lib/python3.6/site-packages/azure/mgmt/compute/v2020_06_01
840K    /usr/lib64/az/lib/python3.6/site-packages/azure/mgmt/compute/v2020_06_30
1.9M    /usr/lib64/az/lib/python3.6/site-packages/azure/mgmt/compute/v2020_09_30
696K    /usr/lib64/az/lib/python3.6/site-packages/azure/mgmt/compute/v2020_10_01_preview
4.8M    /usr/lib64/az/lib/python3.6/site-packages/azure/mgmt/compute/v2020_12_01
4.9M    /usr/lib64/az/lib/python3.6/site-packages/azure/mgmt/compute/v2021_03_01
5.4M    /usr/lib64/az/lib/python3.6/site-packages/azure/mgmt/compute/v2021_04_01
5.6M    /usr/lib64/az/lib/python3.6/site-packages/azure/mgmt/compute/v2021_07_01
1.1M    /usr/lib64/az/lib/python3.6/site-packages/azure/mgmt/compute/v2021_08_01
976K    /usr/lib64/az/lib/python3.6/site-packages/azure/mgmt/compute/v2021_10_01
4.6M    /usr/lib64/az/lib/python3.6/site-packages/azure/mgmt/compute/v2021_11_01
1.1M    /usr/lib64/az/lib/python3.6/site-packages/azure/mgmt/compute/v2021_12_01

so I wonder if there is ways to trim some of the package.

Expected behavior

Leaner package.

Environment summary

Installed using rpm from MS repo.

yonzhan commented 2 years ago

@jiasli for awareness

chantra commented 2 years ago

BTW, the same issue holds for the deb package too:

-rw-rw-r-- 1 chantra chantra 48M Jul 16  2020 azure-cli_2.9.1-1~focal_all.deb

and installed size:

mkdir azure-cli
dpkg-deb -x azure-cli_2.9.1-1\~focal_all.deb azure-cli
du -sh azure-cli
603M    azure-cli
yonzhan commented 2 years ago

It is caused by the huge network python SDK which Azure CLI depends on and we are working with corresponding team to reduce the package size.

chantra commented 2 years ago

Thanks for the update @yonzhan !

advian-digirata commented 1 year ago

Any updates to this?

mt35-rs commented 1 year ago

I just audited my disk space and az and its dependencies are taking up 1Gb of disk space. That's a burden for my desktop but it's crazy when you try to bundle az into a Docker image. This looks really bad when compared to any of the Go based CLI's which can statically compile all the dependencies in making them a) easier to install and b) consume far less disk space.

jiasli commented 1 year ago

We have developed a script to trim unused API versions for Windows MSI pacakge (https://github.com/Azure/azure-cli/pull/23946). We will extend it to other packages.

mt35-rs commented 1 year ago

Note, the issue (at least on Linux) is not the API versions, it is the fact that it brings in its own specific installation of the Python runtime.

sjansen1 commented 8 months ago

we like to use dehydrated (acme client) with azure-dns plugin for letsencrypt certificates on IOT devices. That plugin needs azure-cli for settings dns verification records. ~1 gb of storage for azure-cli on an IOT device is way to much. Any plans on reducing the size?

bebound commented 8 months ago

@sjansen1 700MB is the best we can achieve right now. (Just my personal perspective, have you tried another acme client such as certbot? If I recall correctly, Azure CLI is not required for DNS verification.)

sjansen1 commented 7 months ago

@sjansen1 700MB is the best we can achieve right now. (Just my personal perspective, have you tried another acme client such as certbot? If I recall correctly, Azure CLI is not required for DNS verification.)

Yep but it is ugly. In RHEl, Ubuntu, Debian there is no certbot plugin package for azure dns, installing azure-dns snap or playing around with pip under the root account is not really an option from security maintanance perspective. I hope someday someone do a proper package of certbot-azure-dns for these systems, like other dns providers for example digital ocean.