Git Product home page Git Product logo

Comments (18)

mivano avatar mivano commented on June 7, 2024 1

Hopefully, MS will move more types to the new cost API soon. Unfortunately, the previous error obscured that it simply did not had any data.

from azure-cost-cli.

FrancescoBonizzi avatar FrancescoBonizzi commented on June 7, 2024

My subscription infos:

{
  "authorizationSource": "Legacy",
  "displayName": "XXX",
  "id": "/subscriptions/YYY",
  "state": "Enabled",
  "subscriptionId": "YYY",
  "subscriptionPolicies": {
    "locationPlacementId": "Public_2014-09-01",
    "quotaId": "Sponsored_2016-01-01",
    "spendingLimit": "Off"
  }
}

from azure-cost-cli.

mivano avatar mivano commented on June 7, 2024

I pushed a fix/workaround for this in v0.15

from azure-cost-cli.

FrancescoBonizzi avatar FrancescoBonizzi commented on June 7, 2024

Hi @mivano and thanks for the update!

Now the error is this one Error: Sequence contains no elements:

Version: 0.4.0.0
No subscription ID specified. Trying to retrieve the default subscription ID from Azure CLI.
Default subscription ID retrieved from az cli: [subid]
Token retrieved and expires at: 09/05/2023 07:31:48 +00:00
Retrieving data from 
/subscriptions/[subid]/providers/Microsoft.CostManagement/query?api-version=2021-10-01&$top=5000 using
the following payload:
{
   "type": "ActualCost",
   "timeframe": "BillingMonthToDate",
   "timePeriod": null,
   "dataSet": {
      "granularity": "Daily",
      "aggregation": {
         "totalCost": {
            "name": "Cost",
            "function": "Sum"
         },
         "totalCostUSD": {
            "name": "CostUSD",
            "function": "Sum"
         }
      },
      "sorting": [
         {
            "direction": "Ascending",
            "name": "UsageDate"
         }
      ]
   }
}
Response status code is OK and got payload size of 455
Error: Sequence contains no elements

from azure-cost-cli.

mivano avatar mivano commented on June 7, 2024

According to the debug output, it does not even call the forecast API. Got this every time? Also on the costByResource command?

from azure-cost-cli.

FrancescoBonizzi avatar FrancescoBonizzi commented on June 7, 2024

Yes, I get this error even now, after some hours from the first try. (accumulatedCost, does the same)

With the costByResource the error is this:

fbonizzi@MacBook-Air-di-Francesco ~ % azure-cost costByResource --debug
Version: 0.4.0.0
No subscription ID specified. Trying to retrieve the default subscription ID 
from Azure CLI.
Default subscription ID retrieved from az cli: 
[subId]
Using token credential: ChainedTokenCredential to fetch a token.
Token retrieved and expires at: 09/05/2023 11:21:36 +00:00
Retrieving data from 
/subscriptions/[subId]/providers/Microsoft.CostMana
gement/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"
         }
      ]
   }
}
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','ResourceLocatio
n','SubscriptionId','SubscriptionName','MeterCategory','MeterSubcategory','Meter
','ServiceFamily','UnitOfMeasure','PartNumber','BillingAccountName','BillingProf
ileId','BillingProfileName','InvoiceSection','InvoiceSectionId','InvoiceSectionN
ame','Product','ResourceGuid','ChargeType','ServiceName','ProductOrderId','Produ
ctOrderName','PublisherType','ReservationId','ReservationName','Frequency','Invo
iceId','PricingModel','CostAllocationRuleName','MarkupRuleName','BillingMonth','
Provider','BenefitId','BenefitName','CustomerTenantId','CustomerTenantDomainName
','ResellerMPNId','PartnerEarnedCreditApplied','CustomerName','PartnerName',''.\
r\n\r\n (Request ID: 0c81c26c-9250-4407-a5c4-1f2777cd13e0)"}}

from azure-cost-cli.

FrancescoBonizzi avatar FrancescoBonizzi commented on June 7, 2024

@mivano If I can do something to help with this, please tell me 😆

from azure-cost-cli.

mivano avatar mivano commented on June 7, 2024

Sorry not having been able to fix this properly. I cannot reproduce this on my subscriptions.

Just to be clear; the ServiceTier grouping is only for the costByResource. Do the other calls work for you? I do not understand why the ServiceTier is not retrievable. This contains useful information about SKU and type of cost (like table, files, network)

from azure-cost-cli.

FrancescoBonizzi avatar FrancescoBonizzi commented on June 7, 2024

No problem, let's try the other methods:

By calling azure-cost accumulatedCost --debug, I got:

