gpt4 book ai didi

azure 摊销成本使用开始和使用结束日期错误,同时将其作为变量传递

转载 作者:行者123 更新时间:2023-12-03 02:11:55 24 4
gpt4 key购买 nike

我正在尝试在订阅级别提取 azure 摊销成本,但是当我以硬编码方式传递usage_start_date和usage_end_date时,我能够提取数据:示例:"https://management.azure.com/subscriptions/"+subs+"/providers/Microsoft.Conspiration/usageDetail?$filter=properties/usageStart eq '2022-05-01' 和properties/usageEnd eq '2022-05-31'&metric=AmortizedCost&api-version=2021-10-01"

但是当我将开始使用和开始结束日期作为变量传递时,它会抛出错误。API示例:

f"https://management.azure.com/subscriptions/{subs}/providers/Microsoft.Consumption/usageDetails?$filter=properties/usageStart eq {start_date} and properties/usageEnd eq {end_date}&metric=AmortizedCost&api-version=2021-10-01"

喜欢:

'message': 'Billing Period is not supported in (2019-10-01) API Version for Subscription Scope With Web Direct Offer. Please provide the UsageStart and UsageEnd dates in the $filter key as parameters.'}}

{'error': {'code': '400',
'message': 'Billing Period is not supported in (2021-10-01) API Version for Subscription Scope With Web Direct Offer. Please provide the UsageStart and UsageEnd dates in the $filter key as parameters. (Request ID: f2d9517e-e438-42b3-865e-df2d5888da62)'}}

我尝试了许多选项/组合来通过传递日期范围变量来提取数据,但它给了我同样的错误。我也尝试过此链接中的 API:

https://learn.microsoft.com/en-us/azure/cost-management-billing/costs/manage-automation#get-usage-details-for-a-scope-during-specific-date-range

你能指导我我做错了什么吗?我该如何解决这个问题?

最佳答案

最后这对我有帮助

not working:
costmanagement_client.usage_details.list( scope=f'/subscriptions/{subscription_id}/', filter=f"properties/usageEnd eq {end_date} and properties/usageStart eq {start_date}")

working:
costmanagement_client.usage_details.list( scope=f'/subscriptions/{subscription_id}/', filter=f"properties/usageEnd eq '{end_date}' and properties/usageStart eq '{start_date}'")

只需输入引号即可

关于 azure 摊销成本使用开始和使用结束日期错误,同时将其作为变量传递,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73093695/

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