Your RestClient might be implementing IDisposable, to make sure the underlying networking resources it uses are properly deallocated after each request. With thousands of invocations, the Application Plan VM serving your function might simply have run out of ports etc.
Carefully check your RestClient and related objects and make sure to Dispose of anything that supports disposing.