Reputation: 1
I need to fetch few data related to cost for my azure subscription which are as follows below:
Fetch last 6 months cost by service. 2 Fetch last 6 months cost by resource group and resources
Daily cost of last 15 days.
Pls suggest some useful powershell scripting idea.
I tried using powershell scripting to fetch those details but couldn't able to do so.
I also tried using rest API method, az search graph query and using powershell CMDLETS as well but i am not able to get any appropriate data.
I am expecting evryone to providing me any powershell scripting to fetch those data.
Upvotes: 0
Views: 1215
Reputation: 1
Here is a sample command.
Invoke-AzCostManagementQuery -Scope "/subscriptions/***********" -Timeframe MonthToDate -Type Usage -DatasetGranularity 'Daily'
Column Row
------ ---
{UsageDate, Currency} {20201101 USD, 20201102 USD, 20201103 USD, 20201104 USD…}
Documentation: https://learn.microsoft.com/en-us/powershell/module/az.costmanagement/invoke-azcostmanagementquery?view=azps-9.1.0
Module: https://learn.microsoft.com/en-us/powershell/module/az.costmanagement/?view=azps-9.1.0
Upvotes: 0