Is it possible to ensure an Azure Function executes only once in parallel?

Riccardo Bruè 0 Reputation points
2024-12-02T11:47:30.5566667+00:00

I have the requirement to execute an Azure Function (let's call it OperationalFunction) only once in parallel. What I mean is the following:

I have two "entry point" functions:

  • I have a BlobTrigger Function (BlobTriggeredStartFunction)
  • I have a HttpTrigger Function (HttpTriggeredStartFunction)

Both of those functions call an orchestrator function (OrchestratorFunction) like this:

string instanceId = await starter.StartNewAsync(nameof(OrchestrationFunction),null,data);

This orchestration function has the following code:

[FunctionName("OrchestrationFunction")]
public async Task OrchestrationFunction(
[OrchestrationTrigger] IDurableOrchestrationContext context){
   var input = context.GetInput<string>();
   await context.CallActivityAsync(nameof(OperationalFunction),input);
}

I want that the OperationalFunction is executed ONLY ONCE in parallel, so that if I receive multiple triggers (n blob/http-triggered events), the OperationalFunction at a certain time, is executing only one instance, when such instance finishes, then the new event in the queue (FIFO) is executed.

Which is the best approach to that?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,185 questions
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,971 questions
{count} votes

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.