I have a HTTP Trigger Azure Durable Functions on C# and I use Azurite as local storage for the function. So when I run or debug the project locally, the activity functions are triggered automatically without any http request. I stop debugging, then start it again, the problem is gone. It does not do that the second time. However, this has become annoying. Every time I have to start, stop and then start again if I want to debug. Maybe there is some caching somewhere that triggers activity functions automatically I don't know. Here is my structure:
public static async Task<HttpResponseMessage> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = "orchestrators/{functionName}")] HttpRequestMessage req,
[DurableClient] IDurableClient starter,
string functionName,
ILogger log)
{
[FunctionName(nameof(SynchronizeAllCoursesOrchestrator))]
public static async Task<HttpResponseMessage> SynchronizeAllCoursesOrchestrator([OrchestrationTrigger] IDurableOrchestrationContext context)
{
var input = context.GetInput<FunctionInput>();
return await context.CallActivityAsync<HttpResponseMessage>(nameof(SynchronizeAllCourses), input);
}
[FunctionName(nameof(SynchronizeAllCourses))]
public async Task<HttpResponseMessage> RunAsync([ActivityTrigger] IDurableActivityContext context, ILogger log)
{
So whenever I click start/debug, the activity function runs immediately. I then have to stop, and re-run all the time for it to listen to requests and not run immediately. How do I stop it from not running immediately?
Thanks to @juunas 's answer above, I was able to solve the problem. I have installed Azure Storage Explorer after running Azurite locally and realized that Azurite has been creating/saving a lot of data and not deleting it when stopped. So I manually went through and cleared all the tables, and it started to behave accordingly.
In short, it is enough to just clear testhubname-workitems
queue before running. Then you won't get the problem again.
Additional information edit:
After further suggestions from @juunas . I set my hubName to "SerhatsDurableFunctionsHub" and I was able to rename the storage names to: