首页 > 解决方案 > Azure 资源 API 字段可用于 $filters 和 $expand

问题描述

GET https://management.azure.com/subscriptions/{subscriptionId}/resources?$filter={$filter}&$expand={$expand}&$top={$top}&api-version=2018-02-01

我正在使用此 Azure 资源 API 来获取资源列表(逻辑应用程序连接)我需要知道可在 $filter 和 $expand 中使用的字段名称

从这里我得到了几个字段名称,如名称、资源类型、标记名、位置、资源组

但我需要过滤properties.displayname字段。我尝试使用 $expand 和 $filter。它不工作。

使用名称 $filter

https://management.azure.com/subscriptions/{subscriptionId}/resources?api-version=2018-02-01&$filter=(resourceGroup eq {resourcegroupname}) and **name eq {nametofilter}** and (resourcetype eq 'microsoft.web/connections')

不使用带有 $expand 的 displayname $filter

https://management.azure.com/subscriptions/{subscriptionId}/resources?$expand=ResourceProperties&api-version=2018-02-01&$filter=(resourceGroup eq {resourcegroupname}) and **ResourceProperties/displayName eq {nametofilter}** and (resourcetype eq 'microsoft.web/connections')

https://management.azure.com/subscriptions/{subscriptionId}/resources?$expand=Properties&api-version=2018-02-01&$filter=(resourceGroup eq {resourcegroupname}) and **Properties/displayName eq {nametofilter}** and (resourcetype eq 'microsoft.web/connections')

对带有 displayname 字段的 $filter 有什么建议吗?

标签: restazureazure-resource-manager

解决方案


根据我的测试,如果我使用resourcetype eq microsoft.web/connections过滤资源。但是没有显示名称字段。

据我所知,如果我们想使用 $filter 或 $expand,我们需要确保原始结果包含这些字段。

在此处输入图像描述


推荐阅读