GithubHelp home page GithubHelp logo

mivano / azure-cost-cli Goto Github PK

View Code? Open in Web Editor NEW
793.0 19.0 98.0 1.29 MB

CLI tool to perform cost analysis on your Azure subscription

License: Apache License 2.0

C# 100.00%
azure cli cost command-line cost-management dotnet-tool finops governance

azure-cost-cli's Introduction

Hi there 👋

I'm a Microsoft .NET developer/consultant/architect/manager with a focus on web applications and cloud systems, but also working on backend applications and more complex integrations. Being a certified Scrum Master I additionally started to coach and help multiple scrum teams but moved my focus more to building and managing product and technology teams and had the CTO role in previous organizations.

My heart is with the technique although I'm also capable of managing different teams with professionals over the last couple of years. Being involved with the hiring process and coaching of the people while also setting the IT vision and executing on the strategies. I m interested in team topologies and improving the way people work together to great working software in an agile way.

mivano's GitHub stats

Latest blog posts

azure-cost-cli's People

Contributors

cvs79 avatar dependabot[bot] avatar erincon01 avatar mivano avatar sujithq avatar zilberd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

azure-cost-cli's Issues

Monthly issue metrics report

Issue Metrics

Metric Value
Average time to first response 0:00:02
Average time to close 0:01:29
Average time to answer None
Number of items that remain open 0
Number of items closed 1
Total number of items created 1
Title URL Time to first response Time to close Time to answer
Monthly issue metrics report #67 0:00:02 0:01:29 None

This report was generated with the Issue Metrics Action
Search query used to find these items: repo:mivano/azure-cost-cli is:issue created:2023-08-01..2023-08-31 -reason:"not planned"

unable to install "dotnet tool install --global azure-cost-cli".

dotnet sdk version 6.0.408

error:
error NU1100: Unable to r
esolve 'azure-cost-cli (>= 0.0.0)' for 'net6.0/any'.
The tool package could not be restored.
Tool 'azure-cost-cli' failed to install. This failure may have been caused by:

  • You are attempting to install a preview release and did not use the --version option to specify the version.
  • A package by this name was found, but it was not a .NET tool.
  • The required NuGet feed cannot be accessed, perhaps because of an Internet connection problem.
  • You mistyped the name of the tool.

For more reasons, including package naming enforcement, visit https://aka.ms/failure-installing-tool

Error when running the command azure-cost dailyCosts -b locally

hi @mivano, after authenticating on my local Azure CLI with az login --tenant or az login, I am trying to run the following comand:

azure-cost dailyCosts -b xxxxxxx --timeframe BillingMonthToDate --dimension ResourceGroupName --includeTags -o json

Unfortunatly, I get the following error:
System.ArgumentException: Missing subscription ID. Please specify a subscription ID or login to Azure CLI.
System.ComponentModel.Win32Exception: An error occurred trying to start process 'az' with working directory
'C:\Users\xxxxxx'. The system cannot find the file specified.
at bool System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at string AzureCostCli.Infrastructure.AzCommand.GetDefaultAzureSubscriptionId() in
/home/runner/work/azure-cost-cli/azure-cost-cli/src/Infrastructure/AzCommand.cs:22
at async Task AzureCostCli.Commands.DailyCost.DailyCostCommand.ExecuteAsync(CommandContext context,
DailyCostSettings settings) in /home/runner/work/azure-cost-cli/azure-cost-cli/src/Commands/DailyCost/
DailyCost.cs:73

It works if I run the same comand on the Azure Cloud shell. It also work if I specify a certain subscription with the -s switch. It would be really cool to get a report of all my subscriptions.

Monthly issue metrics report

Issue Metrics

Metric Average Median 90th percentile
Time to first response 5:17:56 5:17:56 5:17:56
Time to close None None None
Time to answer None None None
Metric Count
Number of items that remain open 1
Number of items closed 0
Total number of items created 1
Title URL Author Time to first response Time to close Time to answer
Exclude when filtering #107 Nastaliss 5:17:56 None None

This report was generated with the Issue Metrics Action
Search query used to find these items: repo:mivano/azure-cost-cli is:issue created:2024-02-01..2024-02-29 -reason:"not planned"

Report "dailyCost" by period.

Good afternoon.
I'm using your product "azure-cost-cli" and I'm really enjoying it.
However, I'm trying to extract data from last month through "dailyCosts" command and I can't get results.
It is only showing data for the current month.
I'm using the following command: azure-cost dailyCosts -s xxxx-xxxx-xxxx-xxxx --dimension MeterCategory --from 2023-12-01 --to 2023-12-31 -o csv > dailycost1.csv.
Can you help me?

