Azure Functions + ServiceBus Trigger | Execute One message at a time | PowerShell

Paweł Kaczanowski 1 Reputation point
2022-05-27T12:01:36.763+00:00

I'm trying to one instance of Azure Function a time using ServiceBus Trigger.

I successfully configured Service Bus trigger to start DurableOrchestration when message arrive.
Now I want to force Azure Function to don't pickup another message until previous one is fully processed.

I was trying in host.json:

  1. "singleton": {
    "lockPeriod": "00:01:00"
    }
  2. "serviceBus": {
    "maxConcurrentCalls": 1,
    "maxConcurrentSessions": 1,
    "maxMessageBatchSize": 1,
    "messageHandlerOptions": {
    "maxConcurrentCalls": 1
    },
    "sessionHandlerOptions": {
    "maxConcurrentSessions": 1
    },
    "batchOptions": {
    "maxMessageCount": 1
    }
    }
  3. "durableTask": {
    "hubName": "%FunctionTaskHub%",
    "maxConcurrentActivityFunctions": 1,
    "maxConcurrentOrchestratorFunctions": 1,
    "maxEntityOperationBatchSize": 1
    }

And in local.settings.json:

  1. "FUNCTIONS_WORKER_PROCESS_COUNT": 1
  2. "WEBSITE_MAX_DYNAMIC_APPLICATION_SCALE_OUT": 1

No success.
I'm using PowerShell in Azure Function scripts.

I don't expect that one message processing will take more than 3min. Also I'm using Premium App Service plan.

Azure Service Bus
Azure Service Bus
An Azure service that provides cloud messaging as a service and hybrid integration.
700 questions
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,911 questions
Windows for business | Windows Server | User experience | PowerShell
{count} votes

2 answers

Sort by: Most helpful
  1. MughundhanRaveendran-MSFT 12,506 Reputation points
    2022-06-01T10:30:58.437+00:00

    Hi @Paweł Kaczanowski ,

    Thanks for reaching out to Q&A forum.

    The service bus configuration in the host.json looks perfect. This is the configuration is recommended for singleton processing of service bus triggered functions. Unfortunately, I am not able to reproduce the issue as I am able to achieve singleton processing at my end.

    Here is how my orchestration flow looks like service bus starter function -> Orchestrator -> Activity function
    If you look at the below execution, the service bus starter function started 2nd execution only after completing the 1st message's execution. There were 2 messages in the queue

    207532-image.png

    Only difference that I can see is the language, I am trying it in .net stack. Could you please provide the output/execution of your functions like the above image so that I will get an idea about the flow of your orchestration.


  2. Jayaprakash Kanagaraj 0 Reputation points
    2023-05-31T15:29:29.0566667+00:00

    I am using Service BUs Trigger only but message processing using Azure function in my design yet message send to another topic is after processing is slower than incoming messages.

    example: incoming message are 100k in 5 min yet it takes more than couple of hours to send it to another topic after processing. usually function take 20ms to process a message and using scheduledenquetime while sending it to another topic.

    anyone suggest me to faster way to send the message to another topic after processing. i feel same thing is happenign as function read one message per execution,

    any guidance to faster or make function read may be 100 messages per execution.

    my avg size of message is 100kb which should not be problem for cloud services as i understand the services.

    0 comments No comments

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.