Azure proposes different trigger functions: for blob file, http request, service bus, etc ... The site Azure Functions HTTP trigger explains how to use them. These functions are asynchronous, aren't they? At least that's what we think, based on our experiment. The trigger function for service bus messages is defined as followed: def test_function(msg: func.ServiceBusMessage): message = msg.get_body().decode('utf-8') do_sthg(message) # Our function def do_sthg(var1): # The following won't be printed unly 10000 before the next incomming message, which is understandable, if the trigger function is async. for i in range(10000): print(var1) print(f"message: {var1}") How can we force the function to wait for the do_sthg() function to finish executing its code? Some operations need to be performed before the next incoming message. Is there a better way to do this? { "version": "2.0", "extensionBundle": { "id": "Microsoft.Azure.Functions.ExtensionBundle", "version": "[4.0.0, 5.0.0)" } "extensions": { "serviceBus": { "clientRetryOptions":{ "mode": "exponential", "tryTimeout": "00:01:00", "delay": "00:00:00.80", "maxDelay": "00:01:00", "maxRetries": 3 }, "autoCompleteMessages": true, "maxAutoLockRenewalDuration": "00:05:00", "maxConcurrentCalls": 16, "maxConcurrentSessions": 8, "maxMessageBatchSize": 1000, "maxBatchWaitTime": "00:00:30", "sessionIdleTimeout": "00:01:00", "enableCrossEntityTransactions": false } } } I have played around with different parameter values, but I have not managed to find a way for my program to run message by message, or for the trigger function to wait for the do_sthg() function to finish. Continue reading...