Thanks in advance.

[Bug] image not displayed

Hi @mivano,

I hope you find well.

I have been testing this action and is working great. Do you know why I am getting an image rendering issue on the summary?

Unable to render rich display

Diagram error not found.

For more information, see https://docs.github.com/get-started/writing-on-github/working-with-advanced-formatting/creating-diagrams#creating-mermaid-diagrams

Screenshot from 2023-05-18 10-10-53

Monthly issue metrics report

Issue Metrics

Metric Average Median 90th percentile
Time to first response None None None
Time to close 0:31:25 0:31:25 0:31:25
Time to answer None None None
Metric Count
Number of items that remain open 0
Number of items closed 1
Total number of items created 1
Title URL Author Time to first response Time to close Time to answer
Response status code does not indicate success: 401 (Unauthorized) #95 hyonsok3 None 0:31:25 None

This report was generated with the Issue Metrics Action
Search query used to find these items: repo:mivano/azure-cost-cli is:issue created:2023-12-01..2023-12-31 -reason:"not planned"

Improve logging

Enhance the logging, so we see why/what the Azure API returns.

Discussed in #3

Originally posted by gbralo April 14, 2023
i am getting this error
Error: Response status code does not indicate success: 400 (Bad Request).
i specified subscription id

Unable to install azure-cost-cli

I am using the following command dotnet tool install --global azure-cost-cli --version 0.25.0

I am getting the following error:

\AppData\Local\Temp\71bd9be1-4337-42d7-a4b1-618467d9a5f4\restore.csproj : error NU1301: Unable to
load the service index for source https://pkgs.dev.azure.com/[username]/_packaging/PartsUnlimitedShared/nuget/v3/inde
x.json.
The tool package could not be restored.
Tool 'azure-cost-cli' failed to install. This failure may have been caused by:

* You are attempting to install a preview release and did not use the --version option to specify the version.
* A package by this name was found, but it was not a .NET tool.
* The required NuGet feed cannot be accessed, perhaps because of an Internet connection problem.
* You mistyped the name of the tool.

For more reasons, including package naming enforcement, visit https://aka.ms/failure-installing-tool

dotnet --version: 7.0.304

400 (Bad Request) when attempting to use CostByResource

Hi - I'm experiencing issues using the CostByResource parameter.

The ServiceTier does not appear to be valid.

Version: 0.16.0

Command: azure-cost costByResource -s {SUBSCRIPTION_ID} --debug

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

Detailed Error: 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','BillingProf
ileId','BillingProfileName','InvoiceSection','InvoiceSectionId','InvoiceSectionName','Product','ResourceGuid','ChargeTyp
e','ServiceName','ProductOrderId','ProductOrderName','PublisherType','ReservationId','ReservationName','Frequency','Invo
iceId','PricingModel','CostAllocationRuleName','MarkupRuleName','BillingMonth','Provider','BenefitId','BenefitName','Cus
tomerTenantId','CustomerTenantDomainName','ResellerMPNId','PartnerEarnedCreditApplied','CustomerName','PartnerName',''.
r\n\r\n

Problem with installation

I have tried install solution but i'm getting this error :

PS C:\Users\marian.danisek> dotnet tool install --global azure-cost-cli
C:\Users\marian.danisek\AppData\Local\Temp\d376cbd6-6106-416d-b0d5-2964222e471e\restore.csproj : error NU1100: Unable t
o resolve 'azure-cost-cli (>= 0.0.0)' for 'net7.0'.
C:\Users\marian.danisek\AppData\Local\Temp\d376cbd6-6106-416d-b0d5-2964222e471e\restore.csproj : error NU1100: Unable t
o resolve 'azure-cost-cli (>= 0.0.0)' for 'net7.0/any'.
The tool package could not be restored.
Tool 'azure-cost-cli' failed to install. This failure may have been caused by:

  • You are attempting to install a preview release and did not use the --version option to specify the version.
  • A package by this name was found, but it was not a .NET tool.
  • The required NuGet feed cannot be accessed, perhaps because of an Internet connection problem.
  • You mistyped the name of the tool.

For more reasons, including package naming enforcement, visit https://aka.ms/failure-installing-tool

API returns `424 Failed dependency`

          To me the error now is `424 Failed dependency`
