Azure / Azure/azure-rest-api-specs
QuotaMgmtClient returning negative usage values for resources that arent being utilized in subscription
- 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**







Contributor guide
Assessment
This issue has not been assessed yet.