az consumption usage list errors out with memoryError
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 3.5k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 64
Description
## Describe the bug
When there is a large amount of resources (>2750), resource groups (>150) in a subscription and you run the command for a past billing period (e.g. 202106) it is possible to produce a memory error. Running the command multiple times with smaller parts of the billing period (e.g. day 1-10, 11-20, 20-31) is a workaround but I would assume not a suitable one for everyone.
**Command Name**
`az consumption usage list`
**Errors:**
```
The command failed with an unexpected error. Here is the traceback:
Traceback (most recent call last):
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 237, in invoke
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/output.py", line 146, in out
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/output.py", line 38, in format_json
File "json\__init__.py", line 238, in dumps
File "json\encoder.py", line 202, in encode
MemoryError
```
## To Reproduce:
Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.
- _Put any pre-requisite steps here..._
- `az consumption usage list --subscription {} --billing-period-name {}`
## Expected Behavior
## Environment Summary
```
Windows-10-10.0.19041-SP0
Python 3.6.8
Installer: MSI
azure-cli 2.22.1
Extensions:
account 0.2.1
ad 0.1.0
application-insights 0.1.13
azure-devops 0.18.0
resource-graph 2.0.0
```
## Additional Context
Contributor guide
Research direction
Start with the az consumption usage list command and trace how its results reach knack/output.py, especially format_json, as named in the traceback. Reproduce with a large billing-period query and determine whether the command can complete without MemoryError; the issue provides no test file or more specific completion criteria.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, python
- Domain
- cli, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100