admin管理员组

文章数量:1399269

My Function App is using Azure Durable Functions triggered by Service Bus to process scheduled messages.

Sometimes, these messages aren't being received by my Function App but the messages disappear from the queue and after the full activity time they are being rescheduled and put on the queue for next week, which is part of my logic at the end of my activity function. So while none of the code inside is being logged or executed on my Function App end, the rescheduling shows that maybe it's being received and processed elsewhere?

There are no signs of my ServiceBusTrigger triggering in the logs when this happens. But when my Function App receives it and processes the message, all the logs show correctly.

Also, when I stop my Function App through Azure portal, the messages are still being consumed and rescheduled.

This behavior doesn't happen every message but happens pretty often. It never used to occur until last week when it first started, it's been consistently happening after that.

I've tried creating a new queue and restarting my Function App, but these didn't help. There are no deployment slots and I can't think of anywhere else that it may be running.

Is this behavior truly because there my Function App may be running elsewhere? Or there's another reason why this may be happening?

What can I do to ensure that this doesn't keep happening? Can I somehow "overwrite" all instances so I can restart and ensure that only my Function App is running?

My Function App is using Azure Durable Functions triggered by Service Bus to process scheduled messages.

Sometimes, these messages aren't being received by my Function App but the messages disappear from the queue and after the full activity time they are being rescheduled and put on the queue for next week, which is part of my logic at the end of my activity function. So while none of the code inside is being logged or executed on my Function App end, the rescheduling shows that maybe it's being received and processed elsewhere?

There are no signs of my ServiceBusTrigger triggering in the logs when this happens. But when my Function App receives it and processes the message, all the logs show correctly.

Also, when I stop my Function App through Azure portal, the messages are still being consumed and rescheduled.

This behavior doesn't happen every message but happens pretty often. It never used to occur until last week when it first started, it's been consistently happening after that.

I've tried creating a new queue and restarting my Function App, but these didn't help. There are no deployment slots and I can't think of anywhere else that it may be running.

Is this behavior truly because there my Function App may be running elsewhere? Or there's another reason why this may be happening?

What can I do to ensure that this doesn't keep happening? Can I somehow "overwrite" all instances so I can restart and ensure that only my Function App is running?

Share Improve this question edited Mar 26 at 13:30 ksatione asked Mar 26 at 13:28 ksationeksatione 33 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 0

Sometimes, these messages aren't being received by my Function App but the messages disappear from the queue and after the full activity time they are being rescheduled and put on the queue for next week, which is part of my logic at the end of my activity function.

Since the messages disappear and you get the end result of your orchestration, I'm going to say that your Durable Function does execute.

It sounds like a logging issue to me. I can't say for sure why that is happening. It could be e.g. Application Insights sampling where it doesn't store all logs to reduce log volume.

*My Function App is using Azure Durable Functions triggered by Service Bus to process scheduled messages. Sometimes, these messages aren't being received by my Function App but the messages disappear from the queue and after the full activity time they are being rescheduled and put on the queue for next week, which is part of my logic at the end of my activity function. So while none of the code inside is being logged or executed on my Function App end, the rescheduling shows that maybe it's being received and processed elsewhere?

To resolve this you need to check few things mentioned below. Check Function App Scaling Settings Your Azure Function App may be scaling out unexpectedly, causing multiple instances of the function to run and potentially lead to competing consumers or missing messages.

Go to Azure Portal and navigate to your Function App. In the left-hand menu, click on Scale up (App Service plan) to check if your app is set to automatically scale.

If it's on Consumption Plan, your functions could be scaled automatically based on load, which could cause multiple instances of your function to be triggered simultaneously.

If it's set to Premium or App Service Plan, check the scaling settings to ensure it’s not scaling out beyond the limit you're expecting. You can lock this to a single instance if needed.

If you want to ensure only a single instance is processing, you can set the Instance count to 1 for your App Service Plan.

Check for Competing Consumers on Service Bus Queue It sounds like the messages might be getting consumed by something other than your function app. You need to ensure there are no other consumers (such as other functions or apps) consuming messages from the same Service Bus queue.

Navigate to the Service Bus namespace in the Azure portal. Click on Queues and select the queue your Function App is listening to. Review Service Bus Metrics for your queue (check the Incoming Messages, Dead-lettered Messages, etc.). Look for any unusual patterns, like messages disappearing but not being successfully processed by your function.

*Check Service Bus Subscriptions: If your Service Bus queue is being used by multiple consumers, they could be picking up the messages. In that case, ensure that only your Durable Function is processing messages, and check for other consumers. To confirm that your Function App is the only consumer, temporarily disable other consumers or ensure that only your Function App is configured to trigger from this queue.

*Test OSC Message Sending Independently: Verify that the OSC message sending logic works as expected in isolation (outside of the Durable Function). Test if the OSC messages are being sent successfully with a simple test script or application. Check for Network or API Issues: If your OSC messages rely on a specific port or protocol, check the firewall settings or API logs on the receiving end.

*Check and Adjust Service Bus Message Lock Duration If your messages are being locked but not fully processed in the expected time frame, the Service Bus lock might expire, and the message might be released back into the queue. This can cause issues where your function doesn’t complete the processing before the lock expires. Go to your Service Bus queue in the Azure portal. Click on the Queue Settings and look for the Lock Duration setting. The default lock duration is 30 seconds, which may be too short if your function processes messages slowly. Increase the lock duration (for example, set it to 60 or 90 seconds) to give your function more time to process messages before the lock expires.

*Monitor Function App Logs Using Application Insights If your Function App isn’t processing messages, there may be an issue with the function execution, and logs could help identify why. Enable Application Insights for your Function App if it isn’t already enabled. Application Insights is a powerful monitoring tool that tracks function execution details, including triggers and exceptions. In the Azure portal, go to your Function App and click on Application Insights under the Monitoring section. In the Application Insights section, go to Logs (Log Analytics) and run queries to check if the function is being triggered by the Service Bus messages.

This query will show any logs related to the Service Bus trigger. Look for missing triggers or errors that might explain why your function isn’t receiving messages.

If no logs are found, there might be an issue with the trigger itself, which we will address in the next step.

*Check for Function Timeouts or Long-Running Activities If your function is processing long-running activities, it may be running into timeouts. For Durable Functions, this can be especially important because activities that take too long can be retried or rescheduled. Check the timeout settings for your activity functions in the Durable Function. In Durable Functions, you can control the timeout of individual activities. Review your orchestration functions to make sure the activities are being executed within the allowed time frames.

本文标签: