diff --git a/azure/durable_functions/models/DurableOrchestrationClient.py b/azure/durable_functions/models/DurableOrchestrationClient.py index 6b473c2c..7825171d 100644 --- a/azure/durable_functions/models/DurableOrchestrationClient.py +++ b/azure/durable_functions/models/DurableOrchestrationClient.py @@ -311,20 +311,30 @@ async def get_status_all(self) -> List[DurableOrchestrationStatus]: """ options = RpcManagementOptions() request_url = options.to_url(self._orchestration_bindings.rpc_base_url) - response = await self._get_async_request(request_url) - switch_statement = { - 200: lambda: None, # instance completed - } - - has_error_message = switch_statement.get( - response[0], - lambda: f"The operation failed with an unexpected status code {response[0]}") - error_message = has_error_message() - if error_message: - raise Exception(error_message) - else: - statuses: List[Any] = response[1] - return [DurableOrchestrationStatus.from_json(o) for o in statuses] + all_statuses: List[DurableOrchestrationStatus] = [] + + continuation_token = None + while True: + headers = {} + if continuation_token: + headers['x-ms-continuation-token'] = continuation_token + response = await self._get_async_request(request_url, headers=headers) + switch_statement = { + 200: lambda: None, # instance completed + } + has_error_message = switch_statement.get( + response[0], + lambda: f"The operation failed with an unexpected status code {response[0]}") + error_message = has_error_message() + if error_message: + raise Exception(error_message) + else: + statuses: List[Any] = response[1] + all_statuses.extend([DurableOrchestrationStatus.from_json(o) for o in statuses]) + continuation_token = response.headers.get('x-ms-continuation-token') + if not continuation_token: + break + return all_statuses async def get_status_by(self, created_time_from: datetime = None, created_time_to: datetime = None, diff --git a/azure/durable_functions/models/utils/http_utils.py b/azure/durable_functions/models/utils/http_utils.py index e45cef68..d2bfc6fe 100644 --- a/azure/durable_functions/models/utils/http_utils.py +++ b/azure/durable_functions/models/utils/http_utils.py @@ -1,4 +1,4 @@ -from typing import Any, List, Union +from typing import Any, List, Union, Dict, Optional import aiohttp @@ -29,20 +29,22 @@ async def post_async_request(url: str, data: Any = None) -> List[Union[int, Any] return [response.status, data] -async def get_async_request(url: str) -> List[Any]: +async def get_async_request(url: str, headers: Dict[Any, Any] = None) -> List[Any]: """Get the data from the url provided. Parameters ---------- url: str url to get the data from + headers: Dict[str, str] + headers to send with the request Returns ------- [int, Any] Tuple with the Response status code and the data returned from the request """ - async with aiohttp.ClientSession() as session: + async with aiohttp.ClientSession(headers=headers) as session: async with session.get(url) as response: data = await response.json(content_type=None) if data is None: