我正在使用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'
答案 0 :(得分:2)
正如您所指出的那样,对标签的支持不是追溯性的,仅适用于将标签应用于资源后报告的使用情况。 $filter
和$apply
参数分别支持基于标签的过滤和聚合。
有关更多详细信息,您可以参考此article。