Version: 0.23.0.0
No subscription ID specified. Trying to retrieve the default subscription ID 
from Azure CLI.
Default subscription ID retrieved from az cli: 
[subId]
Using token credential: ChainedTokenCredential to fetch a token.
Token retrieved and expires at: 11/06/2023 16:03:03 +00:00
Retrieving data from 
/subscriptions/[subId]/?api-version=2019-11-01 
using the following payload:
null
Response status code is OK and got payload size of 388
Retrieved subscription details:
{
   "id": "/subscriptions/[subId]",
   "authorizationSource": "Legacy",
   "managedByTenants": [
   ],
   "subscriptionId": "[subId]",
   "tenantId": "1dc02703-20bf-42d8-8622-75e8d168dbb8",
   "displayName": "[subName]",
   "state": "Enabled",
   "subscriptionPolicies": {
      "locationPlacementId": "Public_2014-09-01",
      "quotaId": "Sponsored_2016-01-01",
      "spendingLimit": "Off"
   }
}
Retrieving data from 
/subscriptions/[subId]/providers/Microsoft.CostMana
gement/query?api-version=2021-10-01&$top=5000 using the following payload:
{
   "type": "ActualCost",
   "timeframe": "BillingMonthToDate",
   "timePeriod": null,
   "dataSet": {
      "granularity": "Daily",
      "aggregation": {
         "totalCost": {
            "name": "Cost",
            "function": "Sum"
         },
         "totalCostUSD": {
            "name": "CostUSD",
            "function": "Sum"
         }
      },
      "filter": null,
      "sorting": [
         {
            "direction": "Ascending",
            "name": "UsageDate"
         }
      ]
   }
}
Response status code is OK and got payload size of 455
Retrieving data from 
/subscriptions/[subId]/providers/Microsoft.CostMana
gement/forecast?api-version=2021-10-01&$top=5000 using the following payload:
{
   "type": "ActualCost",
   "timeframe": "Custom",
   "timePeriod": {
      "from": "2023-06-01",
      "to": "2023-06-30"
   },
   "dataSet": {
      "granularity": "Daily",
      "aggregation": {
         "totalCost": {
            "name": "Cost",
            "function": "Sum"
         }
      },
      "filter": null,
      "sorting": [
         {
            "direction": "ascending",
            "name": "UsageDate"
         }
      ]
   }
}
Response status code is FailedDependency and got payload size of 97
Response content: {"error":{"code":"FailedDependency","message":"Can't do 
forecast - cost training data is empty"}}
System.Net.Http.HttpRequestException: Response status code does not indicate 
success: 424 (Failed Dependency).
  at HttpResponseMessage System.Net.Http.HttpResponseMessage.                   
     EnsureSuccessStatusCode()                                                  
  at async Task<HttpResponseMessage> AzureCostCli.CostApi.AzureCostApiRetriever.
     ExecuteCallToCostApi(bool includeDebugOutput, object payload, Uri uri) in  
     /home/runner/work/azure-cost-cli/azure-cost-cli/src/CostApi/               
     AzureCostApiRetriever.cs:163                                               
  at async Task<IEnumerable<CostItem>>                                          
     AzureCostCli.CostApi.AzureCostApiRetriever.RetrieveForecastedCosts(bool    
     includeDebugOutput, Guid subscriptionId, string[] filter, TimeframeType    
     timeFrame, DateOnly from, DateOnly to) in                                  
     /home/runner/work/azure-cost-cli/azure-cost-cli/src/CostApi/               
     AzureCostApiRetriever.cs:612                                               
Ignoring this exception, as it is not supported for all subscriptions.
Retrieving data from 
/subscriptions/[subId]/providers/Microsoft.CostMana
gement/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"
         }
      },
      "sorting": [
         {
            "direction": "Ascending",
            "name": "UsageDate"
         }
      ],
      "grouping": [
         {
            "type": "Dimension",
            "name": "ServiceName"
         }
      ],
      "filter": null
   }
}
Response status code is OK and got payload size of 457
Retrieving data from 
/subscriptions/[subId]/providers/Microsoft.CostMana
gement/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"
         }
      },
      "sorting": [
         {
            "direction": "Ascending",
            "name": "UsageDate"
         }
      ],
      "grouping": [
         {
            "type": "Dimension",
            "name": "ResourceLocation"
         }
      ],
      "filter": null
   }
}
Response status code is OK and got payload size of 462
Retrieving data from 
/subscriptions/[subId]/providers/Microsoft.CostMana
gement/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"
         }
      },
      "sorting": [
         {
            "direction": "Ascending",
            "name": "UsageDate"
         }
      ],
      "grouping": [
         {
            "type": "Dimension",
            "name": "ResourceGroupName"
         },
         {
            "type": "Dimension",
            "name": "ChargeType"
         }
      ],
      "filter": null
   }
}

}
Response status code is OK and got payload size of 501
Error: Sequence contains no elements

from azure-cost-cli.

FrancescoBonizzi avatar FrancescoBonizzi commented on June 7, 2024

By calling azure-cost budgets --debug, I get:

Version: 0.23.0.0

No subscription ID specified. Trying to retrieve the default subscription ID 
from Azure CLI.

Default subscription ID retrieved from az cli: 
[subId]
Using token credential: ChainedTokenCredential to fetch a token.
Token retrieved and expires at: 11/06/2023 16:03:03 +00:00
Retrieving data from 
/subscriptions/[subId]/providers/Microsoft.Consumpt
ion/budgets/?api-version=2021-10-01 using the following payload:

null

Response status code is BadRequest and got payload size of 253
Response content: {"error":{"code":"400","message":"Cost Management supports 
only Enterprise Agreement, Web direct and Microsoft Customer Agreement offer 
types. offerId: MS-AZR-0036P is associated with offerType: None (Request ID: 
8d354889-ee54-46e8-a50f-7f2f80331b4a)"}}

Error: Response status code does not indicate success: 400 (Bad Request).

from azure-cost-cli.

FrancescoBonizzi avatar FrancescoBonizzi commented on June 7, 2024

azure-cost dailyCosts --debug

Version: 0.23.0.0
No subscription ID specified. Trying to retrieve the default subscription ID 
from Azure CLI.
Default subscription ID retrieved from az cli: 
[subId]
Using token credential: ChainedTokenCredential to fetch a token.
Token retrieved and expires at: 11/06/2023 16:03:03 +00:00
Retrieving data from 
/subscriptions/[subId]/?api-version=2019-11-01 
using the following payload:
null
Response status code is OK and got payload size of 388
Retrieved subscription details:
{
   "id": "/subscriptions/[subId]",
   "authorizationSource": "Legacy",
   "managedByTenants": [
   ],
   "subscriptionId": "[subId]",
   "tenantId": "1dc02703-20bf-42d8-8622-75e8d168dbb8",
   "displayName": "[subName]",
   "state": "Enabled",
   "subscriptionPolicies": {
      "locationPlacementId": "Public_2014-09-01",
      "quotaId": "Sponsored_2016-01-01",
      "spendingLimit": "Off"
   }
}
Retrieving data from 
/subscriptions/[subId]/providers/Microsoft.CostMana
gement/query?api-version=2021-10-01&$top=5000 using the following payload:
{
   "type": "ActualCost",
   "timeframe": "BillingMonthToDate",
   "timePeriod": null,
   "dataSet": {
      "granularity": "Daily",
      "aggregation": {
         "totalCost": {
            "name": "Cost",
            "function": "Sum"
         },
         "totalCostUSD": {
            "name": "CostUSD",
            "function": "Sum"
         }
      },
      "sorting": [
         {
            "direction": "Ascending",
            "name": "UsageDate"
         }
      ],
      "grouping": [
         {
            "type": "Dimension",
            "name": "ResourceGroupName"
         },
         {
            "type": "Dimension",
            "name": "ChargeType"
         }
      ],
      "filter": null
   }
}

from azure-cost-cli.

mivano avatar mivano commented on June 7, 2024

That Sponsored_2016-01-01 is still somewhere an issue. Thanks for the traces, I will try to see what I can dig up!

from azure-cost-cli.

FrancescoBonizzi avatar FrancescoBonizzi commented on June 7, 2024

Thanks a lot! 🚀

from azure-cost-cli.

mivano avatar mivano commented on June 7, 2024

The 0.29.0 release will hopefully solve the servicetier issue (when you try to fetch the cost for resources).

from azure-cost-cli.

FrancescoBonizzi avatar FrancescoBonizzi commented on June 7, 2024

Hi and thanks!
I confirm that there are no errors, but the result is empty!

azure-cost costByResource --debug

Version: 0.30.0.0
No subscription ID specified. Trying to retrieve the default subscription ID 
from Azure CLI.
Default subscription ID retrieved from az cli: 
[subid]
Using token credential: ChainedTokenCredential to fetch a token.
Token retrieved and expires at: 09/07/2023 07:33:05 +00:00
Retrieving data from                 
/subscriptions/[subid]/providers/Microsoft.CostMana
gement/query?api-version=2021-10-01&$top=5000 using the following payload:
{                                    
   "type": "ActualCost", resources...
   "timeframe": "BillingMonthToDate",
   "timePeriod": null,
   "dataSet": {
      "granularity": "None",
      "aggregation": {
         "totalCost": {
            "name": "Cost",
            "function": "Sum"
         },
         "totalCostUSD": {
            "name": "CostUSD",
            "function": "Sum"
         }
      },
      "include": [
         "Tags"
      ],
      "filter": null,
      "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": "MeterCategory"
         },
         {
            "type": "Dimension",
            "name": "MeterSubcategory"
         },
         {
            "type": "Dimension",
            "name": "Meter"
         }
      ]
   }
}                                     
Response status code is OK and got payload size of 813
Cost by resources

It ends like this:

image

from azure-cost-cli.

mivano avatar mivano commented on June 7, 2024

Is this the same subscription as listed in your first post? So a Sponsored_2016-01-01 type? If so, then this is an unsupported quota id according to this list: https://learn.microsoft.com/en-us/azure/cost-management-billing/costs/understand-cost-mgt-data#supported-microsoft-azure-offers

from azure-cost-cli.

FrancescoBonizzi avatar FrancescoBonizzi commented on June 7, 2024

Yes, the same. Ok, so we are done. 🙈

from azure-cost-cli.

FrancescoBonizzi avatar FrancescoBonizzi commented on June 7, 2024

The good news is that when we will finish the sponsorship bonus, we will go back with a normal subscription so I will be able to use your wonderful tool. 🤣

from azure-cost-cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.