如何在azure订阅中使用powershell获取成本管理?



我需要获取一些与我的azure订阅成本相关的数据,如下所示:

  1. 按服务收费最近6个月。2按资源组和资源获取最近6个月的成本

  2. 最近15天每日成本。

请建议一些有用的powershell脚本思想。

我尝试使用powershell脚本获取这些详细信息,但无法这样做。

我也尝试使用rest API方法,az搜索图查询和使用powershell CMDLETS,但我无法获得任何适当的数据。

我希望每个人都能为我提供任何powershell脚本来获取这些数据。

下面是一个示例命令:

Invoke-AzCostManagementQuery -Scope "/subscriptions/***********" -Timeframe MonthToDate -Type Usage -DatasetGranularity 'Daily'
Column                Row
------                ---
{UsageDate, Currency} {20201101 USD, 20201102 USD, 20201103 USD, 20201104 USD…}

文档:https://learn.microsoft.com/en-us/powershell/module/az.costmanagement/invoke-azcostmanagementquery?view=azps-9.1.0

模块:https://learn.microsoft.com/en-us/powershell/module/az.costmanagement/?view=azps-9.1.0

最新更新