Query items (container.query_items) for aio CosmosClient works for query that returns few items but fails when the number of items returned increase

Byiringiro, Nissi Fidele 0 Reputation points
2024-06-27T20:11:22.9533333+00:00

Hello, I'm relatively new to aio.CosmosClient which is a Cosmos DB Client for Python to be used with async code.
This is the snippet of my code in one function:

async_iter = container.query_items(
    query=sql_query,
    parameters=query_params,
    partition_key=my_partition_key
)

try:
    # Iterate asynchronously
    async for item in async_iter:
        yield item
except Exception as e:
	raise Exception(f"{e}")

And I use the following code to iterate through the results in another function:

result = []
async for item in items:
    result.append(item)

The issue is that this code works when the query returns fewer items but fails with the following error when the query has to return a lot of items.
Error details: 0, message='', url=URL(url_to_my_docs)

My query should return 14,000+ items, it works when I apply a TOP 500, but fails with the error mentioned above when I remove the TOP 500.

Can anyone advise on what to do in this case?

Thank you

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,518 questions
{count} votes