Azure / Azure/azure-rest-api-specs

QuotaMgmtClient returning negative usage values for resources that arent being utilized in subscription

Open
#30,182 6 comments 0 reactions 1 assignee Claimed by @msyyc View on GitHub
customer-reported Mgmt needs-team-attention question quota Service Attention
Dominant language
TypeSpec
Stars
3.1k
Forks
5.9k
Avg merge
2d 22h
Merged PRs (30d)
444

Description

- **Package Name**: azure-mgmt-quota
- **Package Version**: 1.1.0
- **Operating System**: Windows 11
- **Python Version**: 3.11.9

**Describe the bug**
The Azure Quota Management SDK (QuotaMgmtClient) returns -1 values for certain resources, the response values for resources that aren't used should be 0 and not -1. In the Azure Portal the same resources that show - 1 usage values show 0 usage values. 35 resource types under compute all return -1 usage values when not being utilized in subscription.

**To Reproduce**
Steps to reproduce the behavior:
1. Install library

```
pip install azure-mgmt-quota
```

2. Run code snippet using QuotaMgmtClient (Simplified code snippet)

```
from azure.identity import DefaultAzureCredential
from azure.mgmt.quota import QuotaMgmtClient
import logging

logger = logging.getLogger(__name__)

logging.basicConfig(
filename="compute_usages.log", encoding="utf-8", level=logging.DEBUG
)

def main():
client = QuotaMgmtClient(
credential=DefaultAzureCredential(),
)

response = client.usages.list(
scope="subscriptions/{subscription_id}/providers/Microsoft.Compute/locations/southafricanorth",
)

current_usages = []

for item in response:

payload = {"name": item.name, "usage": item.properties.usages.value,
"isQuotaApplicable" : item.properties.is_quota_applicable}
logging.info(payload)
current_usages.append(payload)

logging.info(current_usages)

if __name__ == "__main__":
main()

```


**Expected behavior**
Resources that have no usage should return a usage value of 0. This should align with what's displayed in the Azure portal under Quotas.

**Extract of output**
```
[
{'name': 'standardNDSFamily', 'usage': -1, 'isQuotaApplicable': False
},
{'name': 'standardNCSv2Family', 'usage': -1, 'isQuotaApplicable': False
},
{'name': 'standardNCSv3Family', 'usage': -1, 'isQuotaApplicable': False
},
]
```

**Screenshots**
![image](https://github.com/user-attachments/assets/113ff9ac-951f-4d83-8d90-05bfa7808420)

![image](https://github.com/user-attachments/assets/7f8c35a3-b7d7-4e0e-990f-1498659ba086)

![image](https://github.com/user-attachments/assets/f2174154-38ac-44d6-ae68-c57fc2db68e2)

![image](https://github.com/user-attachments/assets/c06d842f-182c-4bac-8f43-57b8cf33c57e)

![image](https://github.com/user-attachments/assets/040ce353-5bec-4a39-9dd0-275489e67931)

![image](https://github.com/user-attachments/assets/cc01a60a-1fcd-41df-a083-6af311b71200)

![image](https://github.com/user-attachments/assets/a989b776-14df-4a1d-afce-070af1357ce3)

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.