How to stop multithreading in azure function

Ujwala Kavathekar 0 Reputation points
2023-06-15T17:16:31.9966667+00:00

Hello,

We have one azure function which triggered from service bus queue. Function calls another API and we need to stop multiple calls to API, Causing some requests are failing to reach destination API and also we need to call API sequentially. So how to handle this in azure. we tried multiple options in host.json extension like below. still not working. Please let me know if there is any solution. Thank you!

"extensions": {
    "serviceBus": {
      "prefetchCount": 1,
      "batchOptions": {
        "maxMessageCount": 1
      }
    }
  }
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,399 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Tulika Priyadarshini 165 Reputation points Microsoft Employee
    2023-06-16T10:43:13.0433333+00:00

    You can use the Singleton attribute to ensure that only one instance of a function runs, even when there are multiple instances of the host web app. https://learn.microsoft.com/en-us/azure/app-service/webjobs-sdk-how-to#singleton-attribute


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.