`top` parameter in ConsumptionManagementClient didn't return expecting list.
- Package Name: azure-mgmt-consumption
- Package Version: 8.0.0
- Operating System: Mac os Big Sur
- Python Version:
Python 3.9
Describe the bug
When I try to use
topto limit the results inusage_details.list(scope, top=2)fromConsumptionManagementClientmodule, I found it returns all the results instead of limited results, such as 2 results. After I checked the implementation of this method, it is based onPageIteratorand after print two results, it will continue to retrieve another 2 results and so on.
To Reproduce
from azure.mgmt.consumption import ConsumptionManagementClient
from azure.identity import AzureCliCredential
import os
credential = AzureCliCredential()
subscription_id = os.environ["AZURE_SUBSCRIPTION_ID"]
scope = '/subscriptions/' + subscription_id + '/'
client = ConsumptionManagementClient(credential, subscription_id)
resp = client.usage_details.list(scope, top=2)
for item in resp:
print(item)
Expected behavior I expect it should return 2 results in response.
Screenshots
Additional context
thanks for reaching out! We'll investigate it ASAP.
hi @xingyu-long, thanks for the feedback !
Could you try to use resp = client.usage_details.list(scope, top=2).advance_page() instead of resp = client.usage_details.list(scope, top=2)?
Hi @BigCat20196, thanks for your suggestion. But it didn't work and here is the full trackback.
Traceback (most recent call last):
File "/Users/xxx/Downloads/Github/learning_cloud/ms_azure/test.py", line 12, in <module>
resp = client.usage_details.list(scope, top=2).advance_page()
AttributeError: 'ItemPaged' object has no attribute 'advance_page'
Hi @xingyu-long , could you add debug? This helps us locate the problem quickly. Thanks
Please follow this link: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/debug_guide.md
Hi @BigCat20196 Here is the log and just show a part of it because it still continues to print out another 2 msg and so on.
2021-09-13 09:23:48,830 - azure.identity._internal.decorators - INFO - AzureCliCredential.get_token succeeded
2021-09-13 09:23:48,830 - azure.core.pipeline.policies.http_logging_policy - INFO - Request URL: 'https://management.azure.com/subscriptions/xxxx//providers/Microsoft.Consumption/usageDetails?$top=REDACTED&api-version=REDACTED'
2021-09-13 09:23:48,830 - azure.core.pipeline.policies.http_logging_policy - INFO - Request method: 'GET'
2021-09-13 09:23:48,831 - azure.core.pipeline.policies.http_logging_policy - INFO - Request headers:
2021-09-13 09:23:48,831 - azure.core.pipeline.policies.http_logging_policy - INFO - 'Accept': 'application/json'
2021-09-13 09:23:48,831 - azure.core.pipeline.policies.http_logging_policy - INFO - 'x-ms-client-request-id': 'xxx'
2021-09-13 09:23:48,831 - azure.core.pipeline.policies.http_logging_policy - INFO - 'User-Agent': 'azsdk-python-mgmt-consumption/8.0.0 Python/3.9.4 (macOS-11.5.2-x86_64-i386-64bit)'
2021-09-13 09:23:48,831 - azure.core.pipeline.policies.http_logging_policy - INFO - 'Authorization': 'REDACTED'
2021-09-13 09:23:48,831 - azure.core.pipeline.policies.http_logging_policy - INFO - No body was attached to the request
2021-09-13 09:23:48,842 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): management.azure.com:443
2021-09-13 09:24:02,885 - urllib3.connectionpool - DEBUG - https://management.azure.com:443 "GET /subscriptions/xxxx/providers/Microsoft.Consumption/usageDetails?$top=2&api-version=2019-10-01 HTTP/1.1" 200 None
2021-09-13 09:24:02,885 - azure.core.pipeline.policies.http_logging_policy - INFO - Response status: 200
2021-09-13 09:24:02,885 - azure.core.pipeline.policies.http_logging_policy - INFO - Response headers:
2021-09-13 09:24:02,885 - azure.core.pipeline.policies.http_logging_policy - INFO - 'Cache-Control': 'private'
2021-09-13 09:24:02,885 - azure.core.pipeline.policies.http_logging_policy - INFO - 'Transfer-Encoding': 'chunked'
2021-09-13 09:24:02,885 - azure.core.pipeline.policies.http_logging_policy - INFO - 'Content-Type': 'application/json; odata.metadata=none'
2021-09-13 09:24:02,885 - azure.core.pipeline.policies.http_logging_policy - INFO - 'Content-Encoding': 'REDACTED'
2021-09-13 09:24:02,885 - azure.core.pipeline.policies.http_logging_policy - INFO - 'Vary': 'REDACTED'
2021-09-13 09:24:02,885 - azure.core.pipeline.policies.http_logging_policy - INFO - 'x-ms-ratelimit-remaining-subscription-reads': '11999'
2021-09-13 09:24:02,885 - azure.core.pipeline.policies.http_logging_policy - INFO - 'session-id': 'REDACTED'
2021-09-13 09:24:02,885 - azure.core.pipeline.policies.http_logging_policy - INFO - 'x-ms-request-id': '2f059d14-3fb5-4034-b093-01b04e84d8d8'
2021-09-13 09:24:02,885 - azure.core.pipeline.policies.http_logging_policy - INFO - 'x-ms-correlation-request-id': 'REDACTED'
2021-09-13 09:24:02,885 - azure.core.pipeline.policies.http_logging_policy - INFO - 'x-ms-client-request-id': 'f8d53bb8-14ae-11ec-9c35-acde48001122'
2021-09-13 09:24:02,885 - azure.core.pipeline.policies.http_logging_policy - INFO - 'x-ms-ratelimit-microsoft.consumption-tenant-retry-after': 'REDACTED'
2021-09-13 09:24:02,886 - azure.core.pipeline.policies.http_logging_policy - INFO - 'x-ms-ratelimit-remaining-microsoft.consumption-tenant-requests': 'REDACTED'
2021-09-13 09:24:02,886 - azure.core.pipeline.policies.http_logging_policy - INFO - 'x-ms-ratelimit-microsoft.consumption-clientAppId-retry-after': 'REDACTED'
2021-09-13 09:24:02,886 - azure.core.pipeline.policies.http_logging_policy - INFO - 'x-ms-ratelimit-remaining-microsoft.consumption-clientAppId-requests': 'REDACTED'
2021-09-13 09:24:02,886 - azure.core.pipeline.policies.http_logging_policy - INFO - 'OData-Version': 'REDACTED'
2021-09-13 09:24:02,886 - azure.core.pipeline.policies.http_logging_policy - INFO - 'X-Powered-By': 'REDACTED'
2021-09-13 09:24:02,886 - azure.core.pipeline.policies.http_logging_policy - INFO - 'x-ms-routing-request-id': 'REDACTED'
2021-09-13 09:24:02,886 - azure.core.pipeline.policies.http_logging_policy - INFO - 'Strict-Transport-Security': 'REDACTED'
2021-09-13 09:24:02,886 - azure.core.pipeline.policies.http_logging_policy - INFO - 'X-Content-Type-Options': 'REDACTED'
2021-09-13 09:24:02,886 - azure.core.pipeline.policies.http_logging_policy - INFO - 'Date': 'Mon, 13 Sep 2021 16:24:02 GMT'
{'additional_properties': {}, 'id': '/subscriptions/xxx/providers/Microsoft.Billing/billingPeriods/20210901/providers/Microsoft.Consumption/usageDetails/xxxxx', 'name': 'xxxxx', 'type': 'Microsoft.Consumption/usageDetails', 'tags': {'ms-resource-usage': 'azure-cloud-shell'}, 'kind': 'legacy', 'billing_account_id': '123456789', 'billing_account_name': 'xxx LLC', 'billing_period_start_date': datetime.datetime(2021, 9, 1, 0, 0, tzinfo=<isodate.tzinfo.Utc object at 0x10e6bed60>), 'billing_period_end_date': datetime.datetime(2021, 9, 30, 0, 0, tzinfo=<isodate.tzinfo.Utc object at 0x10e6bed60>), 'billing_profile_id': '123456789', 'billing_profile_name': 'xxx LLC', 'account_owner_id': '[email protected]', 'account_name': '[email protected]', 'subscription_id': 'xxx', 'subscription_name': 'XXXX', 'date': datetime.datetime(2021, 9, 13, 0, 0, tzinfo=<isodate.tzinfo.Utc object at 0x10e6bed60>), 'product': 'Bandwidth - Data Transfer In - Zone 1', 'part_number': 'Q5H-00017', 'meter_id': '32c3ebec-1646-49e3-8127-2cafbd3a04d8', 'meter_details': None, 'quantity': 2.4e-05, 'effective_price': 0.0, 'cost': 0.0, 'unit_price': 0.0, 'billing_currency': 'USD', 'resource_location': 'WestUS', 'consumed_service': 'Microsoft.Storage', 'resource_id': '/subscriptions/xxx/resourceGroups/cloud-shell-storage-westus/providers/Microsoft.Storage/storageAccounts/cs410032001022c6357', 'resource_name': 'cs410032001022c6357', 'service_info1': None, 'service_info2': None, 'additional_info': None, 'invoice_section': 'xxxx Command Center', 'cost_center': 'US1079208', 'resource_group': 'cloud-shell-storage-westus', 'reservation_id': None, 'reservation_name': None, 'product_order_id': None, 'product_order_name': None, 'offer_id': 'MS-AZR-0148P', 'is_azure_credit_eligible': True, 'term': None, 'publisher_name': None, 'publisher_type': 'Azure', 'plan_name': None, 'charge_type': 'Usage', 'frequency': 'UsageBased'}
{'additional_properties': {}, 'id': '/subscriptions/xxx/providers/Microsoft.Billing/billingPeriods/20210901/providers/Microsoft.Consumption/usageDetails/xxxxxx', 'name': 'xxxxxx', 'type': 'Microsoft.Consumption/usageDetails', 'tags': {'ms-resource-usage': 'azure-cloud-shell'}, 'kind': 'legacy', 'billing_account_id': '123456789', 'billing_account_name': 'xxx LLC', 'billing_period_start_date': datetime.datetime(2021, 9, 1, 0, 0, tzinfo=<isodate.tzinfo.Utc object at 0x10e6bed60>), 'billing_period_end_date': datetime.datetime(2021, 9, 30, 0, 0, tzinfo=<isodate.tzinfo.Utc object at 0x10e6bed60>), 'billing_profile_id': '123456789', 'billing_profile_name': 'xxx LLC', 'account_owner_id': '[email protected]', 'account_name': '[email protected]', 'subscription_id': 'xxx', 'subscription_name': 'XXXX', 'date': datetime.datetime(2021, 9, 12, 0, 0, tzinfo=<isodate.tzinfo.Utc object at 0x10e6bed60>), 'product': 'Bandwidth - Data Transfer In - Zone 1', 'part_number': 'Q5H-00017', 'meter_id': '32c3ebec-1646-49e3-8127-2cafbd3a04d8', 'meter_details': None, 'quantity': 0.00011, 'effective_price': 0.0, 'cost': 0.0, 'unit_price': 0.0, 'billing_currency': 'USD', 'resource_location': 'WestUS', 'consumed_service': 'Microsoft.Storage', 'resource_id': '/subscriptions/xxx/resourceGroups/cloud-shell-storage-westus/providers/Microsoft.Storage/storageAccounts/cs410032001022c6357', 'resource_name': 'cs410032001022c6357', 'service_info1': None, 'service_info2': None, 'additional_info': None, 'invoice_section': 'xxxx Command Center', 'cost_center': 'US1079208', 'resource_group': 'cloud-shell-storage-westus', 'reservation_id': None, 'reservation_name': None, 'product_order_id': None, 'product_order_name': None, 'offer_id': 'MS-AZR-0148P', 'is_azure_credit_eligible': True, 'term': None, 'publisher_name': None, 'publisher_type': 'Azure', 'plan_name': None, 'charge_type': 'Usage', 'frequency': 'UsageBased'}
2021-09-13 09:24:02,894 - azure.core.pipeline.policies.http_logging_policy - INFO - Request URL: 'https://management.azure.com/subscriptions/xxx/providers/Microsoft.Consumption/usageDetails?$top=REDACTED&api-version=REDACTED&sessiontoken=REDACTED&$skiptoken=REDACTED&skiptokenver=REDACTED&id=REDACTED'
2021-09-13 09:24:02,894 - azure.core.pipeline.policies.http_logging_policy - INFO - Request method: 'GET'
2021-09-13 09:24:02,894 - azure.core.pipeline.policies.http_logging_policy - INFO - Request headers:
2021-09-13 09:24:02,894 - azure.core.pipeline.policies.http_logging_policy - INFO - 'Accept': 'application/json'
2021-09-13 09:24:02,894 - azure.core.pipeline.policies.http_logging_policy - INFO - 'x-ms-client-request-id': '021d2398-14af-11ec-9c35-acde48001122'
2021-09-13 09:24:02,894 - azure.core.pipeline.policies.http_logging_policy - INFO - 'User-Agent': 'azsdk-python-mgmt-consumption/8.0.0 Python/3.9.4 (macOS-11.5.2-x86_64-i386-64bit)'
2021-09-13 09:24:02,894 - azure.core.pipeline.policies.http_logging_policy - INFO - 'Authorization': 'REDACTED'
2021-09-13 09:24:02,894 - azure.core.pipeline.policies.http_logging_policy - INFO - No body was attached to the request
2021-09-13 09:24:03,454 - urllib3.connectionpool - DEBUG - https://management.azure.com:443 "GET /subscriptions/xxx/providers/Microsoft.Consumption/usageDetails?$top=2&api-version=2019-10-01&sessiontoken=8:45618658&$skiptoken=327C327C327C46616C73657C547275657C30&skiptokenver=v1&id=f92665be-9f36-474c-b45a-903833f53061 HTTP/1.1" 200 None
2021-09-13 09:24:03,455 - azure.core.pipeline.policies.http_logging_policy - INFO - Response status: 200
2021-09-13 09:24:03,455 - azure.core.pipeline.policies.http_logging_policy - INFO - Response headers:
2021-09-13 09:24:03,456 - azure.core.pipeline.policies.http_logging_policy - INFO - 'Cache-Control': 'private'
2021-09-13 09:24:03,456 - azure.core.pipeline.policies.http_logging_policy - INFO - 'Transfer-Encoding': 'chunked'
2021-09-13 09:24:03,456 - azure.core.pipeline.policies.http_logging_policy - INFO - 'Content-Type': 'application/json; odata.metadata=none'
2021-09-13 09:24:03,456 - azure.core.pipeline.policies.http_logging_policy - INFO - 'Content-Encoding': 'REDACTED'
2021-09-13 09:24:03,456 - azure.core.pipeline.policies.http_logging_policy - INFO - 'Vary': 'REDACTED'
2021-09-13 09:24:03,456 - azure.core.pipeline.policies.http_logging_policy - INFO - 'x-ms-ratelimit-remaining-subscription-reads': '11998'
2021-09-13 09:24:03,456 - azure.core.pipeline.policies.http_logging_policy - INFO - 'session-id': 'REDACTED'
2021-09-13 09:24:03,456 - azure.core.pipeline.policies.http_logging_policy - INFO - 'x-ms-request-id': '85327154-53df-409b-a921-7db5ff9fcf3b'
2021-09-13 09:24:03,456 - azure.core.pipeline.policies.http_logging_policy - INFO - 'x-ms-correlation-request-id': 'REDACTED'
2021-09-13 09:24:03,456 - azure.core.pipeline.policies.http_logging_policy - INFO - 'x-ms-client-request-id': '021d2398-14af-11ec-9c35-acde48001122'
2021-09-13 09:24:03,456 - azure.core.pipeline.policies.http_logging_policy - INFO - 'x-ms-ratelimit-microsoft.consumption-tenant-retry-after': 'REDACTED'
2021-09-13 09:24:03,456 - azure.core.pipeline.policies.http_logging_policy - INFO - 'x-ms-ratelimit-remaining-microsoft.consumption-tenant-requests': 'REDACTED'
2021-09-13 09:24:03,457 - azure.core.pipeline.policies.http_logging_policy - INFO - 'OData-Version': 'REDACTED'
2021-09-13 09:24:03,457 - azure.core.pipeline.policies.http_logging_policy - INFO - 'X-Powered-By': 'REDACTED'
2021-09-13 09:24:03,457 - azure.core.pipeline.policies.http_logging_policy - INFO - 'x-ms-routing-request-id': 'REDACTED'
2021-09-13 09:24:03,457 - azure.core.pipeline.policies.http_logging_policy - INFO - 'Strict-Transport-Security': 'REDACTED'
2021-09-13 09:24:03,457 - azure.core.pipeline.policies.http_logging_policy - INFO - 'X-Content-Type-Options': 'REDACTED'
2021-09-13 09:24:03,457 - azure.core.pipeline.policies.http_logging_policy - INFO - 'Date': 'Mon, 13 Sep 2021 16:24:02 GMT'
{'additional_properties': {}, 'id': '/subscriptions/xxx/providers/Microsoft.Billing/billingPeriods/20210901/providers/Microsoft.Consumption/usageDetails/xxxxx', 'name': 'xxxxx', 'type': 'Microsoft.Consumption/usageDetails', 'tags': None, 'kind': 'legacy', 'billing_account_id': '123456789', 'billing_account_name': 'xxx LLC', 'billing_period_start_date': datetime.datetime(2021, 9, 1, 0, 0, tzinfo=<isodate.tzinfo.Utc object at 0x10e6bed60>), 'billing_period_end_date': datetime.datetime(2021, 9, 30, 0, 0, tzinfo=<isodate.tzinfo.Utc object at 0x10e6bed60>), 'billing_profile_id': '123456789', 'billing_profile_name': 'xxx LLC', 'account_owner_id': '[email protected]', 'account_name': '[email protected]', 'subscription_id': 'xxx', 'subscription_name': 'XXXX', 'date': datetime.datetime(2021, 9, 13, 0, 0, tzinfo=<isodate.tzinfo.Utc object at 0x10e6bed60>), 'product': 'Bandwidth - Data Transfer Out - Zone 1', 'part_number': 'Q5H-00003', 'meter_id': '9995d93a-7d35-4d3f-9c69-7a7fea447ef4', 'meter_details': None, 'quantity': 1.4e-05, 'effective_price': 0.077999615874239, 'cost': 1.091994622e-06, 'unit_price': 0.078, 'billing_currency': 'USD', 'resource_location': 'EastUS', 'consumed_service': 'Microsoft.Storage', 'resource_id': '/subscriptions/xxx/resourceGroups/xxxx/providers/Microsoft.Storage/storageAccounts/xxxx', 'resource_name': 'xxxx', 'service_info1': None, 'service_info2': None, 'additional_info': None, 'invoice_section': 'xxxx Command Center', 'cost_center': 'US1079208', 'resource_group': 'xxxx', 'reservation_id': None, 'reservation_name': None, 'product_order_id': None, 'product_order_name': None, 'offer_id': 'MS-AZR-0148P', 'is_azure_credit_eligible': True, 'term': None, 'publisher_name': None, 'publisher_type': 'Azure', 'plan_name': None, 'charge_type': 'Usage', 'frequency': 'UsageBased'}
{'additional_properties': {}, 'id': '/subscriptions/xxx/providers/Microsoft.Billing/billingPeriods/20210901/providers/Microsoft.Consumption/usageDetails/xxxxxxx', 'name': 'xxxxxxx', 'type': 'Microsoft.Consumption/usageDetails', 'tags': None, 'kind': 'legacy', 'billing_account_id': '123456789', 'billing_account_name': 'xxx LLC', 'billing_period_start_date': datetime.datetime(2021, 9, 1, 0, 0, tzinfo=<isodate.tzinfo.Utc object at 0x10e6bed60>), 'billing_period_end_date': datetime.datetime(2021, 9, 30, 0, 0, tzinfo=<isodate.tzinfo.Utc object at 0x10e6bed60>), 'billing_profile_id': '123456789', 'billing_profile_name': 'xxx LLC', 'account_owner_id': '[email protected]', 'account_name': '[email protected]', 'subscription_id': 'xxx', 'subscription_name': 'XXXX', 'date': datetime.datetime(2021, 9, 13, 0, 0, tzinfo=<isodate.tzinfo.Utc object at 0x10e6bed60>), 'product': 'Bandwidth - Data Transfer In - Zone 1', 'part_number': 'Q5H-00017', 'meter_id': '32c3ebec-1646-49e3-8127-2cafbd3a04d8', 'meter_details': None, 'quantity': 2.4e-05, 'effective_price': 0.0, 'cost': 0.0, 'unit_price': 0.0, 'billing_currency': 'USD', 'resource_location': 'EastUS', 'consumed_service': 'Microsoft.Storage', 'resource_id': '/subscriptions/xxx/resourceGroups/xxxx/providers/Microsoft.Storage/storageAccounts/xxxx', 'resource_name': 'xxxx', 'service_info1': None, 'service_info2': None, 'additional_info': None, 'invoice_section': 'xxxx Command Center', 'cost_center': 'US1079208', 'resource_group': 'xxxx', 'reservation_id': None, 'reservation_name': None, 'product_order_id': None, 'product_order_name': None, 'offer_id': 'MS-AZR-0148P', 'is_azure_credit_eligible': True, 'term': None, 'publisher_name': None, 'publisher_type': 'Azure', 'plan_name': None, 'charge_type': 'Usage', 'frequency': 'UsageBased'}
2021-09-13 09:24:03,461 - azure.core.pipeline.policies.http_logging_policy - INFO - Request URL: 'https://management.azure.com/subscriptions/xxx/providers/Microsoft.Consumption/usageDetails?$top=REDACTED&api-version=REDACTED&sessiontoken=REDACTED&$skiptoken=REDACTED&skiptokenver=REDACTED&id=REDACTED'
2021-09-13 09:24:03,461 - azure.core.pipeline.policies.http_logging_policy - INFO - Request method: 'GET'
2021-09-13 09:24:03,461 - azure.core.pipeline.policies.http_logging_policy - INFO - Request headers:
2021-09-13 09:24:03,461 - azure.core.pipeline.policies.http_logging_policy - INFO - 'Accept': 'application/json'
2021-09-13 09:24:03,461 - azure.core.pipeline.policies.http_logging_policy - INFO - 'x-ms-client-request-id': '0273a09c-14af-11ec-9c35-acde48001122'
2021-09-13 09:24:03,461 - azure.core.pipeline.policies.http_logging_policy - INFO - 'User-Agent': 'azsdk-python-mgmt-consumption/8.0.0 Python/3.9.4 (macOS-11.5.2-x86_64-i386-64bit)'
2021-09-13 09:24:03,461 - azure.core.pipeline.policies.http_logging_policy - INFO - 'Authorization': 'REDACTED'
2021-09-13 09:24:03,461 - azure.core.pipeline.policies.http_logging_policy - INFO - No body was attached to the request
2021-09-13 09:24:04,077 - urllib3.connectionpool - DEBUG - https://management.azure.com:443 "GET /subscriptions/xxx/providers/Microsoft.Consumption/usageDetails?$top=2&api-version=2019-10-01&sessiontoken=8:45618658&$skiptoken=327C347C327C46616C73657C547275657C30&skiptokenver=v1&id=f92665be-9f36-474c-b45a-903833f53061 HTTP/1.1" 200 None
2021-09-13 09:24:04,077 - azure.core.pipeline.policies.http_logging_policy - INFO - Response status: 200
2021-09-13 09:24:04,077 - azure.core.pipeline.policies.http_logging_policy - INFO - Response headers:
2021-09-13 09:24:04,077 - azure.core.pipeline.policies.http_logging_policy - INFO - 'Cache-Control': 'private'
2021-09-13 09:24:04,078 - azure.core.pipeline.policies.http_logging_policy - INFO - 'Transfer-Encoding': 'chunked'
2021-09-13 09:24:04,078 - azure.core.pipeline.policies.http_logging_policy - INFO - 'Content-Type': 'application/json; odata.metadata=none'
2021-09-13 09:24:04,078 - azure.core.pipeline.policies.http_logging_policy - INFO - 'Content-Encoding': 'REDACTED'
2021-09-13 09:24:04,078 - azure.core.pipeline.policies.http_logging_policy - INFO - 'Vary': 'REDACTED'
2021-09-13 09:24:04,078 - azure.core.pipeline.policies.http_logging_policy - INFO - 'x-ms-ratelimit-remaining-subscription-reads': '11997'
2021-09-13 09:24:04,078 - azure.core.pipeline.policies.http_logging_policy - INFO - 'session-id': 'REDACTED'
2021-09-13 09:24:04,078 - azure.core.pipeline.policies.http_logging_policy - INFO - 'x-ms-request-id': '5fc578d4-7937-4d56-b253-eafbe6a595ea'
2021-09-13 09:24:04,078 - azure.core.pipeline.policies.http_logging_policy - INFO - 'x-ms-correlation-request-id': 'REDACTED'
2021-09-13 09:24:04,078 - azure.core.pipeline.policies.http_logging_policy - INFO - 'x-ms-client-request-id': '0273a09c-14af-11ec-9c35-acde48001122'
2021-09-13 09:24:04,078 - azure.core.pipeline.policies.http_logging_policy - INFO - 'x-ms-ratelimit-microsoft.consumption-tenant-retry-after': 'REDACTED'
2021-09-13 09:24:04,078 - azure.core.pipeline.policies.http_logging_policy - INFO - 'x-ms-ratelimit-remaining-microsoft.consumption-tenant-requests': 'REDACTED'
2021-09-13 09:24:04,078 - azure.core.pipeline.policies.http_logging_policy - INFO - 'OData-Version': 'REDACTED'
2021-09-13 09:24:04,078 - azure.core.pipeline.policies.http_logging_policy - INFO - 'X-Powered-By': 'REDACTED'
2021-09-13 09:24:04,078 - azure.core.pipeline.policies.http_logging_policy - INFO - 'x-ms-routing-request-id': 'REDACTED'
2021-09-13 09:24:04,078 - azure.core.pipeline.policies.http_logging_policy - INFO - 'Strict-Transport-Security': 'REDACTED'
2021-09-13 09:24:04,078 - azure.core.pipeline.policies.http_logging_policy - INFO - 'X-Content-Type-Options': 'REDACTED'w
2021-09-13 09:24:04,078 - azure.core.pipeline.policies.http_logging_policy - INFO - 'Date': 'Mon, 13 Sep 2021 16:24:03 GMT'
{'additional_properties': {}, 'id': '/subscriptions/xxx/providers/Microsoft.Billing/billingPeriods/20210901/providers/Microsoft.Consumption/usageDetails/xxx', 'name': 'xxx', 'type': 'Microsoft.Consumption/usageDetails', 'tags': None, 'kind': 'legacy', 'billing_account_id': '123456789', 'billing_account_name': 'xxx LLC', 'billing_period_start_date': datetime.datetime(2021, 9, 1, 0, 0, tzinfo=<isodate.tzinfo.Utc object at 0x10e6bed60>), 'billing_period_end_date': datetime.datetime(2021, 9, 30, 0, 0, tzinfo=<isodate.tzinfo.Utc object at 0x10e6bed60>), 'billing_profile_id': '123456789', 'billing_profile_name': 'xxx LLC', 'account_owner_id': '[email protected]', 'account_name': '[email protected]', 'subscription_id': 'xxx', 'subscription_name': 'XXXX', 'date': datetime.datetime(2021, 9, 13, 0, 0, tzinfo=<isodate.tzinfo.Utc object at 0x10e6bed60>), 'product': 'Tiered Block Blob - Hot RA-GRS - Data Stored - US East', 'part_number': 'N9H-01090', 'meter_id': '469a7d8f-36f1-4a99-a884-6eb97643be2c', 'meter_details': None, 'quantity': 0.00265, 'effective_price': 0.048612654060824, 'cost': 0.000128823533261, 'unit_price': 0.0487, 'billing_currency': 'USD', 'resource_location': 'EastUS', 'consumed_service': 'Microsoft.Storage', 'resource_id': '/subscriptions/xxx/resourceGroups/XXX/providers/Microsoft.Storage/storageAccounts/xxxx', 'resource_name': 'xxxx', 'service_info1': None, 'service_info2': None, 'additional_info': None, 'invoice_section': 'xxxx Command Center', 'cost_center': 'US1079208', 'resource_group': 'xxxx', 'reservation_id': None, 'reservation_name': None, 'product_order_id': None, 'product_order_name': None, 'offer_id': 'MS-AZR-0148P', 'is_azure_credit_eligible': True, 'term': None, 'publisher_name': None, 'publisher_type': 'Azure', 'plan_name': None, 'charge_type': 'Usage', 'frequency': 'UsageBased'}
{'additional_properties': {}, 'id': '/subscriptions/xxx/providers/Microsoft.Billing/billingPeriods/20210901/providers/Microsoft.Consumption/usageDetails/xxxx', 'name': 'xxxx', 'type': 'Microsoft.Consumption/usageDetails', 'tags': None, 'kind': 'legacy', 'billing_account_id': '123456789', 'billing_account_name': 'xxx LLC', 'billing_period_start_date': datetime.datetime(2021, 9, 1, 0, 0, tzinfo=<isodate.tzinfo.Utc object at 0x10e6bed60>), 'billing_period_end_date': datetime.datetime(2021, 9, 30, 0, 0, tzinfo=<isodate.tzinfo.Utc object at 0x10e6bed60>), 'billing_profile_id': '123456789', 'billing_profile_name': 'xxx LLC', 'account_owner_id': '[email protected]', 'account_name': '[email protected]', 'subscription_id': 'xxx', 'subscription_name': 'XXXX', 'date': datetime.datetime(2021, 9, 12, 0, 0, tzinfo=<isodate.tzinfo.Utc object at 0x10e6bed60>), 'product': 'Standard SSD Managed Disks - E4 - LRS - Disks - US East', 'part_number': 'AAD-37203', 'meter_id': '11ecb7d4-b18a-447a-bb0c-f057585fc701', 'meter_details': None, 'quantity': 0.033336, 'effective_price': 2.15908748363578, 'cost': 0.071975340354482, 'unit_price': 2.16, 'billing_currency': 'USD', 'resource_location': 'EastUS', 'consumed_service': 'Microsoft.Compute', 'resource_id': '/subscriptions/xxx/resourceGroups/XXX/providers/Microsoft.Compute/disks/xxxx-test-vm_OsDisk_1_ae5e32db458b4d5fb8e5f0c9c0745425', 'resource_name': 'xxxx-test-vm_OsDisk_1_ae5e32db458b4d5fb8e5f0c9c0745425', 'service_info1': None, 'service_info2': None, 'additional_info': None, 'invoice_section': 'xxxx Command Center', 'cost_center': 'US1079208', 'resource_group': 'xxxx', 'reservation_id': None, 'reservation_name': None, 'product_order_id': None, 'product_order_name': None, 'offer_id': 'MS-AZR-0148P', 'is_azure_credit_eligible': True, 'term': None, 'publisher_name': None, 'publisher_type': 'Azure', 'plan_name': None, 'charge_type': 'Usage', 'frequency': 'UsageBased'}
...
Hi @xingyu-long , thanks!
It seems that there is no problem with the request parameters. It may be a bug on the service side.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @ms-premp.
Issue Details
- Package Name: azure-mgmt-consumption
- Package Version: 8.0.0
- Operating System: Mac os Big Sur
- Python Version:
Python 3.9
Describe the bug
When I try to use
topto limit the results inusage_details.list(scope, top=2)fromConsumptionManagementClientmodule, I found it returns all the results instead of limited results, such as 2 results. After I checked the implementation of this method, it is based onPageIteratorand after print two results, it will continue to retrieve another 2 results and so on.
To Reproduce
from azure.mgmt.consumption import ConsumptionManagementClient
from azure.identity import AzureCliCredential
import os
credential = AzureCliCredential()
subscription_id = os.environ["AZURE_SUBSCRIPTION_ID"]
scope = '/subscriptions/' + subscription_id + '/'
client = ConsumptionManagementClient(credential, subscription_id)
resp = client.usage_details.list(scope, top=2)
for item in resp:
print(item)
Expected behavior I expect it should return 2 results in response.
Screenshots
Additional context
| Author: | xingyu-long |
|---|---|
| Assignees: | BigCat20196, msyyc |
| Labels: |
|
| Milestone: | - |
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @TiagoCrewGitHubIssues.
Issue Details
- Package Name: azure-mgmt-consumption
- Package Version: 8.0.0
- Operating System: Mac os Big Sur
- Python Version:
Python 3.9
Describe the bug
When I try to use
topto limit the results inusage_details.list(scope, top=2)fromConsumptionManagementClientmodule, I found it returns all the results instead of limited results, such as 2 results. After I checked the implementation of this method, it is based onPageIteratorand after print two results, it will continue to retrieve another 2 results and so on.
To Reproduce
from azure.mgmt.consumption import ConsumptionManagementClient
from azure.identity import AzureCliCredential
import os
credential = AzureCliCredential()
subscription_id = os.environ["AZURE_SUBSCRIPTION_ID"]
scope = '/subscriptions/' + subscription_id + '/'
client = ConsumptionManagementClient(credential, subscription_id)
resp = client.usage_details.list(scope, top=2)
for item in resp:
print(item)
Expected behavior I expect it should return 2 results in response.
Screenshots
Additional context
| Author: | xingyu-long |
|---|---|
| Assignees: | BigCat20196, msyyc |
| Labels: |
|
| Milestone: | - |
we are working on validating the newer version of python sdk for cost management. will update once the validation is completed and released.
This is work in progress, we do not have a new update at this time for this issue.
Hi @xingyu-long. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.
Hi @xingyu-long, since you haven’t asked that we “/unresolve” the issue, we’ll close this out. If you believe further discussion is needed, please add a comment “/unresolve” to reopen the issue.