azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

AZ CLI CONSUMPTION EMTPY RESPONSE WHEN DATA AVAILABLE

Open martingianni opened this issue 5 years ago • 9 comments

This is autogenerated. Please review and update as needed.

Describe the bug

Command Name az consumption usage list

Errors:


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 -s {} -e {} --subscription {} --debug

Expected Behavior

Environment Summary

Linux-5.4.0-1055-azure-x86_64-with-debian-10.2 (Cloud Shell)
Python 3.6.10
Installer: DEB

azure-cli 2.27.0

Extensions:
ai-examples 0.2.5
ssh 0.1.5

Additional Context

martingianni avatar Aug 05 '21 11:08 martingianni

I can see there is cost available for current month (Aug) on the Portal (WEB) but when using cli is not getting same info, just getting an emtpy list/array.

When trying same command with July works fine, but with Aug no data comes back.

Empty return az consumption usage list -s 2021-08-01 -e 2021-08-05 --subscription xxxxxxxx

Works just fine az consumption usage list -s 2021-07-01 -e 2021-07-05 --subscription xxxxxxxx

Thanks

martingianni avatar Aug 05 '21 12:08 martingianni

@martingianni, could you help run command with --debug as follows to catch debug log for us to further investigation? az consumption usage list -s 2021-08-01 -e 2021-08-05 --subscription xxxxxxxx --debug

jsntcy avatar Aug 06 '21 02:08 jsntcy

@martingianni, could you help run command with --debug as follows to catch debug log for us to further investigation? az consumption usage list -s 2021-08-01 -e 2021-08-05 --subscription xxxxxxxx --debug

Here is the output:

az consumption usage list -s 2021-08-01 -e 2021-08-05 --subscription xyz --debug