Version: 0.4.0.0
Using token credential: ChainedTokenCredential to fetch a token.
Token retrieved and expires at: 18/04/2023 16:02:25 +00:00
Retrieving data from 
/subscriptions/[subId]/providers/Microsoft.CostManagement/query?api-versio
n=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
Retrieving data from 
/subscriptions/[subId]/providers/Microsoft.CostManagement/forecast?api-ver
sion=2021-10-01&$top=5000 using the following payload:
{
   "type": "ActualCost",
   "timeframe": "Custom",
   "timePeriod": {
      "from": "2023-04-18",
      "to": "2023-05-02"
   },
   "dataSet": {
      "granularity": "Daily",
      "aggregation": {
         "totalCost": {
            "name": "Cost",
            "function": "Sum"
         }
      },
      "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"}}

Hi @mivano! I didn't understand if this kind of error is going to be solved or if is it impossible to make ti work with my kind of subscription because of API design. Thanks!

Originally posted by @FrancescoBonizzi in #6 (comment)

From parameter ignored

When specifying a --from, it seems to ignore the input, taking the current date, where the --to parameter seems to be properly propagated to the API. --debug shows this:

azure-cost --debug -s c345e773-72a5-4731-4ab6-8f371e38f7e6 --from 2023-04-01 --to 2023-04-30

Retrieving data from /subscriptions/c04fee73-7da3-4835-8ae1-6f373ee81794/providers/Microsoft.CostManagement/forecast?api-version=2021-10-01&$top=5000 using the following payload:
{
"type": "ActualCost",
"timeframe": "Custom",
"timePeriod": {
"from": "2023-05-02",
"to": "2023-04-30"
},

costByResource 400 (Bad Request) for Azure Plan for DevTest

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"
         }
      ]
   }
}

Savings analysis DevTest/Savings plan/Reservations

Hi @mivano! Thanks for building this nice tool.

What we see currently is that it is very hard to do a quick analysis what DevTest subscriptions would save us.

It would be nice to have functionality to do some of the cost calculations upfront with azure-cost!

Getting error while trying to retrieve cost for using Custom timeframe

I am trying to get Azure cost for last month and trying to use Custom timeframe using "from" and "to" date, but getting error,

Error: Object reference not set to an instance of an object.

Here is the stack:

❯ azure-cost show -s XXXXXXXXXXXXXXXXXXXXXXX --timeframe Custom --from 3/1/2023 --to 3/31/2023 --debug
Using token credential: ChainedTokenCredential to fetch a token.
Token retrieved and expires at: 4/16/2023 8:33:02 AM +00:00
Retrieving costs from /subscriptions/XXXXXXXXXXXXXXXXXXXXXXX/providers/Microsoft.CostManagement/query?api-version=2021-10-01&$top=5000 using
the following payload:
{
"type": "ActualCost",
"timeframe": "Custom",
"timePeriod": {
"from": "2023-03-01",
"to": "2023-03-31"
},
"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
Retrieving costs from /subscriptions/XXXXXXXXXXXXXXXXXXXXXXX/providers/Microsoft.CostManagement/forecast?api-version=2021-10-01&$top=5000 using
the following payload:
{
"type": "ActualCost",
"dataSet": {
"granularity": "Daily",
"aggregation": {
"totalCost": {
"name": "Cost",
"function": "Sum"
}
},
"sorting": [
{
"direction": "Ascending",
"name": "UsageDate"
}
],
"filter": {
"Dimensions": {
"Name": "PublisherType",
"Operator": "In",
"Values": [
"azure"
]
}
}
}
}
Response status code is OK and got payload size of
Retrieving costs from /subscriptions/XXXXXXXXXXXXXXXXXXXXXXX/providers/Microsoft.CostManagement/query?api-version=2021-10-01&$top=5000 using
the following payload:
{
"type": "ActualCost",
"timeframe": "Custom",
"timePeriod": {
"from": "2023-03-01",
"to": "2023-03-31"
},
"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": {
"Dimensions": {
"Name": "PublisherType",
"Operator": "In",
"Values": [
"azure"
]
}
}
}
}
Response status code is OK and got payload size of
Retrieving costs from /subscriptions/XXXXXXXXXXXXXXXXXXXXXXX/providers/Microsoft.CostManagement/query?api-version=2021-10-01&$top=5000 using
the following payload:
{
"type": "ActualCost",
"timeframe": "Custom",
"timePeriod": {
"from": "2023-03-01",
"to": "2023-03-31"
},
"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": {
"Dimensions": {
"Name": "PublisherType",
"Operator": "In",
"Values": [
"azure"
]
}
}
}
}
Response status code is OK and got payload size of
Error: Object reference not set to an instance of an object.

