Azure REST API-用于获取所有虚拟机的查询参数 [英] Azure REST API - query parameters for getting all the virtual machine

查看:74
本文介绍了Azure REST API-用于获取所有虚拟机的查询参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想查询预订中的所有虚拟机,但是我希望能够使用查询参数而不是代码进行过滤.

I want to query all the virtual Machines in a subscription, but I want to be able to filter using a query param and not by code.

我能够获得所有虚拟机,但是我想知道是否可以对其进行过滤以及如何进行过滤.

I am able to get all the virtual machines but I want to know if I can filter them and how.

我不是在使用经典的REST,而是在使用ARM.

I am not using the classic REST but ARM.

推荐答案

如果使用的是API,则:

If this is the API you use:

https://management.azure.com/subscriptions/{subscription-id}/resources?&api-version={api-version}

然后您可以使用以下过滤器:

then you can use filter like this:

?$filter={filter}

您的请求将如下所示:

https://management.azure.com/subscriptions/{subscription-id}/resources?$filter=name eq {resourcename}&api-version={api-version}

$filter是可选的,用于过滤结果.将{filter}替换为以下值之一:

$filter is optional and is used to filter results. Replace {filter} with one of the following values:

$filter=tagname eq {value}
$filter=tagname eq {tagname} and tagvalue eq {tagvalue}
$filter=startswith(tagname, {tagname prefix})
$filter=resourceType eq {resourceProviderNamespace/resourceType}
$filter=name eq {resourcename}
$filter=location eq {locationname}

当前,您不能标记名 tagvalue 过滤器与其他过滤器一起使用;例如,名称位置 resourceType .

Currently, you cannot use the tagname or tagvalue filters with other filters; such as, name, location, or resourceType.

要获取VM类型的所有资源,可以使用如下过滤器:

To get all the Resources of type VM you can use a filter like this:

$filter=resourceType eq {Microsoft.Compute/virtualMachines}

有关更多信息:

https://msdn.microsoft.com/en-us/library/azure/dn790569.aspx

这篇关于Azure REST API-用于获取所有虚拟机的查询参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