Azure用法详细信息REST API-无法筛选标签

时间:2020-07-27 23:58:43

标签: azure api rest postman

我正在使用PostMan对Azure的REST API进行GET标注。根据他们的API Docs on usageDetail,您可以使用$filter查询参数来过滤类似tags eq 'Project ID:PR-008016'这样的标签。我三重检查了标签是否在Azure中存在并且它们是正确的,但是当我在$filter参数中使用这些标签时,我得到200响应,但它返回一个空的values数组。

对于上下文,此$filter参数将返回数据并正确过滤:

$filter=properties/usageStart eq '2020-07-22' and properties/usageEnd eq '2020-08-01'

但是当我添加tags过滤器时,它将返回空白的values数组:

$filter=properties/usageStart eq '2020-07-22' and properties/usageEnd eq '2020-08-01' and tags eq 'Project ID:PR-008016'

有人知道语法是否不正确?还是Azure REST Api可能存在错误?this comment可能存在产品错误)

完整端点:

https://management.azure.com/subscriptions/{{subscriptionId}}/providers/Microsoft.Consumption/usageDetails?api-version=2019-10-01&$filter=properties/usageStart eq '2020-07-22' and properties/usageEnd eq '2020-08-01' and tags eq 'Project ID:PR-008016'

1 个答案:

答案 0 :(得分:2)

正如您所指出的那样,对标签的支持不是追溯性的,仅适用于将标签应用于资源后报告的使用情况$filter$apply参数分别支持基于标签的过滤和聚合。

有关更多详细信息,您可以参考此article