I'm developing an Azure Function that executes several operations in Dynamics 365 CRM. I don't fully understand how Azure Functions concurrency works. I have a Consumption Plan, my Azure Function has a function inside that is triggered by a Service Bus message.
When I tested it the first time, the service bus received around 200 messages and the app started processing a lot of messages at the same time, making a huge load of requests to dynamics 365 that couldn't handle them. So in the Azure Portal I managed to set the max number of instances to 1, but still the function was processing many messages at one time. What's the best way to set a limit to that? Using maxConcurrentCalls in host.json? Using maxConcurrentSessions in host.json? Using WEBSITE_MAX_DYNAMIC_APPLICATION_SCALE_OUT in the app configs?
Also, what's the difference between setting maxConcurrentCalls at 10, and 1 function instance or setting it at 5 with 2 function instances?