-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
azure-cli package could lose some weight #7387
Comments
Thank you for the feedback. You made a great point. We will definitely look into this. I will keep this issue open and assign it to myself. |
@marstr, could you please prioritize this work and get it done sometime in April? |
I'm excited to take care of this :) |
@marstr Thanks for picking this up, I've just been through another painfully slow upgrade (to 2.0.60 under WSL/Ubuntu) so I can assure you this fix will be welcomed! |
Geat that this is finally getting looked at! Every time I update the CLI, I kiss goodbye to my machine for ~20 minutes. I dread updating it. Looking forward to these changes |
20 minutes? Yikes. Which platform are you using @benc-uk? Maybe Ubuntu via WSL? |
Yes. I've had some snide comments from customers about the CLI in this regard |
All the more reason to get this taken care of. Thanks for the honest feedback. |
The WSL file system being slow when transfer large number of files were the problem when I looked at it months ago. Windows Defender is more about the cold start time of the command. |
It's a pipe dream at this point as I can see the amount of work that's gone into this Python version of the CLI, but... A single executable (i.e. based on golang) would be ideal. I've been working with Kubernetes, Helm and Terraform. Their tooling is written in Golang and it's really nice just having this single static binary you can put anywhere EDIT: the new AzCopy V10 has gone down this route |
If you look into my GitHub profile, you'll see that I'm a huge fan of Go and have spent a non-trivial part of my career on/with it. I love Terraform and k8s, and am envious of their ease of distribution. TBH, there are a lot of benefits to Go, but with a project like ours where we need to support many many contributors across the company, asking people to learn Go is a much heavier lift than asking them to use/learn Python. Not to mention, I don't think this product is at burn-it down and rewrite quality just yet ;) |
I totally understand, that's why I prefixed my comment with "this is a pipe dream" 😄 Hopefully some tidy up of the packaging is all that is required to get things speedy again |
@marstr Will slimming the |
Yes! That's what I'm working on right now. |
I don't think there's anyway out of this now, beyond a full rewrite in Go, Rust or Dotnet etc, something that can compile to a single binary Each week that passes the CLL gets larger and larger, and the chances of a rewrite smaller and smaller Where does it stop? When the CLI takes up 2GB? 5GB? 50GB? |
@benc-uk Have you tried https://github.com/clumio-code/azure-sdk-trim ? I wrote this a while back to delete older API directories that are obviously superfluous in 99% of cases and the If you call it from a Dockerfile make sure to have it in the same |
@benc-uk, If you do an It is actually the Azure Python SDK ( Rewriting in Go, Rust, .NET won't give too much benefit as those Azure SDKs are equally huge. |
Agreed, but with a compiled language you ship a binary, you don't ship the SDK with it! If I wrote a Go app that used the Go SDK for Azure, used a few functions from the SDK, and compiled it - it would be completely standalone executable and only a few megabytes |
I still want to see a version of Azure CLI that can be composed of different components more easily, but I've written a blog post that can hopefully help some people out: https://usrme.xyz/posts/how-to-trim-a-container-image-that-includes-azure-cli/. Using the methods described there I was able to slim an image from 1.17GB to 307MB! |
I was trying to find a cli mainly for azure devops. Installing the cli literally (via pip) shocked me. My usage is just to manage repositories & pull requests. I understand the installer itself is pretty small, but having 1G of dependencies is not ideal, at-least for my use case Isn't there way to decouple modules and use them independently, the current az cli is kind of overkill for my workflow. |
Some people are confusing or don't understand the problem. Even more I see with great surprise that some say that changing to Go we will practically not gain anything regarding the size of the CLI, surely they are the ones who love and support the current development that is a disaster. |
quite true on the actual issue of dependency hell, just looking at the pip install execution logs makes ones eyes water in disbelief. Looking at other major cloud providers I can see their equivalent cli tools weigh in differently Does it add more confusion to request a 'core' cli that is smaller but handles common activities (VMs, Blobs, AD, etc) or is that just masking the fundamental issue. think I would nearly prefer to dynamically add extensions to whatever i need rather than pulling down everything. |
I've created this pr to fix the problem. #25801 |
I'm glad to report (/s, if that wasn't obvious) that things have gotten worse in the last 6 years. The current version of the
|
It's never going to be fixed long as they continue to use Python IMO, and they'll never move off Python because a rewrite is too big a job The only answer would be to modularize things into multiple optional packages/sub-packages, but that'll add complexity for users, so I also don't see that happening |
That's not exactly the issue.
|
@benc-uk the size of Azure CLI is not because of the language but, as @akx mentioned, because the Azure SDK for Python is designed in a manner that embeds every single prior release of the Azure APIs. For example if I go to my current python packages directory:
Why we need versions from 2015, or 5 versions from 2018 including 2 preview versions? The latest, valid, version is less than 500K but all these versions add up to almost 9MB. Worse newer versions can depend and import older versions so you can't just delete the older versions. I wrote a tool several years ago to carefully delete unreferenced older versions so it is possible that there are even more versions of the monitor api: Nowadays a fresh install of the azure folder is 1.3GB which the tool trims to 300MB. Last year something happened and the azure folder had shrunk to 600MB and trimmed to 300MB, but new versions of APIs got added and we are back to over 1GB. Again this has nothing to do with Python but everything to do with an extremely poor design choice to force everyone using Azure to embed all the API versions. This problem has existed for years and there are several issues, including this one, documenting the lack of significant progress to provide something remotely reasonable. The azure cli was not always in Python it used to be in NodeJS and it was much worse. One of the worse part was that to get an API token you had to run a special cli command which would launch Internet Explorer, and only Internet Explorer. That did not work from a linux or macOS machine and we had to launch Windows VMs, install nodeJS and the azure cli in order to create the token and copy it to non Windows machines. |
Hi @sodul,
Thanks a lot for the detailed response and the trimming tool, which sounds
very interesting.
I have one question, in case you happen to know about it: I understood long
time ago that a big part of the issue was also that the package "installs"
(or includes somehow, I'm not sure) a specific Python version instead of
using the system one. Is that (still) true? I guess not much could be done
about that, if it is the case, right?
Thanks a lot in advance,
El vie, 14 feb 2025, 0:37, Stephane Odul ***@***.***>
escribió:
… @benc-uk <https://github.com/benc-uk> the size of Azure CLI is not
because of the language but, as @akx <https://github.com/akx> mentioned,
because the Azure SDK for Python is designed in a manner that embeds every
single prior release of the Azure APIs. For example if I go to my current
python packages directory:
❯ du -shc azure/mgmt/monitor/v*
796K azure/mgmt/monitor/v2015_04_01
576K azure/mgmt/monitor/v2015_07_01
608K azure/mgmt/monitor/v2016_03_01
332K azure/mgmt/monitor/v2016_09_01
200K azure/mgmt/monitor/v2017_12_01_preview
280K azure/mgmt/monitor/v2018_01_01
652K azure/mgmt/monitor/v2018_03_01
356K azure/mgmt/monitor/v2018_04_16
492K azure/mgmt/monitor/v2018_06_01_preview
204K azure/mgmt/monitor/v2018_11_27_preview
468K azure/mgmt/monitor/v2019_03_01
392K azure/mgmt/monitor/v2019_06_01
672K azure/mgmt/monitor/v2019_10_17
328K azure/mgmt/monitor/v2020_10_01
724K azure/mgmt/monitor/v2021_04_01
860K azure/mgmt/monitor/v2021_05_01_preview
616K azure/mgmt/monitor/v2022_06_01
480K azure/mgmt/monitor/v2022_10_01
8.8M total
Why we need versions from 2015, or 5 versions from 2018 including 2
preview versions? The latest, valid, version is less than 500K but all
these versions add up to almost 9MB. Worse newer versions can depend and
import older versions so you can't just delete the older versions.
I wrote a tool several years ago to carefully delete unreferenced older
versions so it is possible that there are even more versions of the monitor
api:
https://github.com/clumio-code/azure-sdk-trim
Nowadays a fresh install of the azure folder is 1.3GB which the tool trims
to 300MB. Last year something happened and the azure folder had shrunk to
600MB and trimmed to 300MB, but new versions of APIs got added and we are
back to over 1GB.
Again this has nothing to do with Python but everything to do with an
extremely poor design choice to force everyone using Azure to embed all the
API versions. This problem has existed for years and there are several
issues, including this one, documenting the lack of significant progress to
provide something remotely reasonable.
The azure cli was not always in Python it used to be in NodeJS and it was
much worse. One of the worse part was that to get an API token you had to
run a special cli command which would launch Internet Explorer, and only
Internet Explorer. That did not work from a linux or macOS machine and we
had to launch Windows VMs, install nodeJS and the azure cli in order to
create the token and copy it to non Windows machines.
—
Reply to this email directly, view it on GitHub
<#7387 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJD5MZJGTLQLWSALRHPHDCL2PU3EHAVCNFSM6AAAAABWYBLX4GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNJXHE4TSMRQGA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
[image: sodul]*sodul* left a comment (Azure/azure-cli#7387)
<#7387 (comment)>
@benc-uk <https://github.com/benc-uk> the size of Azure CLI is not
because of the language but, as @akx <https://github.com/akx> mentioned,
because the Azure SDK for Python is designed in a manner that embeds every
single prior release of the Azure APIs. For example if I go to my current
python packages directory:
❯ du -shc azure/mgmt/monitor/v*
796K azure/mgmt/monitor/v2015_04_01
576K azure/mgmt/monitor/v2015_07_01
608K azure/mgmt/monitor/v2016_03_01
332K azure/mgmt/monitor/v2016_09_01
200K azure/mgmt/monitor/v2017_12_01_preview
280K azure/mgmt/monitor/v2018_01_01
652K azure/mgmt/monitor/v2018_03_01
356K azure/mgmt/monitor/v2018_04_16
492K azure/mgmt/monitor/v2018_06_01_preview
204K azure/mgmt/monitor/v2018_11_27_preview
468K azure/mgmt/monitor/v2019_03_01
392K azure/mgmt/monitor/v2019_06_01
672K azure/mgmt/monitor/v2019_10_17
328K azure/mgmt/monitor/v2020_10_01
724K azure/mgmt/monitor/v2021_04_01
860K azure/mgmt/monitor/v2021_05_01_preview
616K azure/mgmt/monitor/v2022_06_01
480K azure/mgmt/monitor/v2022_10_01
8.8M total
Why we need versions from 2015, or 5 versions from 2018 including 2
preview versions? The latest, valid, version is less than 500K but all
these versions add up to almost 9MB. Worse newer versions can depend and
import older versions so you can't just delete the older versions.
I wrote a tool several years ago to carefully delete unreferenced older
versions so it is possible that there are even more versions of the monitor
api:
https://github.com/clumio-code/azure-sdk-trim
Nowadays a fresh install of the azure folder is 1.3GB which the tool trims
to 300MB. Last year something happened and the azure folder had shrunk to
600MB and trimmed to 300MB, but new versions of APIs got added and we are
back to over 1GB.
Again this has nothing to do with Python but everything to do with an
extremely poor design choice to force everyone using Azure to embed all the
API versions. This problem has existed for years and there are several
issues, including this one, documenting the lack of significant progress to
provide something remotely reasonable.
The azure cli was not always in Python it used to be in NodeJS and it was
much worse. One of the worse part was that to get an API token you had to
run a special cli command which would launch Internet Explorer, and only
Internet Explorer. That did not work from a linux or macOS machine and we
had to launch Windows VMs, install nodeJS and the azure cli in order to
create the token and copy it to non Windows machines.
—
Reply to this email directly, view it on GitHub
<#7387 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJD5MZJGTLQLWSALRHPHDCL2PU3EHAVCNFSM6AAAAABWYBLX4GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNJXHE4TSMRQGA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
@pachisb in our case we do not follow the recommended way to install the azure cli, we install it as part of our requirements.txt file so we can re-use our version of python. Furthermore we leave the system version of python alone and use pyenv so we can install a fresh version of python with recent vulnerability and bug fixes. Note that we can't install python 3.13 yet because the Azure SDK is currently incompatible with 3.13 due to the microsoft authentication library, so regardless of the CLI we are stuck with 3.12. We install the Azure CLI through pip because:
We have a special script to install all this, where we create a custom azure-requirements.txt, install that first, then install our updated requirements. This 'tricks' If you have a simple requirements.txt you should be able to just add
Note that the azure-sdk team has created a similar tool to my azure-sdk-trim afterwards and it is called by their installer but it is not as aggressive. |
@sodul Thanks a lot for your detailed explanation! I will definitely give a try to different installation methods, including installing via |
The
azure-cli
package (Ubuntu Xenial) could stand to lose some weight.😲 and 😳 don't begin to describe my reaction at the size difference between the AWS CLI and the Azure CLI packages.
python3
(on platforms where it is known there is a recent enough Python 3)?_py3
variants even included ifaz
is always run with Python 3?It's also not just about the size; install speed is also a thing. It takes 50 seconds to install the single
azure-cli
package on Azure machine, with its 39 000 files (dpkg-query -L azure-cli | wc -l
: 39094), just a little less than installing the twentyish packages that comprise all ofawscli
's dependencies (that can be used by other software on the system).The text was updated successfully, but these errors were encountered: