简体   繁体   中英

Multiple resource filters in ARM REST API

I am trying to use the $filter property on ARM rest api to filter for both tag, value and resource type. Filtering on tag and its value works, resource type only works. But the combination of them returns a bad request

I am using this endpoint to retrieve all resources within one Azure subscription. https://docs.microsoft.com/en-us/rest/api/resources/resources/list#code-try-0

I want to retrieve all of my VM's with a specific tag and the value. I, therefore, need to use the filter property.

Basically, any of these filters work on their own

resourceType eq 'Microsoft.Compute/virtualMachines' or tagname eq 'serverType' and tagvalue eq 'Citrix'

but not this: resourceType eq 'Microsoft.Compute/virtualMachines' and tagname eq 'serverType' and tagvalue eq 'Citrix'

  "error": {
    "code": "InvalidFilterInQueryString",
    "message": "Invalid $filter 'resourceType eq 'Microsoft.Compute/virtualMachines' and tagname eq 'serverType' and tagvalue eq 'Citrix'' specified in the query string."
  }
}

This is a known bug, more details are here . Note that it's a sdk bug, but the sdk also calls this api.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM