Ho to Fix : Result: Failure Exception: ConnectionError: HTTPSConnectionPool(host='graph.microsoft.com', port=443): Max retries exceeded

TOUIL Adhen (External) 0 Reputation points
2024-06-30T19:51:15.57+00:00

Hello Everyone,

I'm facing an issue with an Azure Function in my application that performs a loop over 500 items using Python. For each item, it makes an API call to Microsoft Graph to retrieve the content of an excel file based on its ID.

After successfully processing a certain number of requests(about 300), the function starts to fail with the following error message:

*Result: Failure Exception: ConnectionError: HTTPSConnectionPool(host='graph.microsoft.com', port=443): Max retries exceeded with url: /v1.0/sites/site_id/drives/drive_id/items/item_id (Caused by NameResolutionError("

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,366 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. hossein jalilian 5,175 Reputation points
    2024-06-30T23:05:59.1166667+00:00

    Thanks for posting your question in the Microsoft Q&A forum.

    This problem is likely related to network constraints or resource limitations.

    • Add a robust retry mechanism to your function to handle temporary network failures.
    • Implement connection pooling in your Python code to reuse connections and reduce the overhead of creating new connections for each request.
    • If your function is timing out before completing all requests, consider increasing the function timeout in your host.json file.
    • Instead of making individual API calls for each item, use Microsoft Graph's batching capabilities to reduce the number of network requests.
    • Implement asynchronous programming techniques in your Python code to improve performance and handle multiple requests concurrently.

    Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful

    0 comments No comments