An Azure Function should be stateless as there's no control over where and when function instances are provisioned and de-provisioned. Managing and storing data/state between requests can lead to inconsistencies.
If, for any reason, you need to have a stateful function, consider using the Durable Functions extension of Azure Functions.
// If you want to factorize the description uncomment the following line and create the file.
// A compliant solution would be to manage the `numOfRequests` with an entity function or would use storage (e.g., Azure Blob storage, Azure Queue Storage)
// to share the state between functions.
string responseMessage = $"HttpRequest was made on port {port}.";
* https://docs.microsoft.com/en-us/azure/azure-functions/performance-reliability#write-functions-to-be-stateless[Improve the performance and reliability of Azure Functions]