Command arguments: ['consumption', 'usage', 'list', '-s', '2021-08-01', '-e', '2021-08-05', '--subscription', 'xyz', '--debug'] Event: Cli.PreExecute [] Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x03E0C978>, <function OutputProducer.on_global_arguments at 0x03E9ADF8>, <function CLIQuery.on_global_arguments at 0x03EC0DF8>] Event: CommandInvoker.OnPreCommandTableCreate [] Modules found from index for 'consumption': ['azure.cli.command_modules.consumption'] Loading command modules: Name Load Time Groups Commands consumption 0.019 8 9 Total (1) 0.019 8 9 These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_ai_did_you_mean_this'] Loading extensions: Name Load Time Groups Commands Directory Total (0) 0.000 0 0 Loaded 8 groups, 9 commands. Found a match in the command table. Raw command : consumption usage list Command table: consumption usage list Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x040F4978>] az_command_data_logger : command args: consumption usage list -s {} -e {} --subscription {} --debug metadata file logging enabled - writing logs to 'C:\Users\xyz.azure\commands'. Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x04133DF8>] Event: CommandInvoker.OnPostArgumentLoad [] Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x04133F18>, <function register_cache_arguments..add_cache_arguments at 0x04145588>] Event: CommandInvoker.OnCommandTableLoaded [] Event: CommandInvoker.OnPreParseArgs [] Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x03E9AE40>, <function CLIQuery.handle_query_parameter at 0x03EC0E40>, <function register_ids_argument..parse_ids_arguments at 0x04145540>] Command group 'consumption' is in preview. It may be changed/removed in a future release. Getting management service client client_type=ConsumptionManagementClient msrest.universal_http.requests : Configuring retry: max_retries=4, backoff_factor=0.8, max_backoff=90 msrest.async_paging : Paging async iterator protocol is not available for UsageDetailPaged msrest.service_client : Accept header absent and forced to application/json attempting to read file C:\Users\xyz.azure\accessTokens.json as utf-8-sig adal-python : fdfc945c-8095-4dca-9633-c47081478ca2 - Authority:Performing instance discovery: ... adal-python : fdfc945c-8095-4dca-9633-c47081478ca2 - Authority:Performing static instance discovery adal-python : fdfc945c-8095-4dca-9633-c47081478ca2 - Authority:Authority validated via static instance discovery adal-python : fdfc945c-8095-4dca-9633-c47081478ca2 - TokenRequest:Getting token from cache with refresh if necessary. adal-python : fdfc945c-8095-4dca-9633-c47081478ca2 - CacheDriver:finding with query keys: {'_clientId': '...', 'userId': '...'} adal-python : fdfc945c-8095-4dca-9633-c47081478ca2 - CacheDriver:Looking for potential cache entries: {'_clientId': '...', 'userId': '...'} adal-python : fdfc945c-8095-4dca-9633-c47081478ca2 - CacheDriver:Found 37 potential entries. adal-python : fdfc945c-8095-4dca-9633-c47081478ca2 - CacheDriver:Resource specific token found. adal-python : fdfc945c-8095-4dca-9633-c47081478ca2 - CacheDriver:Returning token from cache lookup, AccessTokenId: b'PSI9UNL+ZVsf+h/jvcvcEOlHc79FnlVdLtieEknu2kw=', RefreshTokenId: b'CR4gKdUqOytiI2l7aPGmoVl2PTkal6EubdlGm6370F0=' msrest.http_logger : Request URL: 'https://management.azure.com/subscriptions/xyz/providers/Microsoft.Consumption/usageDetails?$filter=properties%2FusageEnd%20ge%20%272021-08-01T00%3A00%3A00Z%27%20and%20properties%2FusageEnd%20le%20%272021-08-05T00%3A00%3A00Z%27&api-version=2018-01-31' msrest.http_logger : Request method: 'GET' msrest.http_logger : Request headers: msrest.http_logger : 'Accept': 'application/json' msrest.http_logger : 'Content-Type': 'application/json; charset=utf-8' msrest.http_logger : 'accept-language': 'en-US' msrest.http_logger : 'User-Agent': 'python/3.6.8 (Windows-10-10.0.18362-SP0) msrest/0.6.18 msrest_azure/0.6.3 azure-mgmt-consumption/2.0.0 Azure-SDK-For-Python AZURECLI/2.11.1 (MSI)' msrest.http_logger : Request body: msrest.http_logger : None msrest.universal_http : Configuring redirects: allow=True, max=30 msrest.universal_http : Configuring request: timeout=100, verify=True, cert=None msrest.universal_http : Configuring proxies: '' msrest.universal_http : Evaluate proxies against ENV settings: True urllib3.connectionpool : Starting new HTTPS connection (1): management.azure.com:443 urllib3.connectionpool : https://management.azure.com:443 "GET /subscriptions/xyz/providers/Microsoft.Consumption/usageDetails?$filter=properties%2FusageEnd%20ge%20%272021-08-01T00%3A00%3A00Z%27%20and%20properties%2FusageEnd%20le%20%272021-08-05T00%3A00%3A00Z%27&api-version=2018-01-31 HTTP/1.1" 200 None msrest.http_logger : Response status: 200 msrest.http_logger : Response headers: msrest.http_logger : 'Cache-Control': 'private' msrest.http_logger : 'Transfer-Encoding': 'chunked' msrest.http_logger : 'Content-Type': 'application/json; odata.metadata=none' msrest.http_logger : 'Content-Encoding': 'gzip' msrest.http_logger : 'Vary': 'Accept-Encoding,Accept-Encoding' msrest.http_logger : 'x-ms-ratelimit-remaining-subscription-reads': '11999' msrest.http_logger : 'session-id': '7462f6a2-8e83-4f41-9c1e-03a118c70d8a' msrest.http_logger : 'x-ms-request-id': '6be6c256-ba18-425c-90b7-2f1a82f0bc49' msrest.http_logger : 'x-ms-correlation-request-id': 'f65af820-b7fe-4366-ab3f-68796cd69932' msrest.http_logger : 'x-ms-client-request-id': 'fb7550ec-f6bb-11eb-a4cf-0cd292fcf818' msrest.http_logger : 'x-ms-ratelimit-microsoft.consumption-tenant-retry-after': '60' msrest.http_logger : 'x-ms-ratelimit-remaining-microsoft.consumption-tenant-requests': '9' msrest.http_logger : 'x-ms-ratelimit-microsoft.consumption-clientAppId-retry-after': '60' msrest.http_logger : 'x-ms-ratelimit-remaining-microsoft.consumption-clientAppId-requests': '59' msrest.http_logger : 'OData-Version': '4.0' msrest.http_logger : 'X-Powered-By': 'ASP.NET' msrest.http_logger : 'x-ms-routing-request-id': 'BRAZILSOUTH:20210806T134128Z:f65af820-b7fe-4366-ab3f-68796cd69932' msrest.http_logger : 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains' msrest.http_logger : 'X-Content-Type-Options': 'nosniff' msrest.http_logger : 'Date': 'Fri, 06 Aug 2021 13:41:28 GMT' msrest.http_logger : Response content: msrest.http_logger : {"value":[]} Event: CommandInvoker.OnTransformResult [<function _resource_group_transform at 0x04133390>, <function _x509_from_base64_to_hex_transform at 0x041333D8>] Event: CommandInvoker.OnFilterResult [] [] Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x040F4A98>] az_command_data_logger : exit code: 0 Command ran in 8.882 seconds (init: 0.338, invoke: 8.544) telemetry.save : Save telemetry record of length 2629 in cache telemetry.check : Negative: The C:\Users\xyz.azure\telemetry.txt was modified at 2021-08-06 10:40:32.453702, which in less than 600.000000 s

martingianni avatar Aug 06 '21 13:08 martingianni

Just to add here on the Azure Portal also its looks strange.. it shows 55 USD in 7 days.. no breakdown available, no cost by service showing neither, tried two accounts, same issue. Guessing it maybe something wrong with the backend where the cost data is saved or the api fetching the data.. just my 2 cents.

martingianni avatar Aug 07 '21 12:08 martingianni

Seems it's the issue related to backend service as you can see the response body from service is empty, so route to service team

msrest.http_logger : Response content:
msrest.http_logger : {"value":[]}

jsntcy avatar Aug 13 '21 05:08 jsntcy

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @ccmbpxpcrew.

Issue Details

This is autogenerated. Please review and update as needed.

Describe the bug

Command Name az consumption usage list

Errors:


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 -s {} -e {} --subscription {} --debug

Expected Behavior

Environment Summary

Linux-5.4.0-1055-azure-x86_64-with-debian-10.2 (Cloud Shell)
Python 3.6.10
Installer: DEB

azure-cli 2.27.0

Extensions:
ai-examples 0.2.5
ssh 0.1.5

Additional Context

Author: martingianni
Assignees: -
Labels:

Service Attention, Cost Management-Billing, Consumption-Billing, consumption

Milestone: Aug 2021 (2021-09-07)

ghost avatar Aug 13 '21 06:08 ghost

@jsntcy

Same issue. However, instead of using: az consumption usage list

I'm using PowerShell's (PSVersion 7.1.4) Invoke-RestMethod with $uri: 'https://management.azure.com/subscriptions/xxxx-xxxxx-xxxxx-xxxx/providers/Microsoft.Consumption/usageDetails?startDate=2021-06-01&endDate=2021-06-10&$top=5&api-version=2019-10-01

Same result. No Payload: with 0-byte payload VERBOSE: received 12-byte response of content type application/json VERBOSE: Content encoding: utf-8 value : {}

This process works for other subscriptions of the same offer-type, same security roles, same access token, same powershell $env's. A few subscriptions return 0 records though they clearly have billing details in the portal for the period noted.

No $Error[0] is thrown.

evogelpohl avatar Aug 19 '21 12:08 evogelpohl

@Evogelpohl, for PowerShell issue, please report issue in https://github.com/Azure/azure-powershell which is owned by other team.

jsntcy avatar Aug 20 '21 01:08 jsntcy

@Evogelpohl, for PowerShell issue, please report issue in https://github.com/Azure/azure-powershell which is owned by other team.

It isn't a PowerShell issue. It's a billing-service issue. Any program that can call a REST endpoint - az (python), invoke-restmethod (powershell/.net), Postman - all return the same empty value {} for me on 4 of the 20 subscriptions I'm pulling consumption details.

I've opened a ticket for one of those 4 subs. Awaiting feedback.

I was reenforcing the fact that this bug is repo'able by other REST clients, beyond the Az CLI.

Hope that helps. Thanks!

evogelpohl avatar Aug 20 '21 12:08 evogelpohl