简体   繁体   中英

How to apply filter on results from List all Azure Rest API

I want to apply a filter on all the result return via NSG to only name or a specific name is this possible?

$uri = "https://management.azure.com/subscriptions/xxxxxx/providers/Microsoft.Network/networkSecurityGroups?`$filter=name eq 'xxx-nsg'&api-version=2020-07-01"

This returns all the result without a filter. I would like to use equals/contains to filter

One possible solution is to make use of List Resources API. That allows you to specify $filter criteria with support for contains query.

For example, I tried to list the storage accounts in my Azure Subscription that contained v2 in it. This is how my request URL looks like:

https://management.azure.com/subscriptions/xxxx/resources?api-version=2020-06-01&$filter=resourceType eq 'Microsoft.Storage/storageAccounts' and substringof('v2', name)

For you, I guess the same URL would be something like:

https://management.azure.com/subscriptions/xxxx/resources?api-version=2020-06-01&$filter=resourceType eq 'Microsoft.Network/networkSecurityGroups' and substringof('xxx', name)

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