0

我正在尝试使用Microsoft.Azure.Management.Compute'sComputeManagementClient来查询ResourceSKU。但我无法为过滤器参数提供正确的值。如果没有过滤器,响应会非常大,我想通过使用 resourceType = virtualMachines 进行过滤来减少它。

更具体地说,这是我的代码:

ComputeManagementClient computeManagementClient = new ComputeManagementClient(credentials);
computeManagementClient.SubscriptionId = "**********";
string filter = "resourceType eq 'virtualMachines'";  // Doesn't work. All results are returned.
// string filter = "$filter=resourceType eq 'virtualMachines'";  // Doesn't work. All results are returned.
// string filter = "resourceType eq virtualMachines";  // Doesn't work. All results are returned.
// string filter = "resourceType eq 'Microsoft.Compute/virtualMachines'";  // Doesn't work. All results are returned.
// string filter = "resourceType = 'virtualMachines'";  // Doesn't work. All results are returned.
// string filter = "resourceType='virtualMachines'";  // Doesn't work. All results are returned.
IPage<ResourceSku> resourceSkus = await computeManagementClient.ResourceSkus.ListAsync(filter: filter);

我还尝试使用OData.FilterString.Generate生成过滤字符串:

Expression<Func<ResourceSku, bool>> filterPredicate = x => x.ResourceType.Equals("virtualMachines", StringComparison.OrdinalIgnoreCase);
string filter = FilterString.Generate(filterPredicate);
IPage<ResourceSku> resourceSkus = await computeManagementClient.ResourceSkus.ListAsync(filter: filter);

知道什么是正确的格式吗?

4

1 回答 1

1

根据我的研究,ResourceSkus API 只支持按区域过滤。更多详情请参考反馈文章

于 2020-01-09T06:58:37.947 回答