Exclude when filtering

Filters only seem to be inclusive .
I was trying to exclude a certain tag but it looks like there is currently no way to do this.
I feel like this could be useful, what do you think ?

cost by service name and location are not displayed , any thoughts?

Screenshot 2023-04-17 at 23 02 11

Subscription details:

{
"authorizationSource": "RoleBased",
"displayName": "Azure for Students",
"id": "/subscriptions/XXXXXXXXXXXX",
"state": "Enabled",
"subscriptionId": "XXXXXXXXXXXXX",
"subscriptionPolicies": {
"locationPlacementId": "Public_2014-09-01",
"quotaId": "AzureForStudents_2018-01-01",
"spendingLimit": "On"
}
}

Set thresholds

Specify a threshold, which will return a failed code when it goes over it (percentage/absolute)

Monthly issue metrics report

Issue Metrics

Metric Value
Average time to first response 1 day, 18:16:57
Average time to close None
Average time to answer None
Number of items that remain open 2
Number of items closed 0
Total number of items created 2
Title URL Time to first response Time to close Time to answer
Cost by Tag #64 2 days, 14:36:52 None None
Savings analysis DevTest/Savings plan/Reservations #61 21:57:02 None None

This report was generated with the Issue Metrics Action
Search query used to find these items: repo:mivano/azure-cost-cli is:issue created:2023-07-01..2023-07-31 -reason:"not planned"

Configure the number of items before they become "Others" category

Add an option, so the default of 10 can be overwritten before the list of resource groups, locations and servicenames is collapsed into an Others category.

Discussed in #12

Originally posted by ajmal-yazdani April 17, 2023
It's very excellent to see all the resource cost by service name where I am seeing lots of services cost going to "Other" head and showing as a cumulative cost .

Can we drill down all actual services and shows all services cost instead of "Other":

image

Cost by Tag

We use tags extensively to breakdown business ownership and recharge back to them.

Would it be possible to add byTag and then for it to take 1 or more tags. The breakdown csv/putput should then have a column for each tag specified.

Forecast causing crash on custom timeframe

When specifying historical timeframe to get the cost, because the forecast is always executed in code, it fails with no proper output. Example:

azure-cost accumulatedCost --debug -s XXXX -t Custom --from 2023-01-01 --to 2023-04-30 -o json

yields

Response status code is BadRequest and got payload size of 76
Response content: {"error":{"code":"CantForecastOnThePast","message":"CantForecastOnThePast"}}

because the forecast API is passed the from/to dates.

[question] how to get report by one resource group

Hi @mivano

Greetings.

How can I get the report for 1 resource group in the subscription? For example:

resource group name: my-new-resource-group

My command:

azure-cost -o json --query "[my-new-resource-group].[ResourceGroup, Cost]"

I don't understand how to use the query filter to get the data just for one resource group.

  • Also, do you think this filter is just for the json output format or could be used with the markdown format too?
  • Also, do you know if I can pass to the query filter a "tag" for getting only resources with a specific tag?

The idea with this is to get the report for a specific project that belongs to a specific resource group in the subscription.

Async fetching of cost data

I have built and maintained, and rewritten, the logic for fetching and processing cost data for a few years, so I am quite intimate with these APIs, and one major issue is that getting larger amounts of data is painfully slow.

This is both due to using pagination, and that JSON is very inefficient as a large portion of the raw data fetched are json properties.

There is a much less known and poorly documented (I have had the cost management team confirm this is officially supported) way of getting large amounts of data. The endpoint looks something like below. basically just appending /download

/subscriptions/000-000-000-000-000/providers/Microsoft.Consumption/usageDetails/download?api-version=2019-10-01&metric=AmortizedCost&ln=en&startDate=2023/01/01&endDate=2023/05/01

What happens is that you get an immediate response and in the response headers the one called location contains a uri that keeps track of an async operation that is generating a csv file. You can poll this every few seconds, and eventually it will provide a link to a the csv (it uses a SAS token in a storage account).

(you could try it out in Postman or similar to get a feel of the speed)

You would then have to download the csv file and parse the data.

You would probably need some sort of logic to determine if this method is faster than getting it as json and using pagination, or maybe just a switch in the cli call.

My C# is very rusty, but would be happy to assist otherwise.

workflow Response status code does not indicate success: 401 (Unauthorized).

Hi Folks, I try to create action workflow but I have this issue :

Version: 0.32.0.0 Using token credential: ChainedTokenCredential to fetch a token. Fetching subscription details... Token retrieved and expires at: 09/01/2023 17:12:06 +00:00 Retrieving data from /subscriptions//?api-version=2019-11-01 using the following payload: �[38;5;8mnull�[0m Response status code is OK and got payload size of 397 Retrieved subscription details: �[38;5;8m�[0m �[38;5;12m"id"�[0m�[38;5;11m:�[0m �[38;5;9m"/subscriptions/"�[0m�[38;5;8m,�[0m �[38;5;12m"authorizationSource"�[0m�[38;5;11m:�[0m �[38;5;9m"Bypassed"�[0m�[38;5;8m,�[0m �[38;5;12m"managedByTenants"�[0m�[38;5;11m:�[0m �[38;5;8m[�[0m �[38;5;8m],�[0m �[38;5;12m"subscriptionId"�[0m�[38;5;11m:�[0m �[38;5;9m""�[0m�[38;5;8m,�[0m �[38;5;12m"tenantId"�[0m�[38;5;11m:�[0m �[38;5;9m""�[0m�[38;5;8m,�[0m �[38;5;12m"displayName"�[0m�[38;5;11m:�[0m �[38;5;9m"Azure subscription 1"�[0m�[38;5;8m,�[0m �[38;5;12m"state"�[0m�[38;5;11m:�[0m �[38;5;9m"Enabled"�[0m�[38;5;8m,�[0m �[38;5;12m"subscriptionPolicies"�[0m�[38;5;11m:�[0m �[38;5;8m�[0m �[38;5;12m"locationPlacementId"�[0m�[38;5;11m:�[0m �[38;5;9m"Public_2014-09-01"�[0m�[38;5;8m,�[0m �[38;5;12m"quotaId"�[0m�[38;5;11m:�[0m �[38;5;9m"FreeTrial_2014-09-01"�[0m�[38;5;8m,�[0m �[38;5;12m"spendingLimit"�[0m�[38;5;11m:�[0m �[38;5;9m"On"�[0m �[38;5;8m�[0m �[38;5;8m�[0m Retrieving data from /subscriptions//providers/Microsoft.CostMana gement/query?api-version=2021-10-01&$top=5000 using the following payload: �[38;5;8m�[0m �[38;5;12m"type"�[0m�[38;5;11m:�[0m �[38;5;9m"ActualCost"�[0m�[38;5;8m,�[0m �[38;5;12m"timeframe"�[0m�[38;5;11m:�[0m �[38;5;9m"BillingMonthToDate"�[0m�[38;5;8m,�[0m �[38;5;12m"timePeriod"�[0m�[38;5;11m:�[0m �[38;5;8mnull,�[0m �[38;5;12m"dataSet"�[0m�[38;5;11m:�[0m �[38;5;8m�[0m �[38;5;12m"granularity"�[0m�[38;5;11m:�[0m �[38;5;9m"Daily"�[0m�[38;5;8m,�[0m �[38;5;12m"aggregation"�[0m�[38;5;11m:�[0m �[38;5;8m�[0m �[38;5;12m"totalCost"�[0m�[38;5;11m:�[0m �[38;5;8m�[0m �[38;5;12m"name"�[0m�[38;5;11m:�[0m �[38;5;9m"Cost"�[0m�[38;5;8m,�[0m �[38;5;12m"function"�[0m�[38;5;11m:�[0m �[38;5;9m"Sum"�[0m �[38;5;8m,�[0m �[38;5;12m"totalCostUSD"�[0m�[38;5;11m:�[0m �[38;5;8m�[0m �[38;5;12m"name"�[0m�[38;5;11m:�[0m �[38;5;9m"CostUSD"�[0m�[38;5;8m,�[0m �[38;5;12m"function"�[0m�[38;5;11m:�[0m �[38;5;9m"Sum"�[0m �[38;5;8m�[0m �[38;5;8m***,�[0m �[38;5;12m"filter"�[0m�[38;5;11m:�[0m �[38;5;8mnull,�[0m �[38;5;12m"sorting"�[0m�[38;5;11m:�[0m �[38;5;8m[�[0m �[38;5;8m�[0m �[38;5;12m"direction"�[0m�[38;5;11m:�[0m �[38;5;9m"Ascending"�[0m�[38;5;8m,�[0m �[38;5;12m"name"�[0m�[38;5;11m:�[0m �[38;5;9m"UsageDate"�[0m �[38;5;8m�[0m �[38;5;8m]�[0m �[38;5;8m�[0m �[38;5;8m�[0m Fetching cost data... Response status code is Unauthorized and got payload size of 156 Response content: "error":"code":"RBACAccessDenied","message":"The client does not have authorization to perform action. Request ID: 69fea753-8348-423d-90f1-85085ebec592"*** �[38;5;9mError:�[0m Response status code does not indicate success: 401 (Unauthorized).

I use az ad sp create-for-rbac --name "FinOpsCli" --role "Cost Management Reader" --scopes /subscriptions/Sub-ID1/resourceGroups/FinOpsRG --sdk-auth to assign role to sp and get AZURE_CREDENTIALS.

Best regards,

Monthly issue metrics report

Issue Metrics

Metric Value
Average time to first response 5:30:56
Average time to close 1 day, 4:23:03
Average time to answer None
Number of items that remain open 0
Number of items closed 2
Total number of items created 2
Title URL Author Time to first response Time to close Time to answer
workflow Response status code does not indicate success: 401 (Unauthorized). #71 ilyhel 5:30:56 2 days, 3:35:11 None
Monthly issue metrics report #70 github-actions[bot] None 5:10:55 None

This report was generated with the Issue Metrics Action
Search query used to find these items: repo:mivano/azure-cost-cli is:issue created:2023-09-01..2023-09-30 -reason:"not planned"

BadRequest running azure-cost show

Reproduction steps:

  1. az login
  2. az account set -s [subscriptionId]
  3. azure-cost show -s [subscriptionId] --debug

I receive:

Response status code is BadRequest and got payload size of 905
Response content: {"error":{"code":"BadRequest","message":"Invalid query definition: Invalid dataset grouping: 'BillingPeriod'; valid values:
'ResourceGroup','ResourceGroupName','ResourceType','ResourceId','ResourceLocation','SubscriptionId','SubscriptionName','MeterCategory','MeterSubcategory','Meter
','ServiceFamily','UnitOfMeasure','PartNumber','BillingAccountName','BillingProfileId','BillingProfileName','InvoiceSection','InvoiceSectionId','InvoiceSectionN
ame','Product','ResourceGuid','ChargeType','ServiceName','ProductOrderId','ProductOrderName','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: 3075b6e8-3c39-4607-8823-b42d43bd3226)"}}
Error: Response status code does not indicate success: 400 (Bad Request).

timeframe TheLastMonth error

I am using the following comand to extract my monthly cost:
azure-cost dailyCosts -b xxxxxxx --timeframe TheLastMonth --dimension ResourceGroupName --includeTags -o json

The timeframe TheLastMonth generates the following error:
Error: Response status code does not indicate success: 400 (Bad Request).

If I use TheLastBillingMonth as a timeframe the comand works just fine.

Is anybody facing a similar issue?

401 unauthorized

azure-cost accumulatedCost -s id returns

Error: Response status code does not indicate success: 401 (Unauthorized).

running az login before azure-cost return same result.
How can I login in azure-cost cli?

Accessing Government Cloud (High)

Awesome tool! I'm hoping that it can connect to the government cloud. Is there a command or switch/option that exists to set that?
After loggin in, I receive the following error message:
Error: Response status code does not indicate success: 404 (Not Found).

Analyse budgets

Check if budgets are correctly setup. And if missing, allow for calculating the values.

Feature request: - -o json should just be json

It would be helpful if the -o json caused just json to be sent to stdout but instead it also includes fetch messages. Can the fetch messages be sent to stderr instead?

Fetching subscription details...
Fetching cost data...
Fetching forecasted cost data...
Fetching cost data by service name...
Fetching cost data by location...
Fetching cost data by resource group...
{
   "totals"...

Monthly issue metrics report

Issue Metrics

Metric Average Median 90th percentile
Time to first response None None None
Time to close 4 days, 20:13:05 4 days, 20:13:05 4 days, 20:13:05
Time to answer None None None
Metric Count
Number of items that remain open 0
Number of items closed 1
Total number of items created 1
Title URL Author Time to first response Time to close Time to answer
Monthly issue metrics report #76 github-actions[bot] None 4 days, 20:13:05 None

This report was generated with the Issue Metrics Action
Search query used to find these items: repo:mivano/azure-cost-cli is:issue created:2023-10-01..2023-10-31 -reason:"not planned"

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.