0

I know its possible to have an Azure function run as a singleton

However, from what I can see this is only possible on a global scale, i.e. all functions are impacted

Singleton Azure function running as separate instances

Is there a way of ensuring that functions that dont have run as singleton attribute scale as normal?

Paul

Paul
  • 2,773
  • 7
  • 41
  • 96

1 Answers1

0

It still has an issue to use singleton in a specific azure function instance. Check this github discussions

For achieving this you must use the orchestrator this also has some limitations

We ensure that only one instance of a specific orchestrator runs at a time. The singleton behavior in Durable Functions by assigning a specific instance ID to an orchestrator when creating it.

Implementing the orchestrator function, it doesn't actually matter. It is a regular orchestrator function it starts, it executes and it completes the task, or one orchestrator runs forever. The Most important is that there is only ever one instance running at a time.

We have to add the instance ID while calling the orchestration function

 Route = "orchestrators/{functionName}/{instanceId}

Note There is a potential race condition in this sample. If two instances of HttpStartSingle execute concurrently, both function calls will report success, but only one orchestration instance will start. Depending on your requirements, this may have undesirable side effects. For this reason, it is important to ensure that no two requests can execute this trigger function concurrently.

Refer here

Delliganesh Sevanesan
  • 4,146
  • 1
  • 5
  • 15