Not able to filter groups/products by displayName via Resource Manager REST API

Lev Kuznetsov 0 Reputation points
2024-09-11T11:23:36.88+00:00

I am using Python azure-mgmt-apimanagemen package version 4.0.1 and trying to filter list of groups and products by their display names.

I'm using the following code snippet:

from azure.identity import DefaultAzureCredential
from azure.mgmt.apimanagement import ApiManagementClient

client = ApiManagementClient(
    credential=DefaultAzureCredential(),
    subscription_id="subscription-id",
)
group = client.group.list_by_service(
    resource_group_name="resource-group-name",
    service_name="service-name",
    filter="displayName eq 'MyGroup'",
)

And as a result I am receiving an error that displayName property not exists on type urn:microsoft:windowsazure:apimanagement:mgmt.group:

azure.core.exceptions.HttpResponseError: (ValidationError) Could not find a property named 'displayName' on type 'urn:microsoft:windowsazure:apimanagement:mgmt.group'.Code: ValidationErrorMessage: Could not find a property named 'displayName' on type 'urn:microsoft:windowsazure:apimanagement:mgmt.group'.

I observe the same behavior for products.

However, according documentation it should be possible.

Can anyone please suggest if it is possible to filter a list of entities by the displayName field?

Thank you in advance!

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,116 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. LeelaRajeshSayana-MSFT 15,161 Reputation points Microsoft Employee
    2024-09-16T20:01:11.5+00:00

    Hi @Lev Kuznetsov Greetings! Welcome to Microsoft Q&A forum. Thank you for posting this question here.

    I have tested the APIM Python SDK in house and could replicated the same behavior. The SDK is working as expected when filtering name, description and externalId properties. However, it is failing for displayName I have reached out to the team internally to check on this issue. I will get back to you with more details on this as soon as I get an update from the team.

    In the meantime, you can use the following approach to filter on the displayName property.

    client = ApiManagementClient(credential=DefaultAzureCredential(), subscription_id=sub_id)
    
    groups = client.group.list_by_service(
        resource_group_name="<ResourceGroupName>",
        service_name="<APIMInstanceName>"
    )
    
    products = client.product.list_by_service(
        resource_group_name="lsayanaintegrationwest",
        service_name="lsayanaapimwest"
    )
    
    
    # Filter the groups based on display name
    filtered_groups = [group for group in groups if group.display_name == "<displayName>"]
    
    for item in filtered_groups:
        print(item)
    
    # Filter the prodcuts based on display name
    filtered_products = [product for product in products if product.display_name == "<displayName>
    "]
    
    
    for item in filtered_products:
        print(item)
    
    
    

    Hope this helps!


    If the response helped, please do click Accept Answer and Yes for the answer provided. Doing so would help other community members with similar issue identify the solution. I highly appreciate your contribution to the community.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.