gpt4 book ai didi

Azure 成本管理 API 不遵循所需的日期筛选器

转载 作者:行者123 更新时间:2023-12-03 06:12:20 25 4
gpt4 key购买 nike

我正在 .NET 中编写一个程序来检索订阅的使用成本。 HTTP请求的结构是这样的:

https://management.azure.com/subscriptions/(here_goes_the_subscription_number)/providers/Microsoft.Consumption/usageDetails?startDate=2023-06-01&endDate=2023-06-02&api-version=2021-10-01

问题是:无论我在“startDate”和“endDate”中输入什么日期,它总是从该月的第 1 天开始检索当月的所有成本数据。例如:如果今天是 7 月 15 日,则无论我指定的日期间隔如何,该请求都会向我提供从 7 月 1 日到 7 月 15 日的所有费用数据。

我做错了什么?非常感谢您为这个变相受折磨的灵魂提供的任何反馈。

最佳答案

I agree with @Anupam Chand, API response differs based on the type of subscription that you are currently using.

To retrieve the usage cost of a subscription within specific duration,you need to include $filter in query that works with only Enterprise Agreement (EA) or a pay-as-you-go subscriptions and not supported byMicrosoft Customer Agreements subscription.

如果您有企业协议(protocol) (EA)即用即付订阅,您可以通过包含 $filter 来使用以下查询 检索特定时间内订阅的使用费用:

GET https://management.azure.com/subscriptions/<subID>/providers/Microsoft.Consumption/usageDetails?$filter=properties/usageStart ge '2023-06-01' and properties/usageEnd le '2023-06-02'&$top=1000&api-version=2019-10-01

我有一个 Azure 帐户,其现收现付订阅如下:

enter image description here

当我通过包含不同日期的 $filter 来运行下面的查询时,我成功地得到了不同的结果,如下所示:

查询 1:

GET https://management.azure.com/subscriptions/<subID>/providers/Microsoft.Consumption/usageDetails?$filter=properties/usageStart ge '2023-07-01' and properties/usageEnd le '2023-07-02'&$top=1000&api-version=2019-10-01

回应:

POSTMAN SNAP

查询 2:

GET https://management.azure.com/subscriptions/<subID>/providers/Microsoft.Consumption/usageDetails?$filter=properties/usageStart ge '2023-07-01' and properties/usageEnd le '2023-07-04'&$top=1000&api-version=2019-10-01

回应:

POSTMAN SNAP

引用:

Manage Azure costs with automation - Microsoft Cost Management

关于Azure 成本管理 API 不遵循所需的日期筛选器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76614605/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com