question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

costByResource 400 (Bad Request) for Azure Plan for DevTest

See original GitHub issue

Reproduction steps:

dotnet tool install --global azure-cost-cli ‘azure-cost-cli’ (version ‘0.13.0’) az login azure-cost costByResource -s [subscriptionId] --debug

Azure Subscription Plan type = Azure Plan for DevTest

Response status code is BadRequest and got payload size of 903
Response content: {"error":{"code":"BadRequest","message":"Invalid query definition: Invalid dataset grouping: 'ServiceTier'; valid values:
'ResourceGroup','ResourceGroupName','ResourceType','ResourceId','ResourceLocation','SubscriptionId','SubscriptionName','MeterCategory','MeterSubcategory','Meter','ServiceFamily','UnitOfMeasure','PartNumber','BillingAccountName','BillingProfileId','BillingProfileName','InvoiceSect
ion','InvoiceSectionId','InvoiceSectionName','Product','ResourceGuid','ChargeType','ServiceName','ProductOrderId','ProductOrderName','PublisherType','ReservationId','ReservationName','Frequency','InvoiceId','PricingModel','CostAllocationRuleName','MarkupRuleName','BillingMonth','
Provider','BenefitId','BenefitName','CustomerTenantId','CustomerTenantDomainName','ResellerMPNId','PartnerEarnedCreditApplied','CustomerName','PartnerName',''.\r\n\r\n (Request ID: f9875835-263f-4544-874f-0b270a21ee66)"}}
Error: Response status code does not indicate success: 400 (Bad Request).

Please note the below works for the same subscription azure-cost accumulatedCost -s [subscriptionId]

full output of --debug before the error above:

Using token credential: ChainedTokenCredential to fetch a token.
Token retrieved and expires at: 24/04/2023 7:13:47 AM +00:00
Retrieving data from /subscriptions/[subscriptionId]/providers/Microsoft.CostManagement/query?api-version=2021-10-01&$top=5000 using the following payload:
{
   "type": "ActualCost",
   "timeframe": "BillingMonthToDate",
   "timePeriod": null,
   "dataSet": {
      "granularity": "None",
      "aggregation": {
         "totalCost": {
            "name": "Cost",
            "function": "Sum"
         },
         "totalCostUSD": {
            "name": "CostUSD",
            "function": "Sum"
         }
      },
      "include": [
         "Tags"
      ],
      "grouping": [
         {
            "type": "Dimension",
            "name": "ResourceId"
         },
         {
            "type": "Dimension",
            "name": "ResourceType"
         },
         {
            "type": "Dimension",
            "name": "ResourceLocation"
         },
         {
            "type": "Dimension",
            "name": "ChargeType"
         },
         {
            "type": "Dimension",
            "name": "ResourceGroupName"
         },
         {
            "type": "Dimension",
            "name": "PublisherType"
         },
         {
            "type": "Dimension",
            "name": "ServiceName"
         },
         {
            "type": "Dimension",
            "name": "ServiceTier"
         },
         {
            "type": "Dimension",
            "name": "Meter"
         }
      ]
   }
}

Issue Analytics

  • State:closed
  • Created 5 months ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
mivanocommented, Jul 7, 2023

I think I found the culprit. Some conversion (https://learn.microsoft.com/en-us/azure/cost-management-billing/automate/migrate-ea-usage-details-api#data-field-mapping) was needed. Could you please try 0.29.0 ?

1reaction
Daniel-Spindler-Mandalaycommented, Jul 9, 2023

tested same command using 0.30.0 confirmed issue is resolved. Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · mivano/azure-cost-cli
CLI tool to perform cost analysis on your Azure subscription - Issues ... costByResource 400 (Bad Request) for Azure Plan for DevTest bug...
Read more >
Web api azure 400 Bad Request - Microsoft Q&A
Web api azure 400 Bad Request ... but when I publish the api, setting the first parameter to null gives me a 400...
Read more >
Troubleshoot common Cost Management errors
BadRequest. Error message BadRequest . Mitigation. When using the Query or Forecast APIs to retrieve cost data, validate the query body.
Read more >
Azure Plan for DevTest
Azure Plan for DevTest provides lower rates on Windows on Azure Virtual Machines, Cloud Services, HDInsight, Azure SQL Database, and Web Apps. Azure...
Read more >
Azure App service 400 Bad request! — A STORY | by Roopa V R
So, whats HTTP status Code 400 Bad Request ? the 4XX errors signify that the Client seemed to have Erred. 400 in particular...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found