Azure / Azure/azure-cli

Reduce PyPi azure-cli Package Bloat

Open
#30,972 3 comments 2 reactions 1 assignee Claimed by @bebound View on GitHub
customer-reported feature-request Service Attention
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

**Is your feature request related to a problem? Please describe.**
I'm trying to install azure cli in a non-bloaty way, for use in containerized environments. Most ways of installing it (ubuntu debs, azure linux dockers) balloon the installation near 1GB. This is difficult when azure cli is just supposed to be _one_ of many tools needed to run things in this image, not the whole picture.

I had much more success with a python-alpine image, uv package manager, and `uv pip install --system --prerelease=allow 'azure-cli>=2.66'` (following the developers install/build instructions).

The real problem is this: even the pure python repo is fairly bloated.
![Image](https://github.com/user-attachments/assets/63b92c4b-53a0-4f47-85f2-af477bd817ce)
Of all the deps are almost nothing compared to it, and this is without pre-compiling the bytecode, which adds another 300MB (not shown).

I really only need a few parts of the cli ; I don't need the entire azure cli ecosystem (I can't afford it).
But even worse than 300MB of cli commands I don't need, is that, (correct me if I'm wrong, but this is half the basis of this issue), most of it is depreciated or out of date?

Ex, it seems like most-all the size comes from old versions of the api?
![Image](https://github.com/user-attachments/assets/4563fe53-2c3a-45e7-8434-9512f1425837)
![Image](https://github.com/user-attachments/assets/59fe011e-d782-45a2-8fb8-20f79690ed49)

**Describe the solution you'd like**
My chief suggestion would be to cull old api versions; one can always install an older version of az cli.
But if that would be problematic (tho simple), couldn't releasing or packaging slimmer builds be an option? Ex, a slim wherein only the latest api's are included?

Or, going the aws cli route, allowing the various subcommands to be installed as extras, by default installing "all", unless the subset is specified?

**Describe alternatives you've considered**
Short of hacking at the install itself, there's literally nothing else bloatwise to remove from a mere pypi install, unlike the other methods. Even so, 1/2->1GB +- compiled pyc is a bit much